-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
78 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,7 +38,6 @@ | |
import java.util.*; | ||
|
||
|
||
import static java.util.List.of; | ||
import static org.junit.Assert.*; | ||
import static org.mockito.ArgumentMatchers.*; | ||
import static org.mockito.Mockito.mock; | ||
|
@@ -455,10 +454,6 @@ public void TestCheckoutPaymentMethodSerialisation() throws Exception { | |
Assert.assertTrue(checkoutPaymentMethodApple.toJson().contains("NRWtuNlNEWkRCSm1xWndjMDFFbktkQU")); | ||
} | ||
|
||
|
||
/** | ||
* | ||
*/ | ||
@Test | ||
public void TestPaymentWithRatepay() throws Exception { | ||
Client client = createMockClientFromFile("mocks/checkout/paymentResponseRatepay.json"); | ||
|
@@ -470,7 +465,7 @@ public void TestPaymentWithRatepay() throws Exception { | |
.paymentMethod(new CheckoutPaymentMethod(ratepayDetails)) | ||
.amount(new Amount() | ||
.currency("EUR") | ||
.value(1000L)) | ||
.value(700L)) | ||
.shopperName(new Name() | ||
.firstName("Simon") | ||
.lastName("Hopper")) | ||
|
@@ -483,7 +478,7 @@ public void TestPaymentWithRatepay() throws Exception { | |
.street("Simon Carmiggeltstraat") | ||
.postalCode("1011 DJ")) | ||
.deviceFingerprint("eyJ2ZXJzaW9uIjoiMS4wLjAiLCJkZXZ...") | ||
.lineItems(List.of(new LineItem().quantity(1L) | ||
.lineItems(Arrays.asList(new LineItem().quantity(1L) | ||
.amountExcludingTax(331L) | ||
.taxPercentage(2100L) | ||
.description("Shoes") | ||
|
@@ -521,4 +516,71 @@ public void TestPaymentWithRatepay() throws Exception { | |
); | ||
} | ||
|
||
@Test | ||
public void TestPaymentWithRiverty() throws Exception { | ||
Client client = createMockClientFromFile("mocks/checkout/paymentResponseRiverty.json"); | ||
|
||
RivertyDetails rivertyDetails = new RivertyDetails() | ||
.type(RivertyDetails.TypeEnum.SEPADIRECTDEBIT_RIVERTY) | ||
.iban("NL13TEST0123456789"); | ||
|
||
PaymentRequest paymentRequest = new PaymentRequest() | ||
.paymentMethod(new CheckoutPaymentMethod(rivertyDetails)) | ||
.amount(new Amount() | ||
.currency("EUR") | ||
.value(700L)) | ||
.shopperName(new Name() | ||
.firstName("Simon") | ||
.lastName("Hopper")) | ||
.telephoneNumber("+31858888138") | ||
.shopperIP("123.123.123.123") | ||
.shopperEmail("[email protected]") | ||
.billingAddress(new BillingAddress() | ||
.country("NL") | ||
.city("Amsterdam") | ||
.houseNumberOrName("6-50") | ||
.street("Simon Carmiggeltstraat") | ||
.postalCode("1011 DJ")) | ||
.deliveryAddress(new DeliveryAddress() | ||
.country("NL") | ||
.city("Amsterdam") | ||
.houseNumberOrName("6-50") | ||
.street("Simon Carmiggeltstraat") | ||
.postalCode("1011 DJ")) | ||
.deviceFingerprint("eyJ2ZXJzaW9uIjoiMS4wLjAiLCJkZXZ...") | ||
.lineItems(Arrays.asList(new LineItem().quantity(1L) | ||
.amountExcludingTax(331L) | ||
.taxPercentage(2100L) | ||
.description("Shoes") | ||
.id("Item #1") | ||
.taxAmount(69L) | ||
.amountIncludingTax(400L), | ||
new LineItem() | ||
.quantity(2L) | ||
.amountExcludingTax(248L) | ||
.taxPercentage(2100L) | ||
.description("Socks") | ||
.id("Item #2") | ||
.taxAmount(52L) | ||
.amountIncludingTax(300L))); | ||
paymentRequest.setPaymentMethod(new CheckoutPaymentMethod(rivertyDetails)); | ||
PaymentsApi checkout = new PaymentsApi(client); | ||
PaymentResponse paymentResponse = checkout.payments(paymentRequest); | ||
|
||
assertNull(paymentResponse.getPspReference()); | ||
assertEquals(PaymentResponse.ResultCodeEnum.REDIRECTSHOPPER, paymentResponse.getResultCode()); | ||
assertEquals(CheckoutRedirectAction.TypeEnum.REDIRECT, paymentResponse.getAction().getCheckoutRedirectAction().getType()); | ||
assertEquals("https://checkoutshopper-test.adyen.com/checkoutshopper…", paymentResponse.getAction().getCheckoutRedirectAction().getUrl()); | ||
|
||
|
||
verify(client.getHttpClient()).request( | ||
"https://checkout-test.adyen.com/v71/payments", | ||
paymentRequest.toJson(), | ||
client.getConfig(), | ||
false, | ||
null, | ||
ApiConstants.HttpMethod.POST, | ||
null | ||
); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/test/resources/mocks/checkout/paymentResponseRiverty.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"action": { | ||
"paymentMethodType": "riverty", | ||
"method": "GET", | ||
"url": "https://checkoutshopper-test.adyen.com/checkoutshopper…", | ||
"type": "redirect" | ||
}, | ||
"resultCode": "RedirectShopper" | ||
} |