Skip to content

Commit ba65d07

Browse files
authored
Add Setcard (#244)
* Add Setcard * Add Setcard
1 parent 4bbb264 commit ba65d07

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed

src/main/java/io/craftgate/model/ApmType.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,6 @@ public enum ApmType {
3131
PAYCELL_DCB,
3232
IWALLET,
3333
FUND_TRANSFER,
34+
SETCARD,
3435
CASH_ON_DELIVERY
3536
}

src/main/java/io/craftgate/model/PaymentProvider.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,6 @@ public enum PaymentProvider {
3838
PAYLANDS_MB_WAY,
3939
PAYCELL_DCB,
4040
IWALLET,
41+
SETCARD,
4142
OFFLINE,
4243
}

src/test/java/io/craftgate/sample/PaymentSample.java

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1659,6 +1659,58 @@ void init_garanti_pay_pos_apm_payment() {
16591659
assertEquals(AdditionalAction.REDIRECT_TO_URL, response.getAdditionalAction());
16601660
}
16611661

1662+
@Test
1663+
void init_setcard_apm_payment() {
1664+
List<PaymentItem> items = new ArrayList<>();
1665+
1666+
items.add(PaymentItem.builder()
1667+
.name("item 1")
1668+
.externalId(UUID.randomUUID().toString())
1669+
.price(BigDecimal.valueOf(0.6))
1670+
.build());
1671+
1672+
items.add(PaymentItem.builder()
1673+
.name("item 2")
1674+
.externalId(UUID.randomUUID().toString())
1675+
.price(BigDecimal.valueOf(0.4))
1676+
.build());
1677+
1678+
Map<String, String> additionalParams = new HashMap<>();
1679+
additionalParams.put("cardNumber", "7599640961180814");
1680+
1681+
InitApmPaymentRequest request = InitApmPaymentRequest.builder()
1682+
.apmType(ApmType.SETCARD)
1683+
.price(BigDecimal.ONE)
1684+
.paidPrice(BigDecimal.ONE)
1685+
.currency(Currency.TRY)
1686+
.callbackUrl("https://www.your-website.com/craftgate-3DSecure-callback")
1687+
.paymentGroup(PaymentGroup.LISTING_OR_SUBSCRIPTION)
1688+
.conversationId("conversationId")
1689+
.externalId("externalId")
1690+
.additionalParams(additionalParams)
1691+
.items(items)
1692+
.build();
1693+
1694+
ApmPaymentInitResponse response = craftgate.payment().initApmPayment(request);
1695+
assertNotNull(response.getPaymentId());
1696+
assertEquals(PaymentStatus.WAITING, response.getPaymentStatus());
1697+
assertEquals(ApmAdditionalAction.OTP_REQUIRED, response.getAdditionalAction());
1698+
}
1699+
1700+
@Test
1701+
void complete_setcard_pos_apm_payment() {
1702+
CompleteApmPaymentRequest request = CompleteApmPaymentRequest.builder()
1703+
.paymentId(1L)
1704+
.additionalParams(new HashMap<String, String>() {{
1705+
put("otpCode", "123456");
1706+
}})
1707+
.build();
1708+
1709+
ApmPaymentCompleteResponse response = craftgate.payment().completeApmPayment(request);
1710+
assertNotNull(response.getPaymentId());
1711+
assertEquals(PaymentStatus.SUCCESS, response.getPaymentStatus());
1712+
}
1713+
16621714
@Test
16631715
void complete_pos_apm_payment() {
16641716
CompletePosApmPaymentRequest request = CompletePosApmPaymentRequest.builder()

0 commit comments

Comments
 (0)