Skip to content

Latest commit

 

History

History
594 lines (458 loc) · 19.5 KB

PaymentApi.md

File metadata and controls

594 lines (458 loc) · 19.5 KB

PaymentApi

Method HTTP request Description
createAccountLinkQRCode POST /v1/qr/sessions Create an ACCOUNT LINK QR and display it to the user
cancelPayment DELETE /v2/payments/{merchantPaymentId} Cancel a payment
createPayment POST /v2/payments Create a payment
createPaymentAuthorization POST /v2/payments/preauthorize Create a payment authorization to block the money
createContinuousPayment POST /v1/subscription/payments Create a continuous payment and start the money transfer
revertAuth POST /v2/payments/preauthorize/revert Revert a payment authorization
capturePaymentAuth POST /v2/payments/capture Capture a payment authorization
createQRCode POST /v2/codes Create a Code
deleteQRCode DELETE /v2/codes/{codeId} Delete a Code
getPaymentDetails GET /v2/payments/{merchantPaymentId} Get payment details
getCodesPaymentDetails GET /v2/codes/payments/{merchantPaymentId} Get payment details for QR code
getRefundDetails GET /v2/refunds/{merchantRefundId} Get refund details
refundPayment POST /v2/refunds Refund a payment
revertAuth POST /v2/payments/preauthorize/revert Revert a payment authorization

cancelPayment

NotDataResponse cancelPayment(merchantPaymentId)

Cancel a payment

This API is used in case, while creating a payment, the client can not determine the status of the payment. For example, client get timeout or the response cannot contain the information to indicate the exact payment status.

By calling this API, if accepted, the OPA will guarantee the money eventually goes back to user's account.

Note: The Cancel API can be used until 00:14:59 AM the day after the Payment has happened. For 00:15 AM or later, please call the refund API to refund the payment.

Example

//Import classes:
import jp.ne.paypay.ApiException;
import jp.ne.paypay.api.PaymentApi;

PaymentApi apiInstance = new PaymentApi(apiClient);

String merchantPaymentId = "MERCHANT_PAYMENT_ID"; 

try {
    NotDataResponse result = apiInstance.cancelPayment(merchantPaymentId);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling PaymentApi#cancelPayment");
    e.printStackTrace();
    System.out.println(e.getResponseBody());
}
Please refer to the below document for more information :
https://www.paypay.ne.jp/opa/doc/v1.0/dynamicqrcode#operation/cancelPayment 

capturePaymentAuth

PaymentDetails capturePaymentAuth(body)

Capture a payment authorization

This API is used to capture the payment authorization for a payment Timeout: 30s

Example

//Import classes:
import jp.ne.paypay.ApiException;
import jp.ne.paypay.api.PaymentApi;

PaymentApi apiInstance = new PaymentApi(apiClient);

CaptureObject captureObject = new CaptureObject();
      captureObject.setMerchantCaptureId("MERCHANT_CAPTURE_ID");//UNIQUE ID
      captureObject.setMerchantPaymentId("MERCHANT_PAYMENT_ID");
      captureObject.setAmount(new MoneyAmount().amount(1).currency(MoneyAmount.CurrencyEnum.JPY));
      captureObject.setOrderDescription("ORDER_DESCRIPTION");
      captureObject.setRequestedAt(Instant.now().getEpochSecond());

try {
    PaymentDetails result = apiInstance.capturePaymentAuth(captureObject);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling PaymentApi#capturePaymentAuth");
    e.printStackTrace();
    System.out.println(e.getResponseBody());
}
Please refer to the below document for more information :
https://www.paypay.ne.jp/opa/doc/v1.0/dynamicqrcode#operation/capturePaymentAuth

createPayment

PaymentDetails createPayment(body, agreeSimilarTransaction)

Create a payment

Create a direct debit payment and start the money transfer. Timeout: 30s

Example

//Import classes:
import jp.ne.paypay.ApiException;
import jp.ne.paypay.api.PaymentApi;


PaymentApi apiInstance = new PaymentApi(apiClient);

Payment payment = new Payment();
      payment.setAmount(new MoneyAmount().amount(1).currency(MoneyAmount.CurrencyEnum.JPY));
      payment.setMerchantPaymentId("MERCHANT_PAYMENT_ID");
      payment.setUserAuthorizationId("USER_AUTHORIZATION_ID");
      payment.setRequestedAt(Instant.now().getEpochSecond());
      payment.setStoreId("STORE_ID");
      payment.setTerminalId("TERMINAL_ID");
      payment.setOrderReceiptNumber("ORDER_RECEIPT_NUMBER");
      payment.setOrderDescription("ORDER_DESCRIPTION");
      MerchantOrderItem merchantOrderItem =
              new MerchantOrderItem()
                      .category("pasteries").name("Moon Cake")
                      .productId("PRODUCT_ID").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));

