Create Card Token API

In this page, you will learn how to create Card Tokens for your customers to allow efficient and secure storage for your customers' cards information.

Create Card Token API

To test your Create Card Token API, you need to request using the POST method in our sandbox environment.
-Here is the request URL:

                
                https://sandbox-cashierapi.opaycheckout.com/api/v1/international/token/create
            
                    

-Once you have a fully tested payment flow and you are ready for production, Use the following production API endpoint URL instead

                
                https://cashierapi.opaycheckout.com/api/v1/international/token/create
            
                    

-Request Parameters:

  1. Header: Bearer and private key Signature
  2.                         
                                Authorization: "Bearer" + private key signature
                                MerchantId   : 256612345678901
                            
                        
  3. Json object containing the information:
  4.     
                            {
                                "cardHolderName":"DAVID",
                                "cardNumber":"4508750015741019",
                                "customerInfo":{
                                    "customerEmail":"name@email.com",
                                    "customerId":"123",
                                    "customerMobile":"2023531565",
                                    "customerName":"name"
                                },
                                "cvv":"101",
                                "expiryMonth":"02",
                                "expiryYear":"26",
                                "reference":"123"
                            }
        
    

HTTP POST Parameters

-Here is a detailed description for the parameters you need to complete the POST request:

Parameter type required Description
reference String required Merchant unique reference.
cardNumber String required Card Number.
expiryYear String required Expiry Year.
expiryMonth String required Expiry Month.
cvv String required cvv.
cardHolderName String required Card Holder Name.
customerInfo
customerId String required User unique id.
customerName String optional User name.
customerEmail String optional User Email .
customerMobile String optional User mobile.

Create Card Token Response

-Response Parameters:

the parameters contained in the response received whenever you call the API as a JSON Object.

                
                    {
                        "code":"00000",
                        "message":"SUCCESSFUL",
                        "data":{
                            "opayToken":"OPAY_TOKEN_bf8593c1693546ea83743e4d433c5bf5",
                            "brand":"VISA",
                            "createTimestamp":1637822753,
                            "lastFourDigits":"7411",
                            "firstSixDigits":"450875",
                            "customerInfo":{
                                "customerId":"121111113",
                                "customerName":"name1",
                                "customerEmail":"123@1231.com",
                                "customerMobile":"20123111111"
                            }
                        }
                    }
            
                    

-Here is a detailed description for the parameters received in the response:

Parameter type Description example
opayToken String Card unique token. OPAY_TOKEN_bf8593c1693546ea83743e4d433c5bf5
brand String Card brand. VISA
expiryYear String Expiry Year. 26
expiryMonth String Expiry Month. 02
createTimestamp String Token create time. 1637822753
lastFourDigits String Card number last 4 digits. 7411
firstSixDigits String Card number first 6 digits. 450875
customerInfo
customerId String User unique id. 121111113
customerName String User name. name1
customerEmail String User Email . 123@1231.com
customerMobile String User mobile. 20123111111

Error Handling

After submitting an API call to OPay, you receive a response back to inform you that your request was received and processed. A successful OPay API should return a status code 00, meanwhile, in a situation where any payment processing error occurred, you will receive an error code with a message to describe the reason of the error. A sample error response can be found below.

                    
                        {
                            "code": "20000",
                            "message": "Duplicate merchant order number",
                            "data": null
                        }
                    
                

Depending on the HTTP status code of the response, you should build some logic to handle any errors that a request or the system may return. A list of possible potential error codes that you may receive can be found below. A full list of all possible error codes can be found in the Error Codes section.

Error Code Error Message
09 Time out.
90 System failure.
91 Refund error, please try again later.
96 Search order error, please try again later.
97 Create checkout session failed.
98 Invalid request header with requestId.
99 Request channel parameters are not valid.
20000 Duplicate merchant order number.

What's Next?

User Profile 12 messages

James Jones
Application Developer
Recent Notifications
Another purpose persuade Due in 2 Days
+28%
Would be to people Due in 2 Days
+50%
-27%
The best product Due in 2 Days
+8%