Skip to content

Commit

Permalink
Add GarantiPay v2 integration (#160)
Browse files Browse the repository at this point in the history
  • Loading branch information
onurpolattimur authored Mar 22, 2024
1 parent 8c66efa commit b1b6cc5
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/main/java/io/craftgate/model/PosApmPaymentProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
public enum PosApmPaymentProvider {

YKB_WORLD_PAY,
YKB_WORLD_PAY_SHOPPING_LOAN,
GOOGLEPAY,
APPLEPAY
GARANTI_PAY,
}
37 changes: 37 additions & 0 deletions src/test/java/io/craftgate/sample/PaymentSample.java
Original file line number Diff line number Diff line change
Expand Up @@ -1247,6 +1247,43 @@ void init_ykb_world_pay_pos_apm_payment() {
assertEquals(AdditionalAction.SHOW_HTML_CONTENT, response.getAdditionalAction());
}

@Test
void init_garanti_pay_pos_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());

InitPosApmPaymentRequest request = InitPosApmPaymentRequest.builder()
.price(BigDecimal.ONE)
.paidPrice(BigDecimal.ONE)
.currency(Currency.TRY)
.paymentGroup(PaymentGroup.LISTING_OR_SUBSCRIPTION)
.conversationId("456d1297-908e-4bd6-a13b-4be31a6e47d5")
.paymentProvider(PosApmPaymentProvider.GARANTI_PAY)
.additionalParams(new HashMap() {{
put("integrationType", "WEB2APP");
}})
.callbackUrl("https://www.your-website.com/craftgate-pos-apm-callback")
.items(items)
.build();

InitPosApmPaymentResponse response = craftgate.payment().initPosApmPayment(request);
assertNotNull(response.getPaymentId());
assertNotNull(response.getAdditionalData().get("redirectUrl"));
assertEquals(PaymentStatus.WAITING, response.getPaymentStatus());
assertEquals(AdditionalAction.REDIRECT_TO_URL, response.getAdditionalAction());
}

@Test
void complete_pos_apm_payment() {
CompletePosApmPaymentRequest request = CompletePosApmPaymentRequest.builder()
Expand Down

0 comments on commit b1b6cc5

Please sign in to comment.