use of jp.ne.paypay.model.PaymentDetails in project paypayopa-sdk-java by paypay.
the class PendingPaymentApiExample method cancelPendingOrder.
private static void cancelPendingOrder(final PendingPaymentApi pendingPaymentApi, String merchantPaymentId) {
try {
pendingPaymentApi.cancelPendingOrder(merchantPaymentId);
PaymentDetails cancelledPendingOrder = getPendingPaymentDetails(pendingPaymentApi, merchantPaymentId);
System.out.println("\n\nCancel Pending Order API RESPONSE\n------------------\n");
System.out.println(cancelledPendingOrder);
} catch (ApiException e) {
System.err.println("Exception when calling PaymentApi#cancelPendingOrder" + e.getMessage());
System.err.println(e.getResponseBody());
}
}
use of jp.ne.paypay.model.PaymentDetails in project paypayopa-sdk-java by paypay.
the class PendingPaymentApiExample method getPendingPaymentDetails.
private static PaymentDetails getPendingPaymentDetails(final PendingPaymentApi apiInstance, String merchantPaymentId) {
PaymentDetails result = null;
try {
result = apiInstance.getPaymentDetails(merchantPaymentId);
System.out.println("\nAPI RESPONSE\n------------------\n");
System.out.println(result.getResultInfo().getCode());
System.out.println(result);
} catch (ApiException e) {
System.err.println(e.getResponseBody());
}
return result;
}
use of jp.ne.paypay.model.PaymentDetails in project paypayopa-sdk-java by paypay.
the class PaymentApiTest method createPaymentTest.
/**
* Create a payment
*
* Create a direct debit payment and start the money transfer. **Timeout: 30s**
*
* @throws ApiException if the Api call fails
*/
@Test
public void createPaymentTest() throws ApiException {
Payment payment = new Payment();
payment.setAmount(new MoneyAmount().amount(10).currency(MoneyAmount.CurrencyEnum.JPY));
payment.setMerchantPaymentId("merchantPaymentId");
payment.setUserAuthorizationId("userAuthorizationId");
payment.setRequestedAt(Instant.now().getEpochSecond());
payment.setStoreId(RandomStringUtils.randomAlphabetic(8));
payment.setTerminalId(RandomStringUtils.randomAlphanumeric(8));
payment.setOrderReceiptNumber(RandomStringUtils.randomAlphanumeric(8));
payment.setOrderDescription("Payment for Order ID:" + UUID.randomUUID().toString());
MerchantOrderItem merchantOrderItem = new MerchantOrderItem().category("Dessert").name("Red Velvet Cake").productId(RandomStringUtils.randomAlphanumeric(8)).quantity(1).unitPrice(new MoneyAmount().amount(10).currency(MoneyAmount.CurrencyEnum.JPY));
List<MerchantOrderItem> merchantOrderItems = new ArrayList<>();
merchantOrderItems.add(merchantOrderItem);
payment.setOrderItems(new ArrayList<MerchantOrderItem>(merchantOrderItems));
PaymentDetails paymentDetails = new PaymentDetails();
paymentDetails.setResultInfo(resultInfo);
String agreeSimilarTransaction = "True";
ApiResponse<PaymentDetails> paymentDetailsApiResponse = new ApiResponse<>(00001, null, paymentDetails);
Mockito.when(api.createPaymentWithHttpInfo(payment, agreeSimilarTransaction)).thenReturn(paymentDetailsApiResponse);
PaymentDetails response = api.createPayment(payment, agreeSimilarTransaction);
Assert.assertEquals(response.getResultInfo().getMessage(), "SUCCESS");
}
use of jp.ne.paypay.model.PaymentDetails in project paypayopa-sdk-java by paypay.
the class PaymentApiTest method getPaymentDetailsTest.
/**
* Get payment details
*
* Get payment details. **Timeout: 15s**
*
* @throws ApiException if the Api call fails
*/
@Test
public void getPaymentDetailsTest() throws ApiException {
String merchantPaymentId = "merchantPaymentId";
PaymentDetails paymentDetails = new PaymentDetails();
paymentDetails.setResultInfo(resultInfo);
ApiResponse<PaymentDetails> paymentDetailsApiResponse = new ApiResponse<>(00001, null, paymentDetails);
Mockito.when(apiClient.escapeString(merchantPaymentId)).thenReturn(merchantPaymentId);
Mockito.when(api.getPaymentDetailsWithHttpInfo(merchantPaymentId)).thenReturn(paymentDetailsApiResponse);
PaymentDetails response = api.getPaymentDetails(merchantPaymentId);
Assert.assertEquals(response.getResultInfo().getMessage(), "SUCCESS");
}
use of jp.ne.paypay.model.PaymentDetails in project paypayopa-sdk-java by paypay.
the class PaymentApiTest method capturePaymentAuthTest.
/**
* Capture a payment authorization
*
* This api is used to capture the payment authorization for a payment **Timeout: 30s**
*
* @throws ApiException if the Api call fails
*/
@Test
public void capturePaymentAuthTest() throws ApiException {
CaptureObject captureObject = new CaptureObject();
captureObject.setMerchantCaptureId(UUID.randomUUID().toString());
captureObject.setMerchantPaymentId("merchantPaymentId");
captureObject.setAmount(new MoneyAmount().amount(10).currency(MoneyAmount.CurrencyEnum.JPY));
captureObject.setOrderDescription("new Order");
captureObject.setRequestedAt(Instant.now().getEpochSecond());
PaymentDetails paymentDetails = new PaymentDetails();
paymentDetails.setResultInfo(resultInfo);
payment.setStatus(PaymentState.StatusEnum.COMPLETED);
PaymentStateCaptures paymentStateCaptures = new PaymentStateCaptures();
Capture capture = new Capture();
capture.acceptedAt(Instant.now().getNano());
capture.amount(payment.getAmount());
capture.setExpiresAt(Instant.now().getNano());
capture.setAmountDescription("amount captured");
capture.setMerchantCaptureId(captureObject.getMerchantCaptureId());
capture.setOrderDescription(captureObject.getOrderDescription());
capture.setRequestedAt(captureObject.getRequestedAt());
capture.setAcceptedAt(Instant.now().getNano());
capture.setStatus(Capture.StatusEnum.COMPLETED);
Assert.assertNotNull(capture.toString());
paymentStateCaptures.addDataItem(capture);
payment.setCaptures(paymentStateCaptures);
paymentDetails.setData(payment);
ApiResponse<PaymentDetails> paymentDetailsApiResponse = new ApiResponse<>(00001, null, paymentDetails);
Mockito.when(api.capturePaymentAuthWithHttpInfo(captureObject)).thenReturn(paymentDetailsApiResponse);
PaymentDetails response = api.capturePaymentAuth(captureObject);
Assert.assertNotNull(response.toString());
Assert.assertEquals(response.getResultInfo().getMessage(), "SUCCESS");
Assert.assertNotNull(response.getData());
Assert.assertEquals(response.getData().getMerchantPaymentId(), "merchantPaymentId");
Assert.assertEquals(response.getData().getUserAuthorizationId(), "userAuthorizationId");
Assert.assertEquals(response.getData().getStatus(), Payment.StatusEnum.COMPLETED);
Assert.assertNotNull(response.getData().getTerminalId());
Assert.assertNotNull(response.getData().getOrderReceiptNumber());
Assert.assertNotNull(response.getData().getCaptures());
Assert.assertNotNull(response.getData().getCaptures().getData().get(0));
Assert.assertNotNull(response.getData().getCaptures().getData().get(0).getAcceptedAt());
Assert.assertNotNull(response.getData().getCaptures().getData().get(0).getAmount());
Assert.assertNotNull(response.getData().getCaptures().getData().get(0).getAmountDescription());
Assert.assertNotNull(response.getData().getCaptures().getData().get(0).getExpiresAt());
Assert.assertNotNull(response.getData().getCaptures().getData().get(0).getMerchantCaptureId());
Assert.assertNotNull(response.getData().getCaptures().getData().get(0).getOrderDescription());
Assert.assertEquals(response.getData().getCaptures().getData().get(0).getStatus(), Capture.StatusEnum.COMPLETED);
}
Aggregations