Search in sources :

Example 1 with Payment

use of jp.ne.paypay.model.Payment in project paypayopa-sdk-java by paypay.

the class PaymentApiTest method setUp.

@BeforeEach
public void setUp() {
    apiClient = Mockito.mock(ApiClient.class);
    api.setApiClient(apiClient);
    resultInfo = new ResultInfo();
    resultInfo.setMessage("SUCCESS");
    payment = new Payment();
    payment.setAmount(new MoneyAmount().amount(10).currency(MoneyAmount.CurrencyEnum.JPY));
    payment.merchantPaymentId("merchantPaymentId").userAuthorizationId("userAuthorizationId").requestedAt(Instant.now().getEpochSecond()).storeId(RandomStringUtils.randomAlphabetic(8)).terminalId(RandomStringUtils.randomAlphanumeric(8)).orderReceiptNumber(RandomStringUtils.randomAlphanumeric(8)).orderDescription("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.orderItems(merchantOrderItems);
}
Also used : Payment(jp.ne.paypay.model.Payment) MerchantOrderItem(jp.ne.paypay.model.MerchantOrderItem) ArrayList(java.util.ArrayList) MoneyAmount(jp.ne.paypay.model.MoneyAmount) ApiClient(jp.ne.paypay.ApiClient) ResultInfo(jp.ne.paypay.model.ResultInfo) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with Payment

use of jp.ne.paypay.model.Payment in project paypayopa-sdk-java by paypay.

the class PendingPaymentApiTest method setUp.

@BeforeEach
public void setUp() {
    apiClient = Mockito.mock(ApiClient.class);
    api.setApiClient(apiClient);
    paymentApi.setApiClient(apiClient);
    resultInfo = new ResultInfo();
    resultInfo.setMessage("SUCCESS");
    payment = new Payment();
    payment.setAmount(new MoneyAmount().amount(10).currency(MoneyAmount.CurrencyEnum.JPY));
    payment.merchantPaymentId("merchantPaymentId").userAuthorizationId("userAuthorizationId").requestedAt(Instant.now().getEpochSecond()).storeId(RandomStringUtils.randomAlphabetic(8)).terminalId(RandomStringUtils.randomAlphanumeric(8)).orderReceiptNumber(RandomStringUtils.randomAlphanumeric(8)).orderDescription("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.orderItems(merchantOrderItems);
}
Also used : Payment(jp.ne.paypay.model.Payment) MerchantOrderItem(jp.ne.paypay.model.MerchantOrderItem) ArrayList(java.util.ArrayList) MoneyAmount(jp.ne.paypay.model.MoneyAmount) ApiClient(jp.ne.paypay.ApiClient) ResultInfo(jp.ne.paypay.model.ResultInfo) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with Payment

use of jp.ne.paypay.model.Payment 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 4 with Payment

use of jp.ne.paypay.model.Payment in project paypayopa-sdk-java by paypay.

the class PaymentApiExample method directDebitFlow.

private static void directDebitFlow(WalletApi walletApiInstance, PaymentApi paymentApi, String userAuthorizationId, boolean continuousPayment) {
    String merchantPaymentId = UUID.randomUUID().toString();
    WalletBalance walletBalance = getWalletBalance(walletApiInstance, userAuthorizationId);
    if (walletBalance != null && walletBalance.getData().isHasEnoughBalance()) {
        System.out.println("There is enough balance, now creating payment...");
        PaymentDetails paymentDetails;
        Payment payment = getPaymentObject(merchantPaymentId, userAuthorizationId, 1);
        if (continuousPayment) {
            payment.setAmount(new MoneyAmount().amount(2).currency(MoneyAmount.CurrencyEnum.JPY));
            paymentDetails = createContinuousPayment(paymentApi, payment);
        } else {
            paymentDetails = createPayment(paymentApi, payment, false);
        }
        if (paymentDetails != null) {
            System.out.println("Payment created successfully, Now calling the API to get payment details for payment " + "ID:" + merchantPaymentId);
            String refundId = UUID.randomUUID().toString();
            paymentDetails = getPaymentDetails(paymentApi, merchantPaymentId);
            System.out.println("Creating Refund for the payment:" + paymentDetails.getData().getPaymentId());
            createRefund(paymentApi, paymentDetails.getData().getPaymentId(), refundId);
            System.out.println("Get refund details:" + refundId);
            getRefundDetails(paymentApi, refundId);
            System.out.println("Finally cancel the payment");
            cancelPayment(paymentApi, merchantPaymentId);
        }
    }
}
Also used : Payment(jp.ne.paypay.model.Payment) WalletBalance(jp.ne.paypay.model.WalletBalance) MoneyAmount(jp.ne.paypay.model.MoneyAmount) PaymentDetails(jp.ne.paypay.model.PaymentDetails)

Example 5 with Payment

use of jp.ne.paypay.model.Payment in project paypayopa-sdk-java by paypay.

the class PaymentApiExample method preAuthRevertAuthFlow.

private static void preAuthRevertAuthFlow(WalletApi walletApiInstance, PaymentApi paymentApi, String userAuthorizationId) {
    String merchantPaymentId = UUID.randomUUID().toString();
    System.out.println("Checking wallet balance...");
    WalletBalance walletBalance = getWalletBalance(walletApiInstance, userAuthorizationId);
    if (walletBalance != null && walletBalance.getData().isHasEnoughBalance()) {
        System.out.println("There is enough balance, now creating payment...");
        Payment payment = getPaymentObject(merchantPaymentId, userAuthorizationId, 1);
        PaymentDetails paymentDetails = createPayment(paymentApi, payment, true);
        if (paymentDetails != null) {
            System.out.println("Payment Authorized successfully, Now calling the API to get payment details for payment " + "ID:" + merchantPaymentId);
            paymentDetails = getPaymentDetails(paymentApi, merchantPaymentId);
            if (paymentDetails != null) {
                System.out.println("Reverting payment with Payment ID" + paymentDetails.getData().getPaymentId());
                paymentRevertAuth(paymentApi, paymentDetails.getData().getPaymentId());
                System.out.println("Check the payment details, the status should be CANCELED");
                getPaymentDetails(paymentApi, merchantPaymentId);
            }
        }
    }
}
Also used : Payment(jp.ne.paypay.model.Payment) WalletBalance(jp.ne.paypay.model.WalletBalance) PaymentDetails(jp.ne.paypay.model.PaymentDetails)

Aggregations

Payment (jp.ne.paypay.model.Payment)9 MoneyAmount (jp.ne.paypay.model.MoneyAmount)5 PaymentDetails (jp.ne.paypay.model.PaymentDetails)5 ArrayList (java.util.ArrayList)4 MerchantOrderItem (jp.ne.paypay.model.MerchantOrderItem)4 WalletBalance (jp.ne.paypay.model.WalletBalance)4 ApiClient (jp.ne.paypay.ApiClient)2 ResultInfo (jp.ne.paypay.model.ResultInfo)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 ApiResponse (jp.ne.paypay.ApiResponse)1 QRCodeDetails (jp.ne.paypay.model.QRCodeDetails)1 Test (org.junit.jupiter.api.Test)1