boolean agreeSimilarTransaction = true; // Boolean | (Optional) If the parameter is set to true, the payment duplication check will be bypassed. 

try {
    PaymentDetails result = apiInstance.createPayment(body, agreeSimilarTransaction);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling PaymentApi#createPayment");
    e.printStackTrace();
    System.out.println(e.getResponseBody());
}
Please refer to the below document for more information :
https://www.paypay.ne.jp/opa/doc/v1.0/direct_debit#operation/createPayment

createPaymentAuthorization

PaymentDetails createPaymentAuthorization(body, agreeSimilarTransaction)

Create a payment authorization

Create a payment authorization to block the money. Timeout: 30s

Example

//Import classes:
import jp.ne.paypay.ApiException;
import jp.ne.paypay.api.PaymentApi;


PaymentApi apiInstance = new PaymentApi(apiClient);

Payment payment = new Payment();
      payment.setAmount(new MoneyAmount().amount(1).currency(MoneyAmount.CurrencyEnum.JPY));
      payment.setMerchantPaymentId("MERCHANT_PAYMENT_ID");
      payment.setUserAuthorizationId("USER_AUTHORIZATION_ID");
      payment.setRequestedAt(Instant.now().getEpochSecond());
      payment.setStoreId("STORE_ID");
      payment.setTerminalId("TERMINAL_ID");
      payment.setOrderReceiptNumber("ORDER_RECEIPT_NUMBER");
      payment.setOrderDescription("ORDER_DESCRIPTION");
      MerchantOrderItem merchantOrderItem =
              new MerchantOrderItem()
                      .category("pasteries").name("Moon Cake")
                      .productId("PRODUCT_ID").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));

boolean agreeSimilarTransaction = true; // Boolean | (Optional) If the parameter is set to true, the payment duplication check will be bypassed. 

try {
    PaymentDetails result = apiInstance.createPaymentAuthorization(body, agreeSimilarTransaction);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling PaymentApi#createPaymentAuthorization");
    e.printStackTrace();
    System.out.println(e.getResponseBody());
}
Please refer to the below document for more information :
https://www.paypay.ne.jp/opa/doc/v1.0/preauth_capture#operation/createAuth

createContinuousPayment

PaymentDetails createContinuousPayment(body)

Create a continuous payment Create a continuous payment and start the money transfer. Timeout: 30s

Example

//Import classes:
import jp.ne.paypay.ApiException;
import jp.ne.paypay.api.PaymentApi;


PaymentApi apiInstance = new PaymentApi(apiClient);

Payment payment = new Payment();
      payment.setAmount(new MoneyAmount().amount(1).currency(MoneyAmount.CurrencyEnum.JPY));
      payment.setMerchantPaymentId("MERCHANT_PAYMENT_ID");
      payment.setUserAuthorizationId("USER_AUTHORIZATION_ID");// User should be with scope continuous_payments
      payment.setRequestedAt(Instant.now().getEpochSecond());
      payment.setStoreId("STORE_ID");
      payment.setTerminalId("TERMINAL_ID");
      payment.setOrderReceiptNumber("ORDER_RECEIPT_NUMBER");
      payment.setOrderDescription("ORDER_DESCRIPTION");
      MerchantOrderItem merchantOrderItem =
              new MerchantOrderItem()
                      .category("pasteries").name("Moon Cake")
                      .productId("PRODUCT_ID").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));

try {
    PaymentDetails result = apiInstance.createContinuousPayment(body);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling PaymentApi#createContinuousPayment");
    System.out.println(e.getResponseBody());
}
Please refer to the below document for more information :
https://www.paypay.ne.jp/opa/doc/v1.0/continuous_payments#operation/createPayment

revertAuth

PaymentDetails revertAuth(body, agreeSimilarTransaction)

Revert a payment authorization

This api is used in case, the merchant wants to cancel the payment authorization because of cancellation of the order by the user. Timeout: 30s

Example

//Import classes:
import jp.ne.paypay.ApiException;
import jp.ne.paypay.api.PaymentApi;


PaymentApi apiInstance = new PaymentApi(apiClient);

