Skip to content
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
26 changes: 26 additions & 0 deletions src/test/java/com/adyen/CheckoutTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -665,4 +665,30 @@ public void TestSessionsCheckDefaultValues() throws Exception {
final JsonNode actual = mapper.readTree(captor.getValue());
assertEquals(expected, actual);
}

@Test
public void testPixActionQrCode() throws Exception {
Client client = createMockClientFromFile("mocks/checkout/pixQrCodeResponse.json");

PaymentRequest paymentRequest = new PaymentRequest();
paymentRequest.setAmount(new Amount().currency("EUR").value(100000L));
paymentRequest.lineItems(
Arrays.asList(
new LineItem().id("Item 1").amountIncludingTax(40000L),
new LineItem().id("Item 2").amountIncludingTax(60000L)));
paymentRequest.shopperName(new Name().firstName("Jose").lastName("Silva"));
paymentRequest.setPaymentMethod(
new CheckoutPaymentMethod(new PixDetails().type(PixDetails.TypeEnum.PIX)));
PaymentsApi checkout = new PaymentsApi(client);
PaymentResponse paymentResponse = checkout.payments(paymentRequest);
assertEquals("8815658961765250", paymentResponse.getPspReference());
assertEquals(PaymentResponse.ResultCodeEnum.PENDING, paymentResponse.getResultCode());

assertNotNull(paymentResponse.getAction());
final CheckoutQrCodeAction qrCodeAction = paymentResponse.getAction().getCheckoutQrCodeAction();
assertNotNull(qrCodeAction);
assertEquals(CheckoutQrCodeAction.TypeEnum.QRCODE, qrCodeAction.getType());
assertEquals("pix", qrCodeAction.getPaymentMethodType());
assertEquals("DMhpN90TFR2e7TzwHYRFkhw4brxm2wHBg", qrCodeAction.getQrCodeData());
}
}
15 changes: 15 additions & 0 deletions src/test/resources/mocks/checkout/pixQrCodeResponse.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"additionalData": {
"pix.expirationDate": "2021-12-21T13:00:00-03:00",
"acquirerReference": "00000000008815658961765250",
"acquirerAccountCode": "PixBTGAcquirerAccount"
},
"pspReference": "8815658961765250",
"resultCode": "Pending",
"action": {
"paymentData": "Ab02b4c0!BQABAgA...",
"paymentMethodType": "pix",
"type": "qrCode",
"qrCodeData": "DMhpN90TFR2e7TzwHYRFkhw4brxm2wHBg"
}
}