1. Codapay Introduction

1.1 Introduction

This page will help you get started with Coda-API. You'll be up and running in a jiffy!This guide is intended for merchants intending to integrate Codapay payment channels. It includes guidance on the different payment channels, integration processes, and brand resources, as well as detailed specifications for Codapay API.

Depending on the region, Codapay supports payment through carrier billing, credit/debit cards, bank transfer, convenience store payments, vouchers, and payment by e-wallet as part of the same framework; each option will be described here. Codapay also offers subscription billing capabilities for certain channels.Coda has a robust set of interfaces that allow a great deal of flexibility in how to implement Codapay. You can choose to use the Codapay payment pages, or maintain your own and just rely on the Codapay API.

Contact Us

For further support in integrating with Codapay, or for any questions, feedback, or suggestions regarding this document, please contact technical@codapayments.com

2. Codapay Flow

Let's look at an example of how a customer would pay for a purchase using Codapay in different environments:

(1) Desktop Web browser (using Codapay API)
(2) Mobile web browser (using Codapay API)

Flow:
1. Merchant sends an init request based on making a payment usi and e-wallet to get the Coda Transaction IID (transaction identifier).

2. When you pull up the payment page by using Coda txnId, user will click Close after paying and the payment page will be redirected to the merchant website/apps (back to the game).

3. Coda will notify the merchant of the user's top-up status.

4. Merchant will issue the corresponding goods to the player's account after receiving the notification.

The following example shows a customer making a payment using an e-wallet account.
Desktop Browser: On the merchant's site, the customer selects an item and a Codapay payment method when checking out (here “Touch&Go”).
The Codapay payment page is shown. This example shows the iframe window implementation for Touch&Go. The Customer clicks continue.
Customers will be asked to scan QRcode on Touch&Go Website.
When the payment is confirmed, the merchant is notified so that the customer's order can be fulfilled, and a “thank you” page is shown. The user clicks “Back to Merchant” and is taken back to the merchant's site.
Merchant site showing successful purchase.
Mobile Browser
For customers using a mobile device, Codapay will show a version of the payment pages that is optimized for touch-enabled devices with smaller screens.

Types of Integration:
This section describes how merchants can implement the Codapay payment pages integration. In this option, Coda's payment pages, which work equally well in a desktop browser, mobile browser, or an in-app web view, guide the user through the payment process.

You'll also have to option to leverage Coda's payment channel selection page, which means that customers will choose which payment channel to use on Coda's pages, not yours. This is the simplest integration route, especially for merchants adding support for more than one payment channel through Codapay. It also will allow you to activate new payment channels in the future without any change to your implementation.

Implementing the Codapay payment pages involves three types of integrations:

Payment Page API:
To facilitate direct interaction with the customer using a modal iframe, and to control webpage redirects. First from the merchant's website to Coda, and then from Coda back to the merchant – during a transaction. This requires HTML and JavaScript declarations to be made on your website. Payment Page API

Android Webview:
Some payment channels redirect users to their wallet app for making payments. When using Webview, it is necessary to add additional code (WebViewClient.shouldOverrideUrlLoading)to redirect to the channel's web or app for Android or to the web browser. Please refer to the table below for detailed information.

Backend API
To initiate transactions, and then at the end, to deliver results – i.e. success or error messages. This interface provides the application integration interface via web services (SOAP, RESTful or JSON) invocation Backend API.

Tokenized charge
It is a way for you to gather authorization and collect payments for subscriptions through some of the payment channels provided by Codapay. As such, Codapay will provide all the necessary methods for you to be able to conveniently charge subscription users whenever necessary. Tokenized charge

3. Integration Process

It is recommended to refer to and follow the following process for integration.

Step 1

Review + INTEGRATions..

The integration process begins with the Publisher reviewing the detailed integration documents provided by Coda. Merchants can choose from Payment page API / Backend API / Tokenized Charge

If you're using webview in mobile apps, please inform Coda's tech team. For a better user experience and a higher transaction success rate, we recommend using an external browser.

Step 2

tESTING in sanbox Environments

We recommend testing in Coda's Sandbox Environment during integration.

When using Coda's Sandbox Environment:

No actual charges will be made, and transactions will not be visible in the Coda portal.Sandbox Redirect URL and Callback URL must be configured by Coda's tech team.Some channels do not support sandbox tests.

After you're satisfied with the results in Coda's Sandbox Environment, please move on to request an active Coda account from Sandbox status to Production status.

Several channels need pre-approval from the channel provider before integration.

Merchant account status

When Coda's business team creates an account, the merchant account will be in "Testing" status by default. If you complete the sandbox test, please inform Coda's tech team to open your account in "Active" status.

Once the merchant informs us that the test is done in the sandbox, Coda's business team will submit the payment channel E-Annex approval, which the merchant needs to approve.

Step 3

tESTING in production

Environments

After successfully activating E-Annex, you can contact Coda's tech team to activate the production environment. Before doing so, please configure the redirect URL and callback URL for the production environment in the Coda portal. 

Once your merchant account is active in Coda's production service environment, we recommend completing a final test from your test environment before starting production.

If you need Coda's help with testing, please provide us with the following details:

  •  APK/ Top up Website Link
  •  Game account ID / app login ID and password
  •  Denomination ( We only test the cheapest denomination that you have)

Important note

  • It's recommended that merchants complete their testing in the sandbox environment before using real money for testing in the production environment since refunds are not available.
  • The purpose of testing in the production environment is to ensure that the callback delivery is successful. Therefore, it's sufficient to select one or two channels to test in each country.
  • For channels that can't be tested, merchants should ensure that the channel is properly configured, and the payment page is displayed successfully.
  • If merchants need assistance from Coda for real money testing, please notify Coda's technical team one business day in advance to allocate resources and manpower accordingly.
  • Assistance with testing is not available on the weekend. We recommend merchants contact us in advance to schedule testing.

Production transaction Testing Record

Transactions completed will be visible in the Transactions tab of the Coda portal and are eligible for settlement.

Bank transfer transactions may incur additional service fees from the issuing bank.

Carrier Billing Transaction

In carrier billing, only mobile numbers issued by operators in Coda's network can be used to complete charges.

For bank transfers and convenience store payments, numbers from any operator may be used.

E-wallet-only mobile numbers registered with the wallet provider can be used to complete charges.

Step 4

Deploy to Your Production Environments

After you're satisfied with the results of the tests completed using Coda's production service environment, you're almost ready to launch.

Before launch, please make sure

  • Contact Coda tech team to confirm all channel integrated is ready to launch (Including channel that needs pre-approve)
  • Ensure that your front-end implementation adheres to Coda's Brand Guidelines.
  • Contact Coda and inform us of your launch date and time so we can monitor the launch.

Daily consulting after channel / title launch

Here is the list of each inquiry that you can contact to related department

Supported Payment Channels

Our supported payment channels are divided based on the payment types (Carrier Billing, Bank Transfers, Debit/Credit Cards, Convenience Store Payments, Cash Cards/Vouchers, and E-Wallet).Depending on the region and its availability, Codapay supports payment through those mentioned payment types.

Each of the payment channels can be integrated using the Payment Page Integration or Backend API Integration, depending on the availability of each of the payment channels.