PaymentStateRevert payment = new PaymentStateRevert();
      payment.setPaymentId("Payment_Transaction_ID");
      payment.setMerchantRevertId(UUID.randomUUID().toString());
      payment.setRequestedAt(Instant.now().getEpochSecond());

try {
    RevertAuthResponse result = apiInstance.revertAuth(payment);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling PaymentApi#revertAuth");
    e.printStackTrace();
    System.out.println(e.getResponseBody());
}
Please refer to the below document for more information :
https://www.paypay.ne.jp/opa/doc/v1.0/preauth_capture#operation/revertAuth

createQRCode

QRCodeDetails createQRCode(body)

Create a Code

Create a Code to receive payments. Timeout: 30s

Example

// Import classes:
import jp.ne.paypay.ApiException;
import jp.ne.paypay.api.PaymentApi;

PaymentApi apiInstance = new PaymentApi(apiClient);

QRCode qrCode = new QRCode();
      qrCode.setAmount(new MoneyAmount().amount(amount).currency(MoneyAmount.CurrencyEnum.JPY));
      qrCode.setMerchantPaymentId(MERCHANT_PAYMENT_ID);
      qrCode.setCodeType("ORDER_QR");
      qrCode.requestedAt(Instant.now().getEpochSecond());
      qrCode.redirectUrl("REDIRECT_URL");
      qrCode.redirectType(QRCode.RedirectTypeEnum.WEB_LINK);//For Deep Link, RedirectTypeEnum.APP_DEEP_LINK
      qrCode.setOrderDescription("ORDER_DESCRIPTION");
      MerchantOrderItem merchantOrderItem =
              new MerchantOrderItem()
                      .category("Psteries").name("Moon Cake")
                      .productId("PRODUCT_ID").quantity(1)
                      .unitPrice(new MoneyAmount().amount(10).currency(MoneyAmount.CurrencyEnum.JPY));
      List<MerchantOrderItem> merchantOrderItems = new ArrayList<>();
      merchantOrderItems.add(merchantOrderItem);
      qrCode.setOrderItems(merchantOrderItems);

try {
    QRCodeDetails result = apiInstance.createQRCode(qrCode);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling PaymentApi#createQRCode");
    e.printStackTrace();
    System.out.println(e.getResponseBody());
}
Please refer to the below document for more information :
https://www.paypay.ne.jp/opa/doc/v1.0/dynamicqrcode#operation/createQRCode

deleteQRCode

NotDataResponse deleteQRCode(codeId)

Delete a Code

Delete a created Code. Timeout: 15s

Example

// Import classes:
import jp.ne.paypay.ApiException;
import jp.ne.paypay.api.PaymentApi;



PaymentApi apiInstance = new PaymentApi(apiClient);

String codeId = "QR_CODE_ID"; 

try {
    NotDataResponse result = apiInstance.deleteQRCode(codeId);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling PaymentApi#deleteQRCode");
    e.printStackTrace();
    System.out.println(e.getResponseBody());
}
 Please refer to the below document for more information :
https://www.paypay.ne.jp/opa/doc/v1.0/dynamicqrcode#operation/deleteQRCode

getPaymentDetails

PaymentDetails getPaymentDetails(merchantPaymentId)

Get payment details

Get payment details. Timeout: 15s

Example

// Import classes:
import jp.ne.paypay.ApiException;
import jp.ne.paypay.api.PaymentApi;



PaymentApi apiInstance = new PaymentApi(apiClient);

String merchantPaymentId = "MERCHANT_PAYMENT_ID"; // String

try {
    PaymentDetails result = apiInstance.getPaymentDetails(merchantPaymentId);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling PaymentApi#getPaymentDetails");
    e.printStackTrace();
    System.out.println(e.getResponseBody());
}
 Please refer to the below document for more information :
https://www.paypay.ne.jp/opa/doc/v1.0/direct_debit#operation/getPaymentDetails

getCodesPaymentDetails

PaymentDetails getCodesPaymentDetails(merchantPaymentId)

Get payment details

Get payment details. Timeout: 15s

Example

// Import classes:
import jp.ne.paypay.ApiException;
import jp.ne.paypay.api.PaymentApi;



PaymentApi apiInstance = new PaymentApi(apiClient);

String merchantPaymentId = "MERCHANT_PAYMENT_ID"; // String

try {
    PaymentDetails result = apiInstance.getCodesPaymentDetails(merchantPaymentId);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling PaymentApi#getCodesPaymentDetails");
    e.printStackTrace();
    System.out.println(e.getResponseBody());
}
 Please refer to the below document for more information :
