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

Add iWallet as new APM #218

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
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 @@ -25,6 +25,7 @@ public enum ApmType {
CHIPPIN,
PAYMOB,
BIZUM,
IWALLET,
FUND_TRANSFER,
CASH_ON_DELIVERY
}
1 change: 1 addition & 0 deletions src/main/java/io/craftgate/model/PaymentProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@ public enum PaymentProvider {
CHIPPIN,
PAYMOB,
BIZUM,
IWALLET,
OFFLINE,
}
93 changes: 91 additions & 2 deletions src/test/java/io/craftgate/sample/PaymentSample.java
Original file line number Diff line number Diff line change
Expand Up @@ -987,10 +987,10 @@ void init_sodexo_apm_payment() {
.externalId("optional-externalId")
.callbackUrl("https://www.your-website.com/craftgate-apm-callback")
.apmUserIdentity("5555555555")
.items(items)
.additionalParams(new HashMap() {{
put("sodexoCode", "843195");
}})
.items(items)
.build();

ApmPaymentInitResponse response = craftgate.payment().initApmPayment(request);
Expand Down Expand Up @@ -1085,6 +1085,95 @@ void init_paypal_apm_payment() {
assertEquals(ApmAdditionalAction.REDIRECT_TO_URL, response.getAdditionalAction());
}

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

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

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

InitApmPaymentRequest request = InitApmPaymentRequest.builder()
.apmType(ApmType.IWALLET)
.price(BigDecimal.valueOf(1))
.paidPrice(BigDecimal.valueOf(1))
.currency(Currency.TRY)
.paymentGroup(PaymentGroup.LISTING_OR_SUBSCRIPTION)
.conversationId("456d1297-908e-4bd6-a13b-4be31a6e47d5")
.externalId("optional-externalId")
.callbackUrl("https://www.your-website.com/craftgate-apm-callback")
.apmUserIdentity("1111222233334444")
.items(items)
.build();

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

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

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

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

InitApmPaymentRequest request = InitApmPaymentRequest.builder()
.apmType(ApmType.IWALLET)
.price(BigDecimal.valueOf(1))
.paidPrice(BigDecimal.valueOf(1))
.currency(Currency.TRY)
.paymentGroup(PaymentGroup.LISTING_OR_SUBSCRIPTION)
.conversationId("456d1297-908e-4bd6-a13b-4be31a6e47d5")
.externalId("optional-externalId")
.callbackUrl("https://www.your-website.com/craftgate-apm-callback")
.apmUserIdentity("1111222233334444")
.items(items)
.additionalParams(new HashMap() {{
put("otpCode", "1234");
}})
.build();

ApmPaymentInitResponse response = craftgate.payment().initApmPayment(request);
assertNotNull(response.getPaymentId());
assertNull(response.getRedirectUrl());
assertEquals(PaymentStatus.SUCCESS, response.getPaymentStatus());
assertEquals(ApmAdditionalAction.NONE, response.getAdditionalAction());
}

@Test
void complete_iwallet_apm_payment() {
CompleteApmPaymentRequest request = CompleteApmPaymentRequest.builder()
.paymentId(1L)
.additionalParams(new HashMap() {{
put("otpCode", "1122");
}})
.build();

ApmPaymentCompleteResponse response = craftgate.payment().completeApmPayment(request);
assertNotNull(response.getPaymentId());
assertEquals(PaymentStatus.SUCCESS, response.getPaymentStatus());
}

@Test
void init_klarna_apm_payment() {
List<PaymentItem> items = new ArrayList<>();
Expand Down Expand Up @@ -1552,7 +1641,7 @@ void retrieve_payment() {
@Test
void retrieve_loyalties() {
RetrieveLoyaltiesRequest request = RetrieveLoyaltiesRequest.builder()
.cardNumber("4043080000000003")
.cardNumber("5188961939192544")
.expireYear("2044")
.expireMonth("07")
.cvc("000")
Expand Down
Loading