use of com.ingenico.connect.gateway.sdk.java.domain.payment.definitions.RedirectPaymentProduct809SpecificInput in project connect-sdk-java by Ingenico-ePayments.
the class IdempotenceTest method test.
/**
* Smoke test for idempotence.
*/
@Test
public void test() throws URISyntaxException, IOException {
CreatePaymentRequest body = new CreatePaymentRequest();
Order order = new Order();
AmountOfMoney amountOfMoney = new AmountOfMoney();
amountOfMoney.setCurrencyCode("EUR");
amountOfMoney.setAmount(100L);
order.setAmountOfMoney(amountOfMoney);
Customer customer = new Customer();
customer.setLocale("en");
Address billingAddress = new Address();
billingAddress.setCountryCode("NL");
customer.setBillingAddress(billingAddress);
order.setCustomer(customer);
body.setOrder(order);
RedirectPaymentMethodSpecificInput paymentMethodSpecificInput = new RedirectPaymentMethodSpecificInput();
paymentMethodSpecificInput.setReturnUrl("http://example.com/");
paymentMethodSpecificInput.setPaymentProductId(809);
RedirectPaymentProduct809SpecificInput paymentProductSpecificInput = new RedirectPaymentProduct809SpecificInput();
paymentProductSpecificInput.setIssuerId("INGBNL2A");
paymentMethodSpecificInput.setPaymentProduct809SpecificInput(paymentProductSpecificInput);
body.setRedirectPaymentMethodSpecificInput(paymentMethodSpecificInput);
String idempotenceKey = UUID.randomUUID().toString();
CallContext context = new CallContext().withIdempotenceKey(idempotenceKey);
Client client = getClient();
try {
CreatePaymentResponse response = client.merchant("20000").payments().create(body, context);
String paymentId = response.getPayment().getId();
Assert.assertEquals(idempotenceKey, context.getIdempotenceKey());
Assert.assertNull(context.getIdempotenceRequestTimestamp());
response = client.merchant("20000").payments().create(body, context);
Assert.assertEquals(paymentId, response.getPayment().getId());
Assert.assertEquals(idempotenceKey, context.getIdempotenceKey());
Assert.assertNotNull(context.getIdempotenceRequestTimestamp());
} finally {
client.close();
}
}
Aggregations