Skip to content

Commit

Permalink
Adds tompay integration (#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
abalikci authored Oct 31, 2023
1 parent 66a63d9 commit fa82269
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/main/java/io/craftgate/model/ApmAdditionalAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@ public enum ApmAdditionalAction {
REDIRECT_TO_URL,

OTP_REQUIRED,
WAIT_FOR_WEBHOOK,
APPROVAL_REQUIRED,
NONE
}
1 change: 1 addition & 0 deletions src/main/java/io/craftgate/model/ApmType.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public enum ApmType {
AFTERPAY,
KASPI,
STRIPE,
TOMPAY,
FUND_TRANSFER,
CASH_ON_DELIVERY
}
1 change: 1 addition & 0 deletions src/main/java/io/craftgate/model/PaymentMethod.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ public enum PaymentMethod {
KLARNA,
AFTERPAY,
KASPI,
TOMPAY,
STRIPE
}
3 changes: 2 additions & 1 deletion src/main/java/io/craftgate/model/PaymentProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ public enum PaymentProvider {
YKB_WORLD_PAY,
APPLEPAY,
GOOGLEPAY,
STRIPE
STRIPE,
TOMPAY
}
38 changes: 38 additions & 0 deletions src/test/java/io/craftgate/sample/PaymentSample.java
Original file line number Diff line number Diff line change
Expand Up @@ -1172,6 +1172,44 @@ void init_kaspi_apm_payment() {
assertEquals(ApmAdditionalAction.REDIRECT_TO_URL, response.getAdditionalAction());
}

@Test
void init_tompay_apm_payment() {
List<PaymentItem> items = new ArrayList<>();

items.add(PaymentItem.builder()
.name("item 1")
.externalId(UUID.randomUUID().toString())
.price(BigDecimal.valueOf(0.6))
.build());

items.add(PaymentItem.builder()
.name("item 2")
.externalId(UUID.randomUUID().toString())
.price(BigDecimal.valueOf(0.4))
.build());

InitApmPaymentRequest request = InitApmPaymentRequest.builder()
.apmType(ApmType.TOMPAY)
.price(BigDecimal.ONE)
.paidPrice(BigDecimal.ONE)
.currency(Currency.TRY)
.paymentGroup(PaymentGroup.LISTING_OR_SUBSCRIPTION)
.conversationId("conversationId")
.externalId("externalId")
.callbackUrl("https://www.your-website.com/craftgate-apm-callback")
.items(items)
.additionalParams(new HashMap() {{
put("channel", "channel");
put("phone", "5001112233");
}})
.build();

ApmPaymentInitResponse response = craftgate.payment().initApmPayment(request);
assertNotNull(response.getPaymentId());
assertEquals(PaymentStatus.WAITING, response.getPaymentStatus());
assertEquals(ApmAdditionalAction.WAIT_FOR_WEBHOOK, response.getAdditionalAction());
}

@Test
void init_ykb_world_pay_pos_apm_payment() {
List<PaymentItem> items = new ArrayList<>();
Expand Down

0 comments on commit fa82269

Please sign in to comment.