Search in sources :

Example 11 with PaymentDetails

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());
    }
}
Also used : PaymentDetails(jp.ne.paypay.model.PaymentDetails) ApiException(jp.ne.paypay.ApiException)

Example 12 with PaymentDetails

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;
}
Also used : PaymentDetails(jp.ne.paypay.model.PaymentDetails) ApiException(jp.ne.paypay.ApiException)

Example 13 with PaymentDetails

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");
}
Also used : Payment(jp.ne.paypay.model.Payment) MerchantOrderItem(jp.ne.paypay.model.MerchantOrderItem) ArrayList(java.util.ArrayList) MoneyAmount(jp.ne.paypay.model.MoneyAmount) PaymentDetails(jp.ne.paypay.model.PaymentDetails) ApiResponse(jp.ne.paypay.ApiResponse) Test(org.junit.jupiter.api.Test)

Example 14 with PaymentDetails

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");
}
Also used : PaymentDetails(jp.ne.paypay.model.PaymentDetails) ApiResponse(jp.ne.paypay.ApiResponse) Test(org.junit.jupiter.api.Test)

Example 15 with PaymentDetails

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);
}
Also used : PaymentStateCaptures(jp.ne.paypay.model.PaymentStateCaptures) CaptureObject(jp.ne.paypay.model.CaptureObject) MoneyAmount(jp.ne.paypay.model.MoneyAmount) PaymentDetails(jp.ne.paypay.model.PaymentDetails) Capture(jp.ne.paypay.model.Capture) ApiResponse(jp.ne.paypay.ApiResponse) Test(org.junit.jupiter.api.Test)

Aggregations

PaymentDetails (jp.ne.paypay.model.PaymentDetails)29 ApiResponse (jp.ne.paypay.ApiResponse)9 Test (org.junit.jupiter.api.Test)9 Call (com.squareup.okhttp.Call)8 Type (java.lang.reflect.Type)8 ApiException (jp.ne.paypay.ApiException)7 Payment (jp.ne.paypay.model.Payment)5 MoneyAmount (jp.ne.paypay.model.MoneyAmount)4 WalletBalance (jp.ne.paypay.model.WalletBalance)4 CaptureObject (jp.ne.paypay.model.CaptureObject)2 ArrayList (java.util.ArrayList)1 ApiClient (jp.ne.paypay.ApiClient)1 Configuration (jp.ne.paypay.Configuration)1 PaymentApi (jp.ne.paypay.api.PaymentApi)1 PendingPaymentApi (jp.ne.paypay.api.PendingPaymentApi)1 Capture (jp.ne.paypay.model.Capture)1 MerchantOrderItem (jp.ne.paypay.model.MerchantOrderItem)1 PaymentStateCaptures (jp.ne.paypay.model.PaymentStateCaptures)1 QRCodeDetails (jp.ne.paypay.model.QRCodeDetails)1 DisplayName (org.junit.jupiter.api.DisplayName)1