Search in sources :

Example 1 with PendingPaymentApi

use of jp.ne.paypay.api.PendingPaymentApi in project paypayopa-sdk-java by paypay.

the class PendingPaymentApiExample method main.

public static void main(String[] args) throws ApiException {
    ApiClient apiClient = new Configuration().getDefaultApiClient();
    apiClient.setProductionMode(false);
    apiClient.setApiKey("API_KEY");
    apiClient.setApiSecretKey("API_SECRET_KEY");
    apiClient.setAssumeMerchant("ASSUME_MERCHANT_ID");
    String userAuthorizationId = "USER_AUTHORIZATION_ID";
    PendingPaymentApi pendingPaymentApi = new PendingPaymentApi(apiClient);
    PaymentApi paymentApi = new PaymentApi(apiClient);
    PaymentDetails paymentDetails = pendingPayment(pendingPaymentApi, userAuthorizationId, 2);
    if (paymentDetails != null && paymentDetails.getData() != null) {
        String merchantPaymentId = paymentDetails.getData().getMerchantPaymentId();
        getPendingPaymentDetails(pendingPaymentApi, merchantPaymentId);
        // Cancel Pending Order
        cancelPendingPayment(pendingPaymentApi, merchantPaymentId);
        // Refund payment. Run this after payment is complete
        refundPendingPayment(paymentApi, pendingPaymentApi, paymentDetails.getData().getPaymentId());
    }
}
Also used : PendingPaymentApi(jp.ne.paypay.api.PendingPaymentApi) PaymentApi(jp.ne.paypay.api.PaymentApi) Configuration(jp.ne.paypay.Configuration) PaymentDetails(jp.ne.paypay.model.PaymentDetails) ApiClient(jp.ne.paypay.ApiClient) PendingPaymentApi(jp.ne.paypay.api.PendingPaymentApi)

Aggregations

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 PaymentDetails (jp.ne.paypay.model.PaymentDetails)1