https://www.paypay.ne.jp/opa/doc/v1.0/dynamicqrcode#operation/getPaymentDetails

getRefundDetails

RefundDetails getRefundDetails(merchantRefundId)

Get refund details

Get refund details. Timeout: 15s

Example

// Import classes:
import jp.ne.paypay.ApiException;
import jp.ne.paypay.api.PaymentApi;



PaymentApi apiInstance = new PaymentApi(apiClient);

String merchantRefundId = "MERCHANT_REFUND_ID"; // String 

try {
    RefundDetails result = apiInstance.getRefundDetails(merchantRefundId);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling PaymentApi#getRefundDetails");
    e.printStackTrace();
    System.out.println(e.getResponseBody());
}
 Please refer to the below document for more information :
https://www.paypay.ne.jp/opa/doc/v1.0/dynamicqrcode#operation/getRefundDetails

refundPayment

RefundDetails refundPayment(body)

Refund a payment

Refund a payment. Timeout: 30s

Example

// Import classes:
import jp.ne.paypay.ApiException;
import jp.ne.paypay.api.PaymentApi;



PaymentApi apiInstance = new PaymentApi(apiClient);

Refund refund = new Refund();
      refund.setAmount(new MoneyAmount().amount(1).currency(MoneyAmount.CurrencyEnum.JPY));
      refund.setMerchantRefundId("MERCHANT_REFUND_ID");
      refund.setPaymentId("PAYMENT_ID");
      refund.setReason("REFUND REASON");
      refund.setRequestedAt(Instant.now().getEpochSecond())

try {
    RefundDetails result = apiInstance.refundPayment(refund);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling PaymentApi#refundPayment");
    e.printStackTrace();
    System.out.println(e.getResponseBody());
}
Please refer to the below document for more information :
https://www.paypay.ne.jp/opa/doc/v1.0/dynamicqrcode#operation/refundPayment

revertAuth

RevertAuthResponse revertAuth(body)

Revert a payment authorization

This API is used in case, the merchant wants to cancel the payment authorization because of cancellation of the order by the user. Timeout: 30s

Example

// Import classes:
import jp.ne.paypay.ApiException;
import jp.ne.paypay.api.PaymentApi;



PaymentApi apiInstance = new PaymentApi(apiClient);

PaymentStateRevert body = new PaymentStateRevert();
      payment.setPaymentId("PAYMENT_ID");
      payment.merchantRevertId("MERCHANT_REVERT_AUTH_ID");
      payment.setRequestedAt(Instant.now().getEpochSecond()); | Revert Authorized Order Request

try {
    RevertAuthResponse result = apiInstance.revertAuth(body);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling PaymentApi#revertAuth");
    e.printStackTrace();
    System.out.println(e.getResponseBody());
}
Please refer to the below document for more information :
https://www.paypay.ne.jp/opa/doc/v1.0/dynamicqrcode#operation/revertAuth

createAccountLinkQRCode

LinkQRCodeResponse createAccountLinkQRCode(body)

Create an ACCOUNT LINK QR and display it to the user.

Example

// Import classes:
import jp.ne.paypay.ApiException;
import jp.ne.paypay.api.PaymentApi;



PaymentApi apiInstance = new PaymentApi(apiClient);

AccountLinkQRCode accountLinkQRCode = new AccountLinkQRCode();
      List<AuthorizationScope> scopes = new ArrayList<>();
      scopes.add(AuthorizationScope.DIRECT_DEBIT);
      accountLinkQRCode.setScopes(scopes);
      accountLinkQRCode.setNonce(RandomStringUtils.randomAlphanumeric(8).toLowerCase());
      accountLinkQRCode.setDeviceId("device_id");
      accountLinkQRCode.setRedirectUrl("merchant.domain/test");
      accountLinkQRCode.setPhoneNumber("phone_number");
      accountLinkQRCode.setReferenceId("reference_id");
      accountLinkQRCode.setRedirectType(QRCode.RedirectTypeEnum.WEB_LINK);

try {
    LinkQRCodeResponse result = apiInstance.createAccountLinkQRCode(accountLinkQRCode);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling PaymentApi#createAccountLinkQRCode");
    e.printStackTrace();
    System.out.println(e.getResponseBody());
}
Please refer to the below document for more information :
https://www.paypay.ne.jp/opa/doc/v1.0/account_link#operation/createQRSession