Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds tompay integration #144

Merged
merged 1 commit into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading