Search in sources :

Example 16 with PaymentDetails

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

the class PaymentApiExample method getPaymentDetails.

private static PaymentDetails getPaymentDetails(final PaymentApi apiInstance, final String merchantPaymentId) {
    PaymentDetails result = null;
    try {
        result = apiInstance.getPaymentDetails(merchantPaymentId);
        System.out.println("\nAPI RESPONSE\n------------------\n");
        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 17 with PaymentDetails

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

use of jp.ne.paypay.model.PaymentDetails 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)

Example 19 with PaymentDetails

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

the class PaymentApiExample method createPayment.

private static PaymentDetails createPayment(final PaymentApi apiInstance, Payment payment, boolean authorization) {
    PaymentDetails result = null;
    try {
        if (authorization) {
            result = apiInstance.createPaymentAuthorization(payment, "false");
        } else {
            result = apiInstance.createPayment(payment, "false");
        }
        System.out.println("\nAPI RESPONSE\n------------------\n");
        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 20 with PaymentDetails

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

the class PaymentApiExample method preAuthCaptureFlow.

private static void preAuthCaptureFlow(WalletApi walletApiInstance, PaymentApi paymentApi, String userAuthorizationId) {
    String merchantPaymentId = UUID.randomUUID().toString();
    System.out.println("Checking wallet balance...");
    int amount = 1;
    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, amount);
        PaymentDetails paymentDetails = createPayment(paymentApi, payment, true);
        if (paymentDetails != null) {
            System.out.println("Now capture the payment authorization for a payment, Don't capture if you need to check cancel payment");
            capturePayment(paymentApi, merchantPaymentId, amount);
            System.out.println("Payment created successfully, Now calling the API to get payment details for payment " + "ID:" + merchantPaymentId);
            paymentDetails = getPaymentDetails(paymentApi, merchantPaymentId);
            if (paymentDetails != null) {
                if (paymentDetails.getData().getStatus() == PaymentState.StatusEnum.COMPLETED) {
                    String refundId = UUID.randomUUID().toString();
                    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);
                } else {
                    System.out.println("Finally cancel the payment");
                    cancelPayment(paymentApi, merchantPaymentId);
                }
            }
        }
    }
}
Also used : Payment(jp.ne.paypay.model.Payment) WalletBalance(jp.ne.paypay.model.WalletBalance) PaymentDetails(jp.ne.paypay.model.PaymentDetails)

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