Skip to content

Commit

Permalink
Add TestPaymentWithRiverty
Browse files Browse the repository at this point in the history
  • Loading branch information
gcatanese committed Nov 18, 2024
1 parent 811ec12 commit 2f1727c
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 7 deletions.
76 changes: 69 additions & 7 deletions src/test/java/com/adyen/CheckoutTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand All @@ -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"))
Expand All @@ -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")
Expand Down Expand Up @@ -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 src/test/resources/mocks/checkout/paymentResponseRiverty.json
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"
}

0 comments on commit 2f1727c

Please sign in to comment.