Below is a summary of the channels that we support in each environment in each country along with the payment type explanation.

Carrier Billing

Carrier Billing is a payment channel that allows customers to charge a purchase to their mobile phone account. The payment is authenticated through an SMS sent to the customer's phone, and the payment is processed immediately.

Price Points for Carrier Billing

Please note that some mobile network and cashcard operators only allow transactions at predefined price points and that some may enforce minimum and maximum limits for the value of transactions, both for single transactions and for multiple transactions over a certain time period. See the section price points and transaction limits for details.

Bank Transfer

Customers may pay for their order by executing a bank transfer at an ATM, at a bank counter, or using online banking. Merchants receive a unique payment code in the profile field, which the customer enters as part of the bank transfer details.

Card Payments

Cards payment method allows customers to complete payments using their credit or debit card. Customers will be redirected to the partner's payment page where they will input their credit card number along with its expiry and CVV code to complete the payment.

Convenience Store Payment

The Convenience Store payment method allows customers to complete payments at a convenience store. Customers receive a unique payment code in the Codapay payment window, which they present at the convenience store when making the payment. Codapay registers completed payments in real time, and merchants are notified immediately.

Voucher (Cash Card)

The Voucher payment method allows customers to purchase a voucher from an issuer (i.e. a Telco or a gaming company) and enter it in Coda's payment window to purchase digital content. Codapay registers completed payments in real time, and merchants are notified immediately.

Voucher transactions can be requested either with an expected amount or with an undefined amount. As the voucher value is confirmed only after it has been redeemed, you must be prepared to handle the case of a customer redeeming a voucher with the incorrect value.

E-wallet

E-wallet allows customers to have a digital payment account and top-up balance to the account. Codapay provides and supports many types of e-wallets so that customers can make purchases using e-wallets. The merchant is notified as soon as the customer has completed the payment.

Here is the list of support integrate payment channels. Channel logo download in this link.

3.1 Channel Selection page

Coda identifies channels by the Paytype parameter requested by the merchant

Coda Paytype Description
- Publisher design select channel page "payType": Value
In Codapay, the paytype in our request is used to identify the channel; for example, the merchant requested paytype = 227 (as shown below). After pulling up our Coda payment page, we will directly pull up GoPay Indonesia (according to this example) to pay the user.

