Package: paypayopa
Paypay OPA SDK - PythonSo you are a developer and want to start accepting payments using PayPay. PayPay's Payment SDK is the simplest way to achieve the integration. With PayPay's Payment SDK, you can build a custom Payment checkout process to suit your unique business needs and branding guidelines.When to use QR Code PaymentsQR Code flow is recommended normally in the following scenariosPayment to happen on a TabletPayments on Vending MachinesPayment to happen on a TV ScreenPrinting a QR Code for Bill PaymentUnderstanding the Payment FlowFollowing diagram defines the flow for Dynamic QR Code.We recommend that the merchant implements a Polling of the Get payment Details API with a 4-5 second interval in order to know the status of the transaction.Let's get StartedOnce you have understood the payment flow, before we start the integration make sure you have:Registeredfor a PayPay developer/merchant AccountGet the API key and secret from the Developer Panel.Use the sandbox API Keys to test out the integrationInstall pip package$pipinstallpaypayopaGetting StartedYou need to setup your key and secret using the following:To work in production mode you need to specify your production API_KEY & API_SECRET along with a production_mode True boolean flagimportpaypayopaclient=paypayopa.Client(auth=(API_KEY,API_SECRET),production_mode=True)client.set_assume_merchant("MERCHANT_ID")orTo work in sandbox mode you need to specify your sandbox API_KEY & API_SECRET keys along with a False boolean flag or you could just omit the production_mode flag since it defaults to False if not specifiedimportpaypayopaclient=paypayopa.Client(auth=(API_KEY,API_SECRET),production_mode=False)After setting up the client instance you can get the current PayPay SDK version using the following:print(client.get_version())Create a QR CodeIn order to receive payments using this flow, first of all you will need to create a QR Code. Following are the important parameters that you can provide for this method:FieldRequiredTypeDescriptionmerchantPaymentIdYesstring <= 64 charactersThe unique payment transaction id provided by merchantamountYesinteger <= 11 charactersAmount the user has to PaycodeTypeYesstring <= 64 charactersPlease pass the fixed value "ORDER_QR"orderDescriptionNostring <= 255 charactersDescription of the Order,Click hereto check how it will show upisAuthorizationNobooleanBy default it will be false, please set true if the amount will be captured later (preauth and capture payment)For details of all the request and response parameters , check ourAPI Documentation guiderequest={"merchantPaymentId":"cb31bcc0-3b6c-46e0-9002-e5c4bb1e3d5f","codeType":"ORDER_QR","redirectUrl":"http://foobar.com","redirectType":"WEB_LINK","orderDescription":"Example - Mune Cake shop","orderItems":[{"name":"Moon cake","category":"pasteries","quantity":1,"productId":"67678","unitPrice":{"amount":1,"currency":"JPY",},}],"amount":{"amount":1,"currency":"JPY",},}client.Code.create_qr_code(request)Did you get aHTTP 201response, if yes then you are all set for the next step.Get Payment DetailsNow that you have created a Code, the next  step is to implement polling to get Payment Details. We recommend a 4-5 second interval between requests. Following are the important parameters that you can provide for this method:FieldRequiredTypeDescriptionmerchantPaymentIdYesstring <= 64 charactersThe unique payment transaction id provided by merchantFetch a particular QR CODE payment detailsclient.Payment.get_payment_details("<merchantPaymentId>")For details of all the request and response parameters , check ourAPI Documentation guideOn successful payment, the status in the response will change toCOMPLETEDIn case of a Preauth for Payment, the status in the response will change toAUTHORIZEDDelete a QRCodeSo you want to delete a Code that you have already generated. Following can be possible reasons to use this API:User has cancelled the orderEnsuring race conditions don't come up in the form user has scanned the QR Code and not made the payment and in the meantime the order expires at your endFollowing are the important parameters that you can provide for this method:FieldRequiredTypeDescriptioncodeIdYesstringThis is given as a response in the Create a QR Code methodclient.Code.delete_qr_code("<CodeID>")For details of all the request and response parameters , check ourAPI Documentation guideCancel a paymentSo you want to cancel a Payment. In most cases this should not be needed for payment happening in this flow, however following can be a case when this might be needed.Polling for Get Payment Details timeout, and you are uncertain of the statusNote: 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.Following are the important parameters that you can provide for this method:FieldRequiredTypeDescriptionmerchantPaymentIdYesstring <= 64 charactersThe unique payment transaction id provided by merchantclient.Payment.cancel_payment("<merchantPaymentId>")Refund a paymentSo the user has decided to return the goods they have purchased and needs to be given a refund. Following are the important parameters that you can provide for this method:FieldRequiredTypeDescriptionmerchantRefundIdYesstring <= 64 charactersThe unique refund transaction id provided by merchantpaymentIdYesstring <= 64 charactersThe payment transaction id provided by PayPayamountYesinteger <= 11 charactersThe amount to be refundedreasonNointeger <= 11 charactersThe reason for refundrefund_payment_details={"assumeMerchant":"cb31bcc0-3b6c-46e0-9002-e5c4bb1e3d5f","merchantRefundId":"3b6c-46e0-9002-e5c4bb1e3d5f","paymentId":"456787656","amount":{"amount":1,"currency":"JPY"},"reason":"reason for refund"}client.Payment.refund_payment(refund_payment_details)For details of all the request and response parameters , check ourAPI Documentation guide.Please note that currently we only support 1 refund per order.Capture a payment authorizationSo you are implementing a PreAuth and Capture, and hence want to capture the payment later. In this case, please ensure you have passedisAuthorizationastruein create a code method. Following are the important parameters that you can provide for this method:FieldRequiredTypeDescriptionmerchantPaymentIdYesstring <= 64 charactersThe unique payment transaction id provided by merchantmerchantCaptureIdYesstring <= 64 charactersThe unique capture transaction id provided by merchantamountYesinteger <= 11 charactersAmount to be capturedorderDescriptionYesstring <= 255 charactersDescription of the Capture for the userrequest_payload={"merchantPaymentId":"merchant_payment_id","amount":{"amount":1,"currency":"JPY"},"merchantCaptureId":"31bcc0-3b6c-46e0-9002","orderDescription":"Example - Mune Cake shop",}client.Payment.capture_payment(request_payload)For details of all the request and response parameters , check ourAPI Documentation guide.Revert a payment authorizationSo the order has cancelled the order while the payment was still Authorized, please use the revert a payment authorization method to refund back to the user. Following are the important parameters that you can provide for this method:FieldRequiredTypeDescriptionmerchantRevertIdYesstring <= 64 charactersThe unique revert transaction id provided by merchantpaymentIdYesstring <= 64 charactersThe payment transaction id provided by PayPayreasonNostring <= 255 charactersReason for reverting the payment authorizationrequest_payload={"merchantRevertId":"cb31bcc0-3b6c-46e0-9002-e5c4bb1e3d5f","paymentId":"1585537300","reason":"reason for refund",}client.Payment.revert_payment(request_payload)For List of params refer to the API guide :https://www.paypay.ne.jp/opa/doc/v1.0/dynamicqrcode#operation/revertAuthFetch refund status and detailsSo you want to confirm the status of the refund, maybe because the request for the refund timed out when you were processing the same. Following are the important parameters that you can provide for this method:FieldRequiredTypeDescriptionmerchantRefundIdYesstring <= 64 charactersThe unique refund transaction id provided by merchantclient.Payment.refund_status("<merchantRefundId>")For details of all the request and response parameters , check ourAPI Documentation guide.When to use Native PaymentsNative Payments is recommended normally in the following scenariosIf you want provide your customers with the easiest possible checkoutYou have the security in place to ensure our mutual customers money is safe (We have a strict evaluation procedure to enforce the same)Integrating Native IntegrationAcquire User AuthorizationFirst of all you need to acquire a user Authorization. Following diagram defines the flow to acquire a user authorization.In order to acquire an authorization you need to create a JWT Token -cliamrequiredtypedescriptionissyesstringthe merchant nameexpyesnumberThe expiration date of the authorization page URL. Set with epoch time stamp (seconds).scopeyesstringdirect_debitnonceyesstringwill be sent back with response for the client side validationredirectUrlyesstringThe callback endpoint provided by client. Must be HTTPS, and its domain should be in the allowed authorization callback domainsreferenceIdyesstringThe id used to identify the user in merchant system. It will be stored in the PayPay db for reconciliation purposedeviceIdnostringThe user mobile phone device id. If it is provided, we can use it to verify the user and skip the SMS verification, so as to provide more fluent UXphoneNumbernostringThe user mobile phone number# Helper function to create a JWT Token for requesting user Authorizationclient.encode_jwt(API_SECRET,redirectUrl="https://example.com",deviceId="qwertyuiopoiuytre54567",phoneNumber=90999999999)Once the user has granted authorization, we will return the UserAuthorizationID as a part of the JWT Token in response/ webhook# Retrieving userAuthorizationId from response JWTclient.decode_jwt(API_SECRET,token)Unlink a user from the clientFieldRequiredTypeDescriptionuserAuthorizationIdyesstring <= 64 charactersThe PayPay user reference id returned by the user authorization flow# Calling the method to unlink a Paymentresponse=client.User.unlink_user_athorization('userAuthorizationId')# Printing if the method call was SUCCESSprint(response["resultInfo"]["code"])Did you getSUCCESSin the print statement above, if yes then the API execution has happened correctly.For details of all the request and response parameters , check ourAPI Documentation guide.Create a paymentIn order to take a payment, you will need to send a request to us with the following parameters:FieldRequiredTypeDescriptionmerchantPaymentIdYesstring <= 64 charactersThe unique payment transaction id provided by merchantuserAuthorizationIdYesstring <= 64 charactersThe PayPay user reference id returned by the user authorization flowamountYesinteger <= 11 charactersAmount the user has to PayorderDescriptionNostring <= 255 charactersDescription of the Order,Click hereto check how it will show up# Creating the payload to create a Payment, additional parameters can be added basis the API Documentationrequest={"merchantPaymentId":"my_payment_id","userAuthorizationId":"my_user_authorization_id","amount":{"amount":1,"currency":"JPY"},"orderDescription":"Mune's Favourite Cake",}# Calling the method to create a paymentresponse=client.Payment.create(request)# Printing if the method call was SUCCESS, this does not mean the payment was a successprint(response["resultInfo"]["code"])Did you getSUCCESSin the print statement above, if yes then the API execution has happened correctly.For details of all the request and response parameters , check ourAPI Documentation guideGet Payment DetailsNow that you have created a payment, in case the payment request timeout, you can call get payment details method to know the payment status. Following are the important parameters that you can provide for this method:FieldRequiredTypeDescriptionmerchantPaymentIdYesstring <= 64 charactersThe unique payment transaction id provided by merchant# Calling the method to get payment detailsresponse=client.Payment.get_payment_details("<merchantPaymentId>")# Printing if the method call was SUCCESS, this does not mean the payment was a successprint(response["resultInfo"]["code"])# Printing if the transaction status for the code has COMPLETED/ AUTHORIZEDprint(response["data"]["status"])Did you getSUCCESSin the print statement above, if yes then the API execution has happen correctly.On successful payment, the status in response["data"]["status"] will beCOMPLETEDFor details of all the request and response parameters , check ourAPI Documentation guideCancel a paymentSo you want to cancel a Payment. In most cases this should not be needed for payment happening in this flow, however following can be a case when this might be needed.Initial create payment timeout and you want to cancel the PaymentGet Payment Details timeout, and you are uncertain of the statusNote: 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.Following are the important parameters that you can provide for this method:FieldRequiredTypeDescriptionmerchantPaymentIdYesstring <= 64 charactersThe unique payment transaction id provided by merchant# Calling the method to cancel a Paymentresponse=client.Payment.cancel_payment("<merchantPaymentId>")# Printing if the method call was SUCCESSprint(response["resultInfo"]["code"])Did you getSUCCESSin the print statement above, if yes then the API execution has happend correctly.For details of all the request and response parameters , check ourAPI Documentation guideRefund a paymentSo the user has decided to return the goods they have purchased and needs to be giveb a refund. Following are the important parameters that you can provide for this method:FieldRequiredTypeDescriptionmerchantRefundIdYesstring <= 64 charactersThe unique refund transaction id provided by merchantpaymentIdYesstring <= 64 charactersThe payment transaction id provided by PayPayamountYesinteger <= 11 charactersThe amount to be refundedreasonNointeger <= 11 charactersThe reason for refund# Creating the payload to refund a Payment, additional parameters can be added based on the API Documentationrequest={"merchantRefundId":"merchant_refund_id","paymentId":"paypay_payment_id","amount":1,"reason":"reason for refund",}# Calling the method to refund a Paymentresponse=client.Payment.refund_payment(request)# Printing if the method call was SUCCESSprint(response["resultInfo"]["code"])Did you getSUCCESSin the print statement above, if yes then the API execution has happened correctly.For details of all the request and response parameters , check ourAPI Documentation guide.Please note that currently we only support 1 refund per order.Fetch refund status and detailsSo you want to confirm the status of the refund, maybe because the request for the refund timed out when you were processing the same. Following are the important parameters that you can provide for this method:FieldRequiredTypeDescriptionmerchantRefundIdYesstring <= 64 charactersThe unique refund transaction id provided by merchant# Calling the method to get Refund Detailsresponse=client.Payment.refund_details("<merchantRefundId>")# Printing if the method call was SUCCESSprint(response["resultInfo"]["code"])Did you getSUCCESSin the print statement above, if yes then the API execution has happen correctly.For details of all the request and response parameters , check ourAPI Documentation guide.Acquire User AuthorizationSo you want to confirm the status of the refund, maybe because the request for the refund timed out when you were processing the same. Following are the important parameters that you can provide for this method:ClaimRequiredTypeDescriptionscopesYesArray of stringItems Enum: 'direct_debit' 'cashback' 'get_balance' 'quick_pay' 'continuous_payments' 'merchant_topup' 'pending_payments' 'user_notification' 'user_topup' 'user_profile' 'preauth_capture_native' 'preauth_capture_transaction' 'push_notification' 'notification_center_ob' 'notification_center_ab' 'notification_center_tl' Scopes of the user authorizationnonceYesstringRandom generated stringredirectTypeNostringDefault: 'WEB_LINK' Enum: 'APP_DEEP_LINK' 'WEB_LINK' Parameter to decide whether to redirect to merchant app or merchant web applicationredirectUrlYesstringThe callback endpoint provided by client. For 'WEB_LINK' it must be HTTPS, and its domain should be in the allowed authorization callback domainsreferenceIdYesstringThe id used to identify the user in merchant system. It will be stored in the PayPay db for reconsilliation purposephoneNumberNostringThe user mobile phone numberdeviceIdNostringThe user mobile phone device id. If it is provided, we can use it to verify the user and skip the SMS verification, so as to provide more fluent UXuserAgentNostringThe User agent of the web browser. When redirectType is 'WEB_LINK' this parameter is provided, on mobile devices PayPay tries to open the browser that the merchant website is using.payload={"scopes":["direct_debit"],"nonce":"rtyuhghj7989","redirectType":"WEB_LINK","redirectUrl":"www.example.com","referenceId":"uioiugf789","phoneNumber":"90999999999","deviceId":"qwertyuiopoiuytre54567","userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36"}client.Account.create_qr_session(payload)Once the user has granted authorization, we will return the UserAuthorizationID as a part of the JWT Token in response/ webhook# Retrieving userAuthorizationId from response JWTclient.decode_jwt(API_SECRET,token)Did you getSUCCESSin the print statement above, if yes then the API execution has happen correctly.For details of all the request and response parameters , check ourAPI Documentation guide.Create a Payment AuthorizationIn order to create a payment authorization, you will need to send a request to us with the following parameters:ClaimRequiredTypeDescriptionmerchantPaymentIdYesstring <= 64 charactersThe unique payment transaction id provided by merchantuserAuthorizationIdYesstring <= 64 charactersThe PayPay user reference id returned by the user authorization flowamountYesinteger <= 11 charactersAmount the user has to PayrequestedAtYesintegerEpoch timestamp in secondsorderDescriptionYesstring <= 255 charactersDescription of the Capture for the user# Creating the payload for a payment authorization request, additional parameters can be added basis the API Documentationrequest_payload={"merchantPaymentId":"merchant_payment_id","userAuthorizationId":"user_authorization_id","amount":{"amount":26.00,"currency":"JPY"},"requestedAt":5353454354,"orderReceiptNumber":"435435435","orderDescription":"Mune's Favourite Cake",}# Calling the method to create a payment authorizationclient.Preauth.pre_authorize_create(request_payload)Creating a Continuous Payment authorizationIn order to acquire an authorization you need to create a JWT Token -ClaimRequiredTypeDescriptionscopesYesArray of stringItems Enum: 'direct_debit' 'cashback' 'get_balance' 'quick_pay' 'continuous_payments' 'merchant_topup' 'pending_payments' 'user_notification' 'user_topup' 'user_profile' 'preauth_capture_native' 'preauth_capture_transaction' 'push_notification' 'notification_center_ob' 'notification_center_ab' 'notification_center_tl' Scopes of the user authorizationnonceYesstringRandom generated stringredirectTypeNostringDefault: 'WEB_LINK' Enum: 'APP_DEEP_LINK' 'WEB_LINK' Parameter to decide whether to redirect to merchant app or merchant web applicationredirectUrlYesstringThe callback endpoint provided by client. For 'WEB_LINK' it must be HTTPS, and its domain should be in the allowed authorization callback domainsreferenceIdYesstringThe id used to identify the user in merchant system. It will be stored in the PayPay db for reconsilliation purposephoneNumberNostringThe user mobile phone numberdeviceIdNostringThe user mobile phone device id. If it is provided, we can use it to verify the user and skip the SMS verification, so as to provide more fluent UXuserAgentNostringThe User agent of the web browser. When redirectType is 'WEB_LINK' this parameter is provided, on mobile devices PayPay tries to open the browser that the merchant website is using.# Creating the payload for a payment authorization request, additional parameters can be added basis the API Documentationrequest_payload={"merchantPaymentId":"merchant_payment_id","userAuthorizationId":"my_user_authorization_id","orderDescription":"Mune's Favourite Cake","amount":{"amount":1,"currency":"JPY"}}# Calling the method to create a continuous payment authorizationclient.Payment.create_continuous_payment(request_payload)# Printing if the method call was SUCCESS, this does not mean the payment was a successprint(response["resultInfo"]["code"])Creating a Pending Payment authorizationIn order to acquire an authorization you need to create a JWT Token -ClaimRequiredTypeDescriptionmerchantPaymentIdYesstring <= 64 charactersThe unique payment transaction id provided by merchantuserAuthorizationIdYesstring <= 64 charactersThe PayPay user reference id returned by the user authorization flowamountYesinteger <= 11 charactersAmount the user has to PayrequestedAtYesintegerEpoch timestamp in secondsorderDescriptionYesstring <= 255 charactersDescription of the Capture for the user# Creating the payload for a payment authorization request, additional parameters can be added basis the API Documentationrequest_payload={"merchantPaymentId":"merchant_payment_id","userAuthorizationId":"my_user_authorization_id","amount":{"amount":1,"currency":"JPY"},"requestedAt":1632123456,"expiryDate":None,"storeId":"001","terminalId":"0042","orderReceiptNumber":"0878","orderDescription":"Example - Mune Cake shop","orderItems":[{"name":"Moon cake","category":"pasteries","quantity":1,"productId":"67678","unitPrice":{"amount":1,"currency":"JPY"}}],"metadata":{}}# Calling the method to create a continuous payment authorizationclient.Pending.create_pending_payment(request_payload)# Printing if the method call was SUCCESS, this does not mean the payment was a successprint(response["resultInfo"]["code"])Did you getSUCCESSin the print statement above, if yes then the API execution has happen correctly.On successful payment, the status in response["data"]["status"] will beCOMPLETEDFor details of all the request and response parameters , check ourAPI Documentation guideGet Pending Payment DetailsNow that you have created a pending payment, in case the payment request timeout, you can call get payment details method to know the payment status. Following are the important parameters that you can provide for this method:FieldRequiredTypeDescriptionmerchantPaymentIdYesstring <= 64 charactersThe unique payment transaction id provided by merchant# Calling the method to get payment detailsresponse=client.Pending.get_payment_details("<merchantPaymentId>")# Printing if the method call was SUCCESS, this does not mean the payment was a successprint(response["resultInfo"]["code"])# Printing if the transaction status for the code has COMPLETED/ AUTHORIZEDprint(response["data"]["status"])Did you getSUCCESSin the print statement above, if yes then the API execution has happen correctly.On successful payment, the status in response["data"]["status"] will beCOMPLETEDFor details of all the request and response parameters , check ourAPI Documentation guideCancel Pending Payment DetailsFieldRequiredTypeDescriptionmerchantPaymentIdYesstring <= 64 charactersThe unique payment transaction id provided by merchant# Calling the method to cancel pending paymentresponse=client.Pending.cancel_payment("<merchantPaymentId>")# Printing if the method call was SUCCESS, this does not mean the payment was a successprint(response["resultInfo"]["code"])# Printing if the transaction status for the code has COMPLETED/ AUTHORIZEDprint(response["data"]["status"])Did you getSUCCESSin the print statement above, if yes then the API execution has happen correctly.On successful payment, the status in response["data"]["status"] will beCOMPLETEDFor details of all the request and response parameters , check ourAPI Documentation guideRefund a Pending PaymentSo the user has decided to return the goods they have purchased and needs to be given a refund. Following are the important parameters that you can provide for this method:FieldRequiredTypeDescriptionmerchantRefundIdYesstring <= 64 charactersThe unique refund transaction id provided by merchantpaymentIdYesstring <= 64 charactersThe payment transaction id provided by PayPayamountYesinteger <= 11 charactersThe amount to be refundedreasonNointeger <= 11 charactersThe reason for refundpayload={"assumeMerchant":"cb31bcc0-3b6c-46e0-9002-e5c4bb1e3d5f","merchantRefundId":"3b6c-46e0-9002-e5c4bb1e3d5f","paymentId":"456787656","amount":{"amount":1,"currency":"JPY"},"reason":"reason for refund"}client.Pending.refund_payment(refund_payment_details)On successful payment, the status in response["data"]["status"] will beCOMPLETEDFor details of all the request and response parameters , check ourAPI Documentation guideCashbackPaypay Cashback API can give users some balance.
If you use Cashback API, you should authorize paypay user to usecreate_qr_sessionsdk.Give CashbackFieldRequiredTypeDescriptionmerchantCashbackIdYesstring <= 64 charactersThe unique cashback transaction id provided by merchantuserAuthorizationIdYesstring <= 64 charactersThe paypay user reference id provided by PayPayamountYesinteger <= 11 charactersThe amount to cashbackcurrencyYesstring"JPY"requestedAtYesintegerEpoch timestamp in secondsorderDescriptionNostring <= 255 charactersDescription of the orderwalletTypeNostringWallet typeexpiryDateNodateThe date on which the Cashback ExpiresmetadataNostringExtra information the merchant want to addpayload={"merchantCashbackId":"ab31bcc0-3b6c-46e0-9002-e5c4bb1e3d5f","userAuthorizationId":"3b6c-a7c9-9002-e5c4bb1e3d5f","amount":{"amount":100,"currency":"JPY"},"requestedAt":1609749559,"orderDescription":"order description","walletType":"PREPAID","expiryDate":None,"metadata":""}client.Cashback.give_cashback(payload)Check Cashback DetailsFieldRequiredTypeDescriptionmerchantCashbackIdYesstring <= 64 charactersThe unique cashback transaction id provided by merchantmerchant_cashback_id="ab31bcc0-3b6c-46e0-9002-e5c4bb1e3d5f"client.Cashback.check_give_cashback(merchant_cashback_id)Reverse CashbackFieldRequiredTypeDescriptionmerchantCashbackReversalIdYesstring <= 64 charactersThe unique reversal cashback transaction id provided by merchantmerchantCashbackIdYesstring <= 64 charactersThe unique cashback transaction id provided by merchantamountYesinteger <= 11 charactersThe amount to cashbackcurrencyYesstring"JPY"reasonNostring <= 255 charactersReason for reversing the cashbackmetadataNostringExtra information the merchant want to addpayload={"merchantCashbackReversalId":"e031bcc0-3b6c-9a7d-9002-e5c4cc1e3d5f","merchantCashbackId":"ab31bcc0-3b6c-46e0-9002-e5c4bb1e3d5f","amount":{"amount":100,"currency":"JPY"},"requestedAt":1609749559,"reason":"reversal reason","metadata":{}}client.Cashback.reverse_cashback(payload)Check Cashback Reversal DetailsFieldRequiredTypeDescriptionmerchantCashbackReversalIdYesstring <= 64 charactersThe unique reversal cashback transaction id provided by merchantmerchantCashbackIdYesstring <= 64 charactersThe unique cashback transaction id provided by merchantmerchant_cashback_reversal_id="e031bcc0-3b6c-9a7d-9002-e5c4cc1e3d5f"merchant_cashback_id="ab31bcc0-3b6c-46e0-9002-e5c4bb1e3d5f"client.Cashback.check_reversal_cashback(merchant_cashback_reversal_id,merchant_cashback_id)Get refund details of a Pending paymentSo the user has decided to return the goods they have purchased and needs to be given a refund. Following are the important parameters that you can provide for this method:FieldRequiredTypeDescriptionmerchantPaymentIdYesstring <= 64 charactersThe unique payment transaction id provided by merchant# Calling the method to cancel pending paymentresponse=client.Pending.refund_details("<merchantPaymentId>")# Printing if the method call was SUCCESS, this does not mean the payment was a successprint(response["resultInfo"]["code"])# Printing if the transaction status for the code has COMPLETED/ AUTHORIZEDprint(response["data"]["status"])Did you getSUCCESSin the print statement above, if yes then the API execution has happen correctly.On successful payment, the status in response["data"]["status"] will beCOMPLETEDFor details of all the request and response parameters , check ourAPI Documentation guideError HandlingPayPay uses HTTP response status codes and error code to indicate the success or failure of the requests. With this information, you can decide what error handling strategy to use. In general, PayPay returns the following http status codes.HTTP 2xx200Everything works as expected.201The requested resource(e.g. dynamic QR code) was created.202Means the request is received, and will be processed sometime later.HTTP 4xx400This status code indicates an error because the information provided in request is not able to be processed. The following OPA error code may be returned.INVALID_PARAMS
The information provided by the request contains invalid data. E.g. unsupported currency.UNACCEPTABLE_OP
The requested operation is not able to be processed due to the current condition. E.g. the transaction limit exceeded.NO_SUFFICIENT_FUND
There is no sufficient fund for the transaction.401This status code indicates an authorization error. The following OPA error code may be returned.UNAUTHORIZED
No valid api key and secret provided.OP_OUT_OF_SCOPE
The operation is not permitted.404This status code indicates that the requested resource is not existing in the system.429This status code indicates that the client sent too many requests in a specific period of time, and hit the rate limits. You should slow down the request sending or contact us to rise your limit.HTTP 5xx500This status code indicates that something went wrong on the PayPay side. A few OPA error code could be returned.TRANSACTION_FAILED
This code means the transaction is failed on the PayPay side. You can create new transactions for the same purpose with reasonable backoff time.INTERNAL_SERVER_ERROR
This code means that something goes wrong, but we don't know exactly if the transaction has happened or not. It should be treated as unknown payment status.502,503,504Treated as unknown payment status.TimeoutThe recommended timeout setting is specified in each API. The most important one is for the payment creation api, where the read timeout should not be less than 30 seconds. When timeout happens, it should be treated as unknown payment status.Handle unknown payment statusThere are two ways to react with this situation:Use the query api to query the transaction status. If the original transaction was failed or not found in PayPay, you can start a new transaction for the same purpose.Or, you can cancel the transaction, if the cancel api is provided. After the cancellation is accepted, you can start a new transaction for the same purpose.Response code listCommon response codeStatusCodeIdCodeMessage20008100001SUCCESSSuccess20208100001REQUEST_ACCEPTEDRequest accepted40008100006INVALID_REQUEST_PARAMSInvalid request params40108100023OP_OUT_OF_SCOPEThe operation is not permitted40008100024MISSING_REQUEST_PARAMS40108100016UNAUTHORIZEDUnauthorized request40408100007OPA_CLIENT_NOT_FOUNDOPA Client not found42908100998RATE_LIMITToo many requests50008100026SERVICE_ERROR50008101000INTERNAL_SERVER_ERRORSomething went wrong on PayPay service side50308100999MAINTENANCE_MODESorry, we are down for scheduled maintenanceCreate a QRCodeStatusCodeIdCodeMessage40001652073DUPLICATE_DYNAMIC_QR_REQUESTDuplicate Dynamic QR request error40000400060PRE_AUTH_CAPTURE_UNSUPPORTED_MERCHANTMerchant do not support40000400061PRE_AUTH_CAPTURE_INVALID_EXPIRY_DATEProvided Expiry Date is above the allowed limit of Max allowed expiry days40001650000DYNAMIC_QR_BAD_REQUESTDynamic QR bad request errorGet payment detailsStatusCodeIdCodeMessage40001652075DYNAMIC_QR_PAYMENT_NOT_FOUNDDynamic QR payment not found40001650000DYNAMIC_QR_BAD_REQUESTDynamic QR bad request errorDelete a QRCodeStatusCodeIdCodeMessage40001652074DYNAMIC_QR_ALREADY_PAIDDynamic QR already paid40001650000DYNAMIC_QR_BAD_REQUESTDynamic QR bad request error40401652072DYNAMIC_QR_NOT_FOUNDDynamic qr code not foundCancel a PaymentStatusCodeIdCodeMessage40000200044ORDER_NOT_REVERSIBLEOrder cannot be reversed50000200034INTERNAL_SERVER_ERRORRequest timed outRefund a paymentStatusCodeIdCodeMessage40000200004INVALID_PARAMSInvalid parameters received40000200013UNACCEPTABLE_OPOrder cannot be refunded40000200014UNACCEPTABLE_OPMultiple refund not allowed40000200015INVALID_PARAMSInvalid refund amount40001103027CANCELED_USERCanceled user40400200001RESOURCE_NOT_FOUNDOrder not found50000200002TRANSACTION_FAILEDTransaction failed50000200003TRANSACTION_FAILEDTransaction failed50000800017TRANSACTION_FAILEDBalance exceeded50000200034INTERNAL_SERVER_ERRORRequest timed outFetch refund status and detailsStatusCodeIdCodeMessage40400200018NO_SUCH_REFUND_ORDERRefund not found50000200034INTERNAL_SERVER_ERRORRequest timed outCapture a payment authorizationStatusCodeIdCodeMessage20208300103USER_CONFIRMATION_REQUIREDUser confirmation required as requested amount is above allowed limit40000400035UNACCEPTABLE_OPTotal transaction limit exceeds merchant limit40000200039ALREADY_CAPTUREDCannot capture already captured acquiring order40001103027CANCELED_USERCanceled user40000400062HIGHER_CAPTURE_NOT_PERMITTEDMerchant not allowed to capture higher amount40000200043ORDER_EXPIREDOrder cannot be captured or updated as it has already expired40000200035ORDER_NOT_CAPTURABLEOrder is not capturable40000200038REAUTHORIZATION_IN_PROGRESSOrder is being reauthorized40000400064TOO_CLOSE_TO_EXPIRYOrder cannot be reauthorized as request is too close to expiry timeRevert a payment authorizationStatusCodeIdCodeMessage40000200042ORDER_NOT_CANCELABLEOrder is not cancelableLicense