Therefore, merchants need to make a channel selection page to make channel choices for users, and what channel users choose, the merchant will use the corresponding channel number.
- Publisher using Coda select channel page "payType": 0
Paytype has an option `"payType": 0. This option can be interpreted to mean that the merchant does not need to design it, direct uses Coda channel selection page for user to select channel and continue payment.
Important note for "payType": 0
  * Paytype = 0 does not support displaying Voucher ( cash card) channel
  * Use Paytype=0, need to contact Coda technical assist configure, otherwise transaction will
      response error 233.
- Publisher using Coda DCB channel selection page "payType": 1
Referring to the below flowchart, usually when requesting, the merchant will use the Paytype number of the channel to pull up the payment page of the channel. In this case, there are four operational channels (phone bill payment), and the merchant needs to design four operational options.
If merchant wants to design and display one option, all the operational options are grouped together; Merchants can use the operational common interface provided by Coda Paytype=1. Below we will introduce Paytype = 1.
The concept of Paytype = 1 is the same as Paytype = 0, Paytype = 1 is a request interface shared by the operational channel (phone bill payment). A merchant's request for Paytype=1 is equivalent to requesting all of the merchant's access to the local operating company. Users only need to enter their mobile phone numbers, and the Coda system can identify the operating channels used by users.

In some regions, such as Thailand, the system does not recognize the carrier by phone number, and Coda requires the user to select the channel they are using. The process will be the same as in the screenshot above, the only difference is the payment page (below).
🛎️ Channel Paytype Code
➡️ All channels except carriers billing
Payment Type Information

➡️ Carriers billing
Carrier Billing Payment Type Information

📌 Special note
Thailand Bank Transfers and Cash at Retails
Thai banks and offline payment channels (excluding 7-Eleven TH ), offline and bank payments share the same channel code "payType":331 ; merchant just need set a payment option.
Philippines Cash at Retail Philippines (exclude 7-11)Offline payments in the Philippines are shared with one channel code "payType":251 , merchant just need set a payment option.

Payment Pages Backend Integration:
API Request Notes
Please ensure that requests to Codapay API must be sent over
1. HTTPS
2. TLS 1.2 or higher

SOAP or RESTful
Codapay supports both SOAP-based and RESTful Web services.

Coda provides two interfaces:
The Init() interface, which you must use to send purchase order information from the merchant's website to Coda;InquiryPaymentResult(), which you may optionally use to check the status of a transaction.

Init() method:
When invoked by your web application, this method sends purchase information from the merchant's website to Codapay. Codapay will respond with a success or error message, along with important supporting information.

Request Message

Parameters that require special attention
* item > names (Mandatory)
* names > Must use English Alphabet。
* profile > user_id (Mandatory)。

Response Message:InitResult Type

Sample Json Response
<initResult>
   <resultCode>0</resultCode>
   <txnId>6812010872505070347</txnId>
</initResult>
   Successful response coderesultCode=0 ,
   Coda returns this parameter for successful order initiation.

Common error codes when init:
103 - Request parameter error, please contact Codapay publisher tech team.
104 - The payment page is repeatedly opened or refreshed resulting in.
205 - This is a backend account that is not activated and requires Codapay
            publisher tech team to activate it for you. Usually this error will get when
             the test environment is completed and converted to production..
206 - Request parameter error, please contact Codapay publisher tech team
214 - Request parameter error, please contact Codapay publisher tech team.
225 - This is a specific channel is not yet activated in the background.
            a. Inform Codapay publisher tech team to assist you to active it.
            b. Or the finance has created e-annex, but the merchant has not yet
             gone to the Coda portal to activate those channel.
             If you are a new merchant, please make sure you have completed the              contract sign-up process
227 - Price point is not supported, you need to ensure that the requested price
            meets the channel restrictions.
233 - When you request paytype=0, you get this error because of account              configuration problem.
            Please inform Codapay publisher tech team to do the backend              configuration.
237 - Request parameter missing UserID.
238 - USD request error, please contact Coda.
407 - Common errors that are not supported by the test environment, please
            contact Codapay publisher tech team.

InquiryPaymentResult() method:
    👍You can invoke this method at any time, to inquire about the status of a     transaction.

You may want to use this method in cases where a customer closes the payment window before the transaction has been completed, to find out whether the transaction was completed successfully or not. This method may also be useful to invoke at Transaction Completion Redirect URL. You can double-check the transaction result via this method.

PaymentResult inquiryPaymentResult(InquiryPaymentRequest request)

Request Message


Sample Json Request
{
"inquiryPaymentRequest":
{
"apiKey" : "<API Key>",
"txnId" : "6850829481872754784",
        "needStatusFinal": "true"
  }
}

Response Message: PaymentResult Type


Sample Json Response -Success
{
    "paymentResult": {
        "orderId": 20230526062337,
        "profile": {
            "entry": [
                {
                    "key": "PaymentType",
                    "value": 236
                },
                {
                    "key": "isStatusFinal",
                    "value": true
                },
                {
                    "key": "status",
                    "value": "success"
                }
            ]
        },
        "resultCode": 0,
        "resultDesc": "",
        "totalPrice": 1,
        "txnId": 6850822175662776971
    }
}
Sample Json Response -Pending
{
    "paymentResult": {
        "orderId": 20230526067748,
        "profile": {
            "entry": [
                {
                    "key": "PaymentType",
                    "value": 236
                },
                {
                    "key": "isStatusFinal",
                    "value": true
                },
                {
                    "key": "status",
                    "value": "pending"
                }
            ]
        },
        "resultCode": 213,
        "resultDesc": "This transaction has been cancelled. No charges were made. (error:213)",
        "totalPrice": 50,
        "txnId": 6850829481872754754
    }
}
Sample Json Response -Failed
{
    "paymentResult": {
        "orderId": 20230526063548,
        "profile": {
            "entry": [
                {
                    "key": "PaymentType",
                    "value": 236
                },
                {
                    "key": "isStatusFinal",
                    "value": true
                },
                {
                    "key": "status",
                    "value": "failed"
                }
            ]
        },
        "resultCode": 213,
        "resultDesc": "This transaction has been cancelled. No charges were made. (error:213)",
        "totalPrice": 50,
        "txnId": 6850829481872754784
    }
}

Profile Fields

Item Info:
Item represents an SKU. Code and Name should be unique and univocally represent the item. Name needs to be user-friendly, as it shows to end-users in the payment window.

Name
Length
Type
Description
code
string
128
Merchant-managed item code.
name
string
128
The name of the purchased item or topup, e.g. “50 diamonds”. If purchases can be made for multiple games or services, include also the name of that, e.g. “Hero's Glory - 200 gold”.

Note: Value must only contain english characters.
price
float
N/A
The price of the item (inclusive of any taxes) in the currency specified in the request message.
type
numeric
N/A
default = 1.


Channel Parameters List

Bank Transfers, Debit/Credit card, Convenience Store payments, Vouchers, and E-wallet.
Payment Type Information
Carrier BillingCarrier Billing Payment Type Information.

Payment type information
Besides Carrier's billing, Codapay channel parameters lists.

Country
Type
All
Payment Channel Selection
All
Carrier Billing
Argentina
Pago Facil
Argentina
Rapi Pago
Argentina
Card Payments Argentina
Argentina
Mercado Pago
Australia
Card Payments Australia
Austria
EPS
Bahrain
Benefit
Bangladesh
bKash
Belgium
Bancontact
Bolivia
Cash Payment Bolivia
Brazil
Ame Digital
Brazil
Bank Transfer
Brazil
Boleto
Brazil
PicPay
Brazil
PIX
Brazil
Mercado Pago
Brazil
Card Payments Brazil
Cambodia
Paygo
Cambodia
PiPay
Cambodia
Wing
Cambodia
Card Payments Cambodia
Cambodia
KHQR ( Bakong )
Chile
Bank Transfer Chile
Colombia
Card Payments Colombia
Colombia
DaviPlata
Colombia
Bank Transfer Colombia
Canada
Card Payments Canada
Czech Republic
Card Payments Czech Republic
Denmark
MobilePay
Egypt
Fawry
Egypt
Orange Money
Egypt
Meeza Card
Egypt
Masary, Aman, Momken
Egypt
Vodafone Cash
Egypt
Card Payments Egypt
Ecuador
Cash Payment (OTC)
Ecuador
Card Payments Ecuador
France
Card Payments France
Germany
Card Payments Germany
Germany
GiroPay
Hong Kong
PayMe
Hong Kong
Card Payments Hong Kong
Hong Kong
Alipay HK

Carrier Billing Payment Type Information:
pay_type = 1 or pay_type=MNO ID

If you would like to take advantage of the fact that some telcos are cheaper than others, and therefore set different pricing for different telcos, then we recommend you let the user select which telco they are using on your checkout page and send us the specific MNO ID for that telco in the init request.

Furthermore, if you would prefer to have uniform pricing across telcos you may opt to simply have one payment option for carrier billing. In this case, you may simply send pay_type = 1.

❗️If customers enter MSISDN of different carrier billings from the carrier billings in the request message, the transaction will be failed with error 240.

Complete notification URL:
When a payment transaction has been completed, Codapay notifies your application using the “Transaction Completion Notification URL”.

🚧By default, Coda ONLY sends notifications for Successful transactions (not for Pending or Failed transactions).

- This is a web application URL using HTTPS and TLS 1.2 or Higher.
- GET method with the following HTTPS parameters.

👍How to configure the address
Sandbox environment: Contact Codapay publisher tech team, and request assist configuring URL via tech chat group.

Production environment: Merchant can configure at Coda portal any time, direction will be Integration --> Security --> Codapay Publisher Settings, effective immediately

Request Message

As indicated in the call flows, it's important that you reply to this message with either a success or failure message.

- If your application processes the transaction successfully, it should reply to Coda with the message ‘ResultCode=0’.
- If your application did not process the transaction successfully, it should instead reply to Coda with your error code.

❗️Important note

Note that for True Money Cash Card and One-2-Call Cash Card, the point in the transaction where Coda notifies you of the value of the voucher that was redeemed. Your system should interpret the value indicated in the TotalPrice parameter of the notification URL and distribute an appropriate amount of game credits that corresponds with the value of the voucher the customer redeemed. Because Coda cannot block customers from redeeming particular voucher denominations, merchants are required to support the redemption of each denomination/price point in which the voucher is distributed

❗️After receive Coda Completed Notify , Merchant needs to reply "ResultCode=0" to inform item has been sent.

Example:
NotifyURL="Merchant callback address TxnId=Coda order number&OrderId=Merchant orderID&TotalPrice=Amount&PaymentType=Channel number&ResultCode=0&Checksum=xxxxx", MResp="ResultCode=0"

❗️Callback using GET method

If CODA does not receive a reply of "resultcode=0" from the merchant, the retry mechanism will resend three times, once every five minutes. If the resending mechanism also fails, an email notification will be sent.

Note: Before the go live in production environments , please inform the CODA Tech Team to configures recipients email to received failed transaction.

Response Message

Name
Length
Type
Description
ResultCode
string
N/A
Success or your Error code. Success message is ‘ResultCode=0’.

If Coda receives an error code, we will make (up to) three additional attempts to notify you of the transaction result. If, after these additional attempts, Coda still has not received ResultCode=0 , our system will send an email to your technical contact with details of our failed notification attempts.

Occasionally, processing a payment takes longer than expected. This may happen if there is a technical problem or delay at a particular payment channel. When this happens, Codapay will continue to wait for the payment confirmation from the payment channel, while redirecting the customer to your Transaction Redirect URLs. When a customer reaches this page before you have received a Transaction Completion Notification from Codapay, you should:

1. Show the customer a “Transaction is in progress”
2. Fulfill the user's purchase when we subsequently send you the Transaction
    Completion Notification (or, when we respond to your InquiryPaymentResult()
   method with a success message).
Security(Checksum, IP whitelist, etc

Whether you select a static or dynamic Transaction Completion Notification URL, it's extremely important that it be secure. If someone would gain access to this URL, they may be able to fake payment transactions and create transactions for which you would not be reimbursed. Please implement the following methods to ensure the security of this URL.

❗️Make sure your Transaction Completion Notification URL is secure!

Implement Checksum
👍Codapay's checksum combination is TxnID + API key + OrderId + ResultCode, you also need to do the corresponding update after changing the API key

Using a checksum will help ensure messages are not tampered with. The Checksum string is created using the TxnId, the API key, the OrderID (if any) and the ResultCode:

Step 1
Append the values listed below as a string as follows: “TxnID + API key + OrderId + ResultCode”. For example:
TxnId = 3381290433880074215
ApiKey = 5a8ca8f31f19a23c41edd14b29a74fd2
OrderId = 8ae6ffee169b
ResultCode = 0

String checksumString = "33812904338800742155a8ca8f31f19a23c41edd14b29a74fd28ae6ffee169b0"

Step 2
Calculate the MD5 hash of the string (checksumString). MD5 algorithm will return byte array value.

Step 3
Convert from the byte array value to hexadecimal string. The result string will be "5cb948816af0b5b61516fd71a17d271b"with above values.

If you want Checksum checking, make MD5 calculated and hexadecimal converted string, and then compare with Checksum value in the Transaction Completion Notification parameters.

Implement HTTPS
This will prevent third parties from message eavesdropping.

Filtering Codapay IP
👍Only if the transaction callback can get through your firewall and send you a transaction completion notification message.

Make sure that Codapay is the only one who can send you transaction completion notification messages by configuring your firewall using the following Codapay's IP address:
(hidden for security purposes)

Filtering Merchant IP
This whitening is based on rendering on the init interface, and only the IP you whited can request orders.

Direction: Coda portal --> Intergration --> Security --> Codapay Publisher Settings --> Action (Edit IP Address)

Complete or Pending landing page URL
These URLs define what page on your website your customer is redirected to after they have completed their transaction in our payment interface.

👍How to configure the address

Sandbox environment: Contact Codapay publisher tech team, and request assist configuring URL via tech chat group.

Production environment: Merchant can configure at Coda portal any time, direction will be Integration --> Security --> Codapay Publisher Settings, effective immediately.

🚧3 Types of Redirect URL

Three redirection url that you must configure. If there is no need to categorize the redirect page, you can reuse the same redirect address.

Complete landing page URL
When your customer leaves Coda's payment page after completing a Carrier Billing, e-wallet or card payment, they will be redirected to the Complete Transaction Redirect URL by using HTTPS/TLS 1.2 Get Method with the following parameters.

Name
Length
Type
Description
TxnId
Numeric
N/A
Unique TxnId returned from Init() Method call.
OrderId
String
64
Unique transaction identifier passed by Init() Method request message from Merchant.

Bank Transfer Transaction Pending Redirect URL
When your customer leaves Coda's payment page after initiating a Bank Transfer, they will be redirected to the Bank Transfer Transaction Pending Redirect URL by using TLS 1.2 GET method with the following parameters.

Name
Length
Type
Description
TxnId
Numeric
N/A
Unique TxnId returned from Init() Method call.
OrderId
String
64
Unique transaction identifier passed by Init() Method request message from Merchant.

You should show a message on this page to clarify the status of the order, e.g. “Your order is confirmed, and pending payment. Please follow the instructions provided to you to complete your payment at the ATM. Once your payment is completed, we will fulfill your order immediately.”

Convenience Store Transaction Pending Redirect URL
When your customer leaves Coda's payment page after initiating an Convenience Store payment, they will be redirected to the Convenience Store Transaction Pending Redirect URL by using HTTP/TLS 1.2 GET method with the following HTTP parameters.

Name
Length
Type
Description
TxnId
Numeric
N/A
Unique TxnId returned from Init() Method call.
OrderId
String
64
Unique transaction identifier passed by Init() Method request message from Merchant.

You should show a message on this page to clarify the status of the order, e.g. “Your order is confirmed, and pending payment. Please follow the instructions provided to you to complete your payment at the Convenience Store. Once your payment is completed, we will fulfill your order immediately.”

InitRequest currency by USD
This feature allows Codapay merchants to initiate transaction requests in US dollars. There's no need for merchants to maintain price lists in the many local currencies in which they operate.

Merchants may just keep one price list in USD, and Coda will handle the currency conversion in real time. Our FX conversion uses the mid-market rate sourced from a broad range of commercial sources and banks.

This system of multiple fallbacks ensures the highest levels of accuracy and reliability.

✍️ Exchange rates are refreshed once per day.

Request Currency
For payment requests, Codapay currency parameter offers two options
- Local Currency
- US Dollar

🚧User payments are only supported in local currency, differentiated by countryCoda doesn't support conversions like RMB-> IDR

Request Flow
1. When the merchant needs to request US dollars, the request parameter currency must use840.
2. When the user pays, Coda payment page will convert and display in local currency.
3. Coda payment page shows the price in local currency, based on the conversion rate of the day in Coda system.

Sample Request
{
    "initRequest":
    {
        "country": 360,
        "payType": 0,
        "apiKey": "<Your API Key>",
        "orderId": "1234",
        "currency": 840,
        "items":
        [
            { 
               "code": "1",
                "price": 100.00,
                "name": "Test Item500             
           }
        ],
        "profile":
        {
            "entry":
            [
                {
                    "key": "user_id", 
                   "value": "105"
                }
            ]
        }
    }
}

An example is provided below, using Coda's channel selection page paytype=0. After requesting to pull up the page, users can see the channels they can choose from along with their respective local prices.

🛎️ Complete notification logs showing USD price
TotalPrice in the Coda callback displays local price by default. If a merchant needs to display their InitRequest USD price in the callback parameter, please notify Coda technical support so that it can be configured.

For comparison, consider the following example, with USD Price appended to the end of the callback parameter:
No callback added for USDPrice configuration:https://sample.com/notify/callback?
TxnId=6366201293481272797&OrderId=CodaTest&TotalPrice=1426935.00&
PaymentType=23&ResultCode=0&
Checksum=bbb4828b8d2a1bafb123a12b55d666f5

Added USDPrice configuration callback:
https://sample.com/notify/callback?
TxnId=6366201293481272797&OrderId=CodaTest&TotalPrice=1426935.00&
PaymentType=23&ResultCode=0&
Checksum=bbb4828b8d2a1bafb123a12b55d666f5&USDPrice=100.00

📘Cambodia🇰🇭
Some regions use US dollars as a currency unit, the callback parameter will not appear USDPrice. Such as Cambodia

👍Note for USD Transaction Initiation

If merchants specified the payType in the Initiation request, then we will respond with the price in Local Currency.
- If merchants do not specify the payType, (or use payType 1 for generic DCB) then the response will not contain the price.
- If merchants use our payment pages frontend integration, we will display the price in local currency to the user.
- The API is fully backwards compatible. To start using this feature, simply start sending a USD amount in the "price" parameter and the ISO Code "840" in the "currency" parameter.
- USD amounts can be submitted with two decimal places, but local amounts may be rounded up to the nearest whole number. For IDN, JPN, MMR, VNM, and LAO, it will be rounded to the nearest whole number. For other countries, it will be rounded to the nearest 2 decimal places.
- Channels with specified pricing requirements, such as Maxis in Malaysia, Telkomsel in Indonesia, etc.; we do not recommend using USD requests.

4. Backend API

Introduction:
This page will help you get started with Coda Backend API. You'll be up and running in a jiffy!

Overview:
This section explains how merchants can implement the Codapay back-end integration API.

Implementing this API entails a purely backend integration between the merchant and Coda – customers will not be redirected to Coda's payment pages.

This option is suitable for implementation in any environment, web or app, and allows you to maintain your own branding through the whole payment flow.

It just takes more time to implement and maintain than using our payment pages.

APIKEY:
Each game or platform that merchant integrate will have one set of API keys; each country's API key is separate. All Codapay API keys are available in the Coda portal's Integration, Security, - Codapay Publisher settings pages.

If you need to open a new account in a different country, please notify our Coda Business Team so that an API Key for that country can be created, which can then be viewed in Integration - Security.

Direct Page link: https://portal.codapayments.com/integration/security/ip-addresses

🚧Sandbox environment and production environment API keys are the same.

Backend Call Flows Brief

Carrier Billing (DCB)

Carrier Billing is a payment type that allows customers to charge a purchase to their mobile phone account. The payment is authenticated through an SMS sent to the customer's phone, and the payment is processed immediately.

Depending on the payment channel, there are differences in the way that a customer authorises the transaction, and in what information you need to provide for them to do so.

E-Wallet
With the Wallet payment type, merchants will receive a redirect link for the customer to complete their payment. Usually, it’s either the deep link (directly opening the wallet app) or the redirection page where the customer needs to fill in some additional information and authorize the payment.

Bank Transfer
Customers may pay for their order by executing a bank transfer at an ATM, at a bank counter, or using online banking. Merchants receive a unique payment code in the profile field, which the customer enters as part of the bank transfer details.

Card payments
Cards payment method allows customers to complete payments using their credit or debit card. Customers will be redirected to the partner's payment page where they will input their credit card number along with its expiry and CVV code to complete the payment. Codapay registers completed payments in real time, and merchants are notified immediately.

Vouchers (Cash Card)
Vouchers payment method allows customers to redeem their voucher codes at Codapay. Codapay registers completed payments in real time, and you are notified immediately. See Voucher details in Profile fields in the request table for more details.

For voucher transactions, the voucher's value is confirmed only after it has been redeemed; You need to validate the net_amount returned in Coda's API response, and be able to handle the redemption of all available denominations.

Convenience Store (OTC)
With the Convenience Store payment type, customers complete their payment at a convenience store or other payment counter. Merchants receive a unique payment code in the profile field, which the customer presents at the counter when making the payment. See Convenience Store details in Profile field in the response table for more details

👍Result Code
"resultCode": 0 mean transaction success
For Error Code list, please refer to https://codapayments.readme.io/docs/error-codes

Backend Call Flow

Carrier Biling
Carrier Billing Call Flow

Carrier Billing MT-MO Authentication Flow
In Carrier Billing MT-MO authentication the customer receives instructions by SMS, and authorises the transaction by sending an SMS based on those instructions.

Carrier Billing MO Authentication Flow
Also in Carrier Billing MO authentication, the authorisation is also done by sending an SMS, but instructions on doing so must be provided on your payment page.

Request Message

Item Info:
🚧Item represents a SKU

Code and Name should be unique and univocally represent the item.
Name needs to be user-friendly, as it shows to end-users in the payment window.

Other details in Profile field


Sample Of Response
Sample with msisdn:
{
    "txn_id": 6648561839693172536,
    "txn_timeout": 11,
    "result_code": 0,
    "total_price": 100.0, 
   "pay_instructions": "We just sent an SMS to xxxxxx. To complete the transaction,
send \"PAY\" followed by five digits code from the SMS to 75457. Example: PAY 12345.",
    "profile": {
        "extInfoByte": "0",
        "user_id": "Testuser397",
        "merchantType": "Codapay"
 }
}
Sample without msisdn:
{    
"txn_id": 6742026121325386583,
    "txn_timeout": 61,
    "result_code": 0,
    "total_price": 1000.0,
    "pay_instructions": "",
    "profile": {
        "extInfoByte": "0",
        "user_id": "12345",
        "merchantType": "Codapay",
        "redirect_url": "https://sample_URL.com"
    }
}

Sample Of Response
Sample with msisdn
{
"txn_id": 6648561839693172536,
"txn_timeout": 11,
"result_code": 0,
"total_price": 100.0,
"pay_instructions": "We just sent an SMS to xxxxxx. To complete the transaction, send
\"PAY\" followed by five digits code from the SMS to 75457. Example: PAY 12345.",
"profile":
{
"extInfoByte": "0",
"user_id": "Testuser397",
"merchantType": "Codapay"
}
}
Sample without msisdn
{
    "txn_id": 6742026121325386583,
    "txn_timeout": 61,
    "result_code": 0,
    "total_price": 1000.0,
    "pay_instructions": "",
    "profile": {
        "extInfoByte": "0",
        "user_id": "12345",
        "merchantType": "Codapay",
        "redirect_url": "https://sample_URL.com"
    }
}

🚧 Reference of USD TransactionsPlease check out this guide to know more on USD transactions.
E-Wallet
E-wallet Call Flow

With the Wallet payment type, merchants will receive a redirect link for the customer to complete their payment. Usually, it’s either the deep link (directly opening the wallet app) or the redirection page where the customer needs to fill in some additional information and authorize the payment.

Item Info
🚧Item represents a SKU

Code and Name should be unique and univocally represent the item.Name needs to be user-friendly, as it shows to end-users in the payment window.


Require msisdn and email:
{
   "api_key":"<YOUR API KEY>",
   "order_id":"<Your Order ID>",
   "lang":"en",
   "merchant_name":"Koko eBooks",
   "pay_type":"5",
   "pay_channel":"20",
   "type":"1",
   "msisdn":"<phone number>",
   "email":"<email address>" ,
   "items":[{
       "code":"456789",
       "name":"One Day",
       "price":1000.00
   }],
   "profile":{"user_id":"12345"}
}Require customer name and id_no
{
   "api_key": "<YOUR API KEY>",
   "order_id": "<Your Order ID>",
   "lang": "en",
   "merchant_name": "Koko eBooks",
   "type": "1",
   "pay_type": "5",
   "pay_channel": "98",
   "email": "test@codapayments.com",
   "msisdn": "123432",
   "items": [
       {
           "code": "1",
           "name": "One Day",
           "price": 3
       }
   ],
   "profile":{"name":"CodaUser","user_id":"12345","id_no":"88899988811"}
}Msisdn and email not required
{
   "api_key":"<YOUR API KEY>",
   "order_id":"<Your Order ID>",
   "lang":"en",
   "merchant_name":"Koko eBooks",
   "pay_type":"5",
   "pay_channel":"39",
   "type":"1",
   "items":[{
       "code":"456789",
       "name":"One Day",
       "price":1000.00
   }],
   "profile":{"user_id":"12345"}
}Require Document number and type
{
 "api_key": "<YOUR API KEY>",
 "order_id": "<Your Order ID>",
 "lang": "en",
 "pay_type": "5",
 "pay_channel": "255",
 "email": "test@codapayments.com",
 "type": "1",
 "merchant_name": "Koko eBooks",
 "items": [
   {
     "code": "1",
     "name": "ebook",
     "price": "1000.0",
     "type": "0",
   }
 ],
 "profile": {
   "document_number": "1134568011",
   "user_id": "12345",
   "document_type": "CC"
 }
}

Sample of Response
Require msisdn and email
{
  "txn_id": <coda transaction ID>,
  "txn_timeout": 20,
  "result_code": 431,
  "result_desc": "Please wait a few minutes for your transaction to be completed. Need Help? Visit our <a href=“http://bit.ly/idCODAhelp” target=“_blank”>Help Center</a>.",
  "total_price": 1000.0,
  "pay_instructions": "",
  "profile": {
       "extInfoByte": "11",
       "user_id": "12345",
       "merchantType": "Codapay",
       "payment_code": ""
   }
}
Require customer name and id_no
{
   "txn_id": <coda transaction ID>,
   "txn_timeout": 1445,
   "result_code": 431,
   "result_desc": null,
   "total_price": 3.03,
   "pay_instructions": "",
   "profile": {
       "extInfoByte": "0",
       "id_no": "88899988811",
       "user_id":"12345",
       "redirect_url": "https://sample_URL.com",
       "payment_code": ""
   }
}Msisdn and email not required
{
   "txn_id": <coda transaction ID>,
   "txn_timeout": 11,
   "result_code": 0,
   "result_desc": null,
   "total_price": 1000.0,
   "pay_instructions": "",
   "profile": {
       "redirect_url": "https://sample_URL.com",
       "extInfoByte": "0",
       "payment_code": ""
   }
}Require Document number and type
{
   "txn_id": <coda transaction ID>,
   "txn_timeout": 17,
   "result_code": 431,
   "total_price": 1000.0,
   "pay_instructions": "",
   "profile": {
       "extInfoByte": "0",
       "document_number": "1134568011",
       "user_id": "12345",
       "merchantType": "Codapay",
       "redirect_url": "https://sample_URL.com",
       "document_type": "CC",
       "payment_code": ""
   }
}

5. Reference

Country and Currency Codes

Restricted Access for Certain Countries in Coda

An important update regarding our Anti-Money Laundering (AML) compliance notice. As part of our ongoing commitment to maintaining a secure and compliant financial environment, we have implemented sanction IP blocking in Coda Payments.

📘Please note that the following countries are subject to sanction IP blocking in Coda:

Crimea
Afghanistan
Cuba
Belarus
Iran
Burundi
North Korea
Eritrea
Sudan
Syria
Libya
Russia
Somalia
South Sudan
Venezuela
Yemen
Zimbabwe

If you have any questions or concerns regarding the sanction IP blocking or need further clarification, our dedicated Business Development Team is available to assist you.

Thank you for your continued trust and support as we work together to uphold the integrity and security of the Coda platform.

6. Tokenized Charge API

What is Tokenized Charge?

Tokenized charge is a way for you to gather authorization and collect payments for subscriptions through some of the payment channels provided by Codapay. As such, Codapay will provide all the necessary methods for you to be able to conveniently charge subscription users whenever necessary.

How tokenized charge works?

For each payment channel supporting tokenized charge, Codapay provides 7 core functions:
- Linking/Unlinking a user wallet account
- Authenticating a subscription
- Charging a user
- Cancelling a subscription
- Checking a charge status
- Refunding a transaction
- Pre-notifying a user that they will get charged soon

Each payment channel integration has a different flow, all the details on how the core functions can be used for each of them is provided in this guide.

Overview

Pay channel ID:
Pay channel ID is a unique identifier for the payment channel you are processing payment with. You can find the full list of Pay channel IDs here.

Pay provider ID:
Pay provider ID is a unique identifier for the provider that makes the payment channel available. You can find the full list of Pay provider IDs to use for each payment channel here.

isChargeable:
At any point in the payment process, you can check the isChargeable field to check if you are able to charge a user or not

Payment channels:
Below is the list of supported payment channels with its respective pay channel id, pay provider id and expected currency:

Get Started
Step 1: Get your credentials
Before you start integrating, your merchant support engineer will need to generate a Client ID, a Client Secret and an x-API-Key for you to be able to authenticate in each environment (staging and production). You can also get your unique apiKey from our portal in the “API keys” page.

To get these credentials for each environment, you need to send the information below to your support engineer:

- The IP Address(es) you will be using to make API calls, so that we can allow
  them.
- The URL you will be using to receive the Charge notifications.
- The URL you will be using to receive the Subscription notifications.
- In the case of GoPay, you will also need to provide a redirect URL. This is the
   URL Payment channels will redirect your users to after the account linking is    successful.

Step 2: Learn about authentication
Check out the authentication section to learn about how to use your credentials to authenticate a request.

Step 3: Go through the guides and make a test payment
Learn about how the flow and how to make a charge for one of the payment channels we have partnered with.
- Gopay

📘Get some help (if you need)
For any support or questions that are not addressed in this document, you can reach out to your support engineer who will be able to help you.

Authentication and Security

Authentication Guide
In order to make requests to our system, you will need to authenticate them. To do that, you need to include the following fields in the headers of all API requests:
- Content-Type.
- x-API-key.
- x-api-version.
- Authorization.

How to generate the JWT token
📘More details about JWT tokens can be found here.

JWT (or JSON Web Token) is a token that you can generate from your payload and that provides an easy way to transmit information between parties securely.

You can generate one by using one the jwt libraries that can be found here and passing a header value that contains information on how to encode the data and a payload that contains your data.

The token header should contain the following information:
- alg: this is the signing algorithm to use. For your request to Coda, always use
  HS256.
- typ: this is the type of token you want to generate. For your request to Coda,
   always use “JWT”.
- xClientId: This is the Client id provided to you by Coda.

🚧Note: This is the token header that will be used to generate the authorization, not the header of your request to Coda. Do not expose the xClientId in the header of your request to Coda. Encode it as part of the token by passing it through the token header.

For Example


Token Header
{
  "alg":"HS256",
  "typ":"JWT",
  "xClientId":[
     "yourClientIdProvidedByCoda"
  ]
}
The payload is the payload that you are planning to send through your request to Coda.
For Example:
payload
{
  "apiKey":"39aa6b9d8c4ffb1a9403b51469efd47e",
  "orderId":"20200330142600",
  "lang":"en",
  "merchantName":"Koko eBooks",
  "payType":5,
  "payChannel":332,
  "payProvider":506,
  "items":[
     {
        "code":"1",
        "name":"One Day",
        "price":10
     }
  ],
  "iat":1585701733,
  "checksum":"f40fc9e74d662daff507403bfc7ba28e"
}

To generate a JWT, you can first encode the token header and the payload, then generate a signature from your Client Secret and assemble them.

generate JWTkey = '*yourclientsecret*'
unsignedToken = *encodeBase64Url(header) + '.' + encodeBase64Url(payload)*
signature = *HMAC-SHA256(key, unsignedToken)*
JWT = *unsignedToken + ‘.’ + signature*

❗️Please note that the generated token is available for 5 minutes.

Calculating a checksum
For each request, we require that you send a checksum parameter in order to verify data integrity. To calculate a checksum, you can follow the steps below:

Step 1:
Append the Client Secret, API key and Subscription ID values as a string in the following way:
“[Secret Key] + [API key]+ [Subscription Id]”

Step 2:
Calculate the MD5 hash of the string. The MD5 algorithm will return a byte array value.

Step 3:
Convert from the byte array value to a hexadecimal string.

Verifying a checksum:
To verify a checksum returned by Coda, you can calculate the expected checksum as described above and compare the result string with the one we have returned

Authentication Guide

In order to make requests to our system, you will need to authenticate them. To do that, you need to include the following fields in the headers of all API requests:
- Content-Type
- x-API-key
- x-api-version
- Authorization
The description of these parameters is provided in the table below:

How to generate the JWT token

📘More details about JWT tokens can be found here.

JWT (or JSON Web Token) is a token that you can generate from your payload and that provides an easy way to transmit information between parties securely.

You can generate one by using one the jwt libraries that can be found here and passing a header value that contains information on how to encode the data and a payload that contains your data.

The token header should contain the following information:

- alg: this is the signing algorithm to use. For your request to Coda, always use
   HS256.
- typ: this is the type of token you want to generate. For your request to Coda,
   always use “JWT”
- xClientId: This is the Client id provided to you by Coda.

🚧Note: This is the token header that will be used to generate the authorization, not the header of your request to Coda. Do not expose the xClientId in the header of your request to Coda. Encode it as part of the token by passing it through the token header.

For Example


Token Header
{
  "alg":"HS256",
  "typ":"JWT",
  "xClientId":[
     "yourClientIdProvidedByCoda"
  ]
}
The payload is the payload that you are planning to send through your request to Coda.
For Example:
payload
{
  "apiKey":"39aa6b9d8c4ffb1a9403b51469efd47e",
  "orderId":"20200330142600",
  "lang":"en",
  "merchantName":"Koko eBooks",
  "payType":5,
  "payChannel":332,
  "payProvider":506,
  "items":[
     {
        "code":"1",
        "name":"One Day",
        "price":10
     }
  ],
  "iat":1585701733,
  "checksum":"f40fc9e74d662daff507403bfc7ba28e"
}

To generate a JWT, you can first encode the token header and the payload, then generate a signature from your Client Secret and assemble them.

generate JWT
key = '*yourclientsecret*'

unsignedToken = *encodeBase64Url(header) + '.' + encodeBase64Url(payload)*
signature = *HMAC-SHA256(key, unsignedToken)*
JWT = *unsignedToken + ‘.’ + signature*

❗️Please note that the generated token is available for 5 minutes.

Calculating and Verifying a checksum

Calculating a checksum (Init Subscription)
For each request, we require that you send a checksum parameter in order to verify data integrity. To calculate a checksum, you can follow the steps below:
Step 1: Append the Client Secret, API key, Order ID, Pay Channel, Pay Provider, and Price values as a string in the following way:
“[Secret Key] + [API key] + [Order ID] + [Pay Channel] + [Pay Provider] + [Price]”
Step 2: Calculate the MD5 hash of the string. The MD5 algorithm will return a byte array value.
Step 3: Convert from the byte array value to a hexadecimal string.

Calculating a checksum (Charge)
For each request, we require that you send a checksum parameter in order to verify data integrity. To calculate a checksum, you can follow the steps below:

Step 1:Append the Client Secret, API key, Order ID, Pay Channel, Pay Provider, and Subscription ID values as a string in the following way:
“[Secret Key] + [API key] + [Order ID] + [Pay Channel] + [Pay Provider] + [Subscription Id]”
Step 2: Calculate the MD5 hash of the string. The MD5 algorithm will return a byte array value.
Step 3: Convert from the byte array value to a hexadecimal string.

Common API Checksum Calculation
Calculating checksum for Common API (Check Subscription Status and Cancel Subscription).
For each request, we require that you send a checksum parameter in order to verify data integrity. To calculate a checksum, you can follow the steps below:

Step 1: Append the Client Secret, API key and Subscription ID values as a string in the following way:
“[Secret Key] + [API key]+ [Subscription Id]”
Step 2: Calculate the MD5 hash of the string. The MD5 algorithm will return a byte array value.
Step 3: Convert from the byte array value to a hexadecimal string.

Calculating checksum for Common API (Check Charge Status and Refund)
For each request, we require that you send a checksum parameter in order to verify data integrity. To calculate a checksum, you can follow the steps below:

Step 1: Append the Client Secret, API key and Transaction ID values as a string in the following way:“[Secret Key] + [API key]+ [Transaction Id]”.

Step 2: Calculate the MD5 hash of the string. The MD5 algorithm will return a byte array value.

Step 3: Convert from the byte array value to a hexadecimal string.

Verifying a checksum
To verify a checksum returned by Coda, you can calculate the expected checksum as described above and compare the result string with the one we have returned.

Payment Channels Integration Flow

GoPay Flow and Integration Guide

🚧CodaPay has partnered with GoPay to provide tokenized charge through GoPay’s wallet. Please note that as of now, GoPay only allows you to subscribe each of your users to a single item only.

Link your user’s account and make the initial charge

1. Collect your user’s GoPay phone number as this will be used to initiate their subscription.

2. When your user is ready to initiate a new subscription, make a POST to /subscription/init to initiate the tokenized charge by collecting user consent. The response will include a URL that you can use to redirect your user to let them authenticate and link their account. If your user is on mobile, you can use activationAppUrl to redirect your user directly to the GoPay app. If they are on a desktop, you can get a QR code from redirectUrl and display it to the user so that they scan it with their GoPay app. The response also contains a subscriptionId, do store this value as this will be used later whenever you will need to make a charge.

3. Once redirected to the GoPay app, your user will need to authenticate and link their account. They will then be redirected to your website.

4. When the linking process is completed, we will send a subscription notification to let you know by sharing the updated isChargeable value. If it is set to True, then you are ready to make the first charge. If it is set to False then that means that the account linking has failed. You can check the error codes list to understand what happened.

5. To do the first charge, make a POST to /subscription/charge. You can follow the "Make a charge" guide below for that.

Make Charge:

1. After the initiation was successful, you can charge your user anytime you need. To do that, make a POST request to /subscription/charge and provide item details and subscriptionID.

2. The response to that call can be any of the following:
a. Successful: the charge has been completed successfully! You should expect to see the errorCode field’s value set to 0 and txnStatus to 6.
b. Pending: the transaction is pending. In this case, the errorCode field’s value should be 431 and you should expect to receive a charge notification with the final status of the transaction.
c. Failed: the transaction has failed. You can refer to the error codes to understand the reason for the failure.

3. We will send you a charge notification to update you on the status of the transaction when it reaches a final state.

Check a Subscription Status:
If you want to make sure you are allowed to make a charge for a given subscription you can make a POST call to /subscription/check. If the isChargeable field is set to true, that means it is possible to charge the user for that specific subscription. If the isChargeable field is set to false, that means you are not allowed to make the charge.
You can read more about possible resultCode values and failure scenarios in the API reference.

Check Charge Status:
At any point in time, you can check a charge status by making a POST call to /subscription/inquiryPaymentResult. You can better understand the response by looking at the possible resultCode values and failure scenarios in the API reference.

Refund:
You can refund any previously successful charge by making a POST call to /subscription/refund. You can better understand the response by looking at the possible resultCode values and failure scenarios in the API reference.

Rabbit LINE Pay Flow and Integration Guide

🚧Codapay has partnered with RabbitLinePay to provide tokenized charges through RabbitLinePay’s wallet.
Link your user’s account and make the initial charge

1. When your user is ready to initiate a new subscription, make a POST to /subscription/init to initiate the tokenized charge by collecting user consent. The response will include a URL that you can use to redirect your user to let them authenticate and link their Line Pay account. At this point, you should receive a subscription notification, with a isChargeable value set to False. If the initiation fails the response will include an error message.

2. Once redirected to Line Pay, your user will need to authenticate and approve the subscription. They will then be redirected to your website. If the authentication is successful, we will send you a subscription notification to let you know by sharing the updated isChargeable value. If it is set to True, then you are ready to make the first charge. If it is set to False then that means that the account linking has failed. You can check the error codes list to understand what happened.

3. Once the authentication is done, you will need to do the first charge a few minutes after the initiation. It is required to do a first charge in order for the subscription to become active. To do so, you can make a POST to /subscription/charge. You can follow the "Make a charge" guide below for that.

Make Charge

1. After the initiation was successful, you can charge your user anytime you need. To do that, make a POST request to /subscription/charge and provide item details and subscriptionID.

2. The response to that call can be any of the following:
a. Successful: the charge has been completed successfully! You should expect to see the errorCode field’s value set to 0 and txnStatus to 6.
b. Pending: the transaction is pending. In this case, the errorCode field’s value should be 431 and you should expect to receive a charge notification with the final status of the transaction.
c. Failed: the transaction has failed. You can refer to the error codes to understand the reason for the failure.

3. We will send you a charge notification to update you on the status of the transaction when it reaches a final state.

❗️Offer a free trial

Currently free trial is not an option we support using Rabbit Line Pay tokenized charge. If you wish to offer a free trial to your user, you might want to call the refund API after the charge.

Check a Subscription Status:
If you want to make sure you are allowed to make a charge for a given subscription you can make a POST call to /subscription/check. If the isChargeable field is set to true, that means it is possible to charge the user for that specific subscription. If the isChargeable field is set to false, that means you are not allowed to make the charge.
You can read more about possible resultCode values and failure scenarios in the API reference.

Check Charge Status
At any point in time, you can check a charge status by making a POST call to /subscription/inquiryPaymentResult. You can better understand the response by looking at the possible resultCode values and failure scenarios in the API reference.

Refund:
You can refund any previously successful charge by making a POST call to /subscription/refund. You can better understand the response by looking at the possible resultCode values and failure scenarios in the API reference.

6.1 GoPay API Reference

Initiate Subscription

This method collects user consent (authorization) and the subscription to their account.

Request Parameters


Sample Request

Request
{
   "apiKey": "06444450ae6ffee169b86ab68821688b",
   "orderId": "20191106143333",
   "lang": "en",
   "merchantName": "Koko eBooks",
   "payType": 5,
   "payChannel":223,
   "payProvider":108,
   "msisdn": "085781117382",
   "items": [
       {
           "code": "1",
           "name": "One Day",
           "price":1000
       }
   ],
    "iat":1585701733,
    "checksum":"9c3730c33e3d389f98e7c3e9ca369bff"
}

Response Parameters


Sample Response
{
   "txnInfo": {
       "txnId":"5754536975311000004",
       "txnStatus":6,
       "errorCode":0,
       "price":1000.0,
       "subscriptionId":"66"
   },
  "resultCode":0
}

Charge Notifications

Charge notifications are sent whenever you have made a charge and we are ready to update you on the status. We would send a notification similar to the one below to the URL you have provided to your support engineer:

HTTP
https://www.your-transaction-notify-url?TxnId=5754547328491000005&
OrderId=20191106143333&Price=1000.00&PaymentType=223&
ErrorCode=0&TxnStatus=6&SubscriptionId=166&
Checksum=545c4df9c8e3daefe8ea4c4b7d2c705c

Notifications can be sent when a charge has been successfully completed, is pending or has failed.

The parameters sent in the notification are like below

Subscription notifications:
Subscription notifications are sent when a subscription status changes, meaning whenever a user provides a new authorization or revokes an existing one.

When that happens, a notification similar to the one below to the URL you have provided to your support engineer. Note that the URL you provide for the Subscription notification needs to be different from the one you provide for Charge notifications.

HTTP

https://www.your-subscription-notify-url/?SubscriptionId=167&
PayChannel=240&PayProvider=117&ResultCode=0&
Price=1000.00&OrderId=1590025533149&IsChargeable=true&
SubscriptionStatus=2&Checksum=5e303a1f4965f10bc53465b3bed9c991

Notifications can be sent when a charge has been successfully completed, is pending or has failed.

The parameters sent in the notification are like below

Technical Constraints:
This section consists of various technical constraints to take into account:
Technical Constraints
For GoPay, transaction expiry time is 2 hours
GoPay only allows you to subscribe to each of the users to a single item only.

Result and Error Codes:
subscriptionStatus

SubscriptionStatus gives the current status of a given subscription whenever you are initiating, checking, cancelling a subscription or receiving a subscription notification.

Code
Meaning
0
Subscription initiation has failed
1
Subscription is pending authorization
2
Subscription initiation is successful
3
Subscription authorization has failed
5
Subscription has been cancelled

resultCode:
resultCode whether or not Coda was able to successfully process a request. It does not necessarily give the details of what went wrong, except in the exceptional case of 980. It usually means that subscription validation by Coda has failed.

Code
Meaning
0
Request was processed successfully
1
Request was not processed
980
User’s phone number has already been linked to GoPay Subscription. (This is only applicable to GoPay).
335
Subscription does not exist

txnStatus:
txnStatus gives the status of the transaction whenever a charge is made, checked or a charge notification is sent.

Code
Meaning
0
The transaction was not initiated
1
The transaction was only initiated
2
Transaction is at the checkout stage
3
Transaction is pending confirmation
4
Transaction is confirmed
5
??
6
Transaction is completed

errorCodes:
errorCodes gives more details if something went wrong while a charge is being made to GoPay. If the request is not processed by Coda (resultCode is not 0), then errorCode won’t be returned. If the request is successfully processed by Coda, then errorCode will be returned.

Code
Meaning
0
Request was successful
213
Transaction has expired
359
Technical error
403
Transaction has failed
414
Balance is insufficient
431
Transaction is pending
553
Refund has failed
555
Refund is pending

refundStatus:
refundStatus gives details on the refund status.

Code
Meaning
0
Refund was not initiated
2
Refund is pending
3
Refund is successful
4
Refund has failed