Dinger

Developer / Staging API / Pay API

Pay API


Pass Payload

Filling params, passing payload and receiving response.

Pay API

{{baseurl}}api/pay

baseurl for staging - https://staging.dinger.asia/payment-gateway-uat/

Once receive the token from Dinger, merchant needs to initiate the payment API which needs to encrypt with public API key that is provided by Dinger.



Request

This API requests only one payload param(base64(rsa(obj)) string) in form body. Please be careful that items should be json format in string and ' single quotes are not allowed in json values. If you want to include ' single quotes, please include with '.


                                
// Other payment provider
val data = {
    "providerName": "AYA Pay", 
    "methodName": "QR", 
    "totalAmount" : 2200, 
    "orderId":  "11111", 
    "customerPhone" : "09787747310", 
    "customerName" : "test user name", 
    "items" : "[{‘name':'Mac','amount':'1100','quantity':'2'}]" 
 }
 
  // For Visa, Master and JCB
 val data = {
    "providerName": "AYA Pay", 
    "methodName": "QR", 
    "totalAmount" : 2200, 
    "orderId":  "11111", 
    "email": "[email protected]",
    "customerPhone" : "09787747310", 
    "customerName" : "test user name", 
    "state" : "customer state",
    "country" : "customer country", ** Must add 'code' value from Country Code List Enquiry API(/countryCodeListEnquiry) from Dinger **
    "postalCode" : "customer postal code",
    "billAddress" : "customer address",
    "billCity" : "customer city",
    "items" : "[{‘name':'Mac','amount':'1100','quantity':'2'}]" 
 }

 // transformation algorithm RSA/ECB/PKCS1Padding
 // publicKey will be provided by dinger)
 val encrypteDataWithRsa = rsa(jsonStrigify(data),publicKey)
 val payload = Base64.getEncoder().encodeToString(encrypteDataWithRsa)

Country Code List Enquiry API for Visa / Master / JCB

{{baseurl}}api/countryCodeListEnquiry


                                
{
    "code": "000",
    "message": "Request Success",
    "time": "20230109 103318",
    "response": [
        {
            "country": "Afghanistan",
            "code": "AF"
        },
        {
            "country": "Aland Islands",
            "code": "AX"
        }, ...
    ]
}

Code Sample

Payload encrypteDataWithRsa Example (RSA/ECB/PKCS1Padding)



                                    
import json
import base64
from Crypto.PublicKey import RSA
from Crypto.Hash import MD5
from Crypto.Signature import pkcs1_15
from Crypto.Cipher import PKCS1_OAEP

from Cryptodome.Cipher import PKCS1_v1_5
import os

class encrypt_rsa():

    
    def __init__(self, data):
        # replace with your public key
        public_key = ("-----BEGIN PUBLIC KEY-----\n"+
        "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCy7O9ULgdfc1SUXrU0W2qWg3l8VbvNpvq+ilwPDdq4EYzKwOe97Zd2wtW8HJQF7
GNn2SaeHLCilsAJTYPLb+uRzXz3Aozxx8u6Bk5mGMVqi9rXXCNQCpRZYgM/7JDvtO5UhLCiMFHFO2f2c0QCmdR+yzdP6anJk9vLikuBwWxY6wIDAQAB"+
        "\n-----END PUBLIC KEY-----")
        self.message = data.encode()
        self.public_key = RSA.import_key(public_key)


    # Segmentation encryption
    def encrypt(self):
        try:
            cipher_rsa = PKCS1_v1_5.new(self.public_key)
            res = []
            for i in range(0, len(self.message), 64):
                enc_tmp = cipher_rsa.encrypt(self.message[i:i+64])
                res.append(enc_tmp)
            cipher_text = b''.join(res)
        except Exception as e:
            print(e)
        else:
            return base64.b64encode(cipher_text).decode()


if __name__ == '__main__':

    payload = "{providerName: 'KBZ Pay',methodName: PWA,orderId: 'test-23112021001',customerPhone: '959796564600',
 description:'Test',customerAddress:'Yangon, Myanmar' ,totalAmount: 2200, email: '[email protected]',
 customerName: 'test username', items:'[{\"name\":\"Apple\",\"amount\":\"1100\",\"quantity\":\"2\"}]'}"

    payload_encrypt = encrypt_rsa(payload).encrypt()
    print(str(payload_encrypt))


Provider and Methods

Before using payment provider and methods, you need to click (ON) button on merchant dashboard payment settting page

Setting Page in Merchant Dashboard



Notes for Merchant Developers

There are mainly three types of payment providers

1. Rendering QR image and scan QR code by customers with respective payment wallet apps
2. Receiving notification on pay wallet apps and do payment
3. Redirecting respective payment provider's payment form on web (for this kinds of redirect payment, you'll receive formtoken value in pay api response and need to redirect properly. For redirecting reference, please see Section 2.5)


Payment Providers List

Provider Method Accept Decimal Amount Payment Flow
AYA pay QR,PIN No QR - scan QR
PIN - receives notification on AYA wallet
KBZ Pay QR , PWA Yes QR - scan QR
PWA - opens KBZ Pay app directly
Citizens Pay PIN No Citizens Pay form redirect
Wave Pay PIN No Wave Pay form redirect
MPU OTP Yes MPU Pay form redirect
Mytel PIN No Mytel Pay form redirect
Sai Sai Pay PIN No receives notification on Sai Sai Pay wallet
Onepay PIN No receives notification on Onepay wallet
MPitesan PIN No M-Pitesan form redirect
KBZ Direct Pay PWA Yes KBZ Mobile Banking web page redirect
Visa OTP Yes Visa form redirect
Master OTP Yes Master form redirect
MPU JCB Yes JCB form redirect
CB Pay QR Yes CB Pay QR form redirect
MAB Bank OTP Yes MAB Mobile Banking web page redirect
MPT Pay PIN Yes MPT Pay web page redirect
OK $ PIN Yes OK $ web page redirect
UAB Pay PIN No receives notification on UAB Pay wallet

Pay API Request Parameter

Name Type Length Mandatory Description Value
providerName String 20 Char Yes Name of the payment provider that the user chooses (see the list of provided provider name in Provider and Methods Table) AYA Pay
methodName String 20 Char Yes Name of the payment method that the user chooses (see the list of provided method name in Provider and Methods Table) QR, PIN , PWA
totalAmount Integer Yes The total amount of the order Min amount - 500 MMK, Max amount - 999999999 MMK
orderId String 50 Char Yes Unique ID for each order Eg- Order 001
description String No Cutomer order description Eg - call this number 095412313 before delivery
customerAddress String No Customer address Eg - No(70), Thukha street, ...
customerPhone String 50 Char Yes Mobile number of the customers Eg- 095412313
customerName String 50 Char Yes Customer name Eg- Mg Mg
Items String Json Array Yes Lists of the keys ( Name, Amount and Quantity) Remark: This amount should be same with total amount from above [{‘name':'Mac','amount':'1100','quantity':'2'}]
email String Yes (For Visa, Master and JCB) No (For other payment providers) Customer Email Eg- [email protected]
billAddress String Yes (For Visa, Master and JCB) No (For other payment providers) Billing Address Eg- No.70, Thukha street, ...
billCity String Yes (For Visa, Master and JCB) No (For other payment providers) Billing City Eg- Yangon
description String No Description or notes of the payment Eg- Buying Dinger Products
currency String 50 Char No Currency of the payment MMK, USD (When you do not add, default will be 'MMK')

HEADERS


    

Authorization Bearer {{paymentToken}}



BODY formdata


    

payload {payload}




                                    

curl --location --request POST '{{baseurl}}api/pay'
--header 'Authorization: Bearer {{paymentToken}}'
--form 'payload={payload}'


Form Redirect

Redirect to Dinger KBZ PAY PWA, KBZ Direct Pay, Wave Pay, Citizens and Mytel Gateway, MAB Bank, MPT Pay, OK$

Method

URL https://staging.dinger.asia/gateway/formCheckout?transactionNo={transactionNo}&formToken={formToken}&merchantOrderId={merchantOrderId}

Please note that form redirect url will be a little different when you move to production. Please refer to Production Api Documentation for production form redirect url when you test with production credentials.


Response



                                
{
 code: '000',
 message: 'Request Success',
 time: '20201224 103734',
 response: {
 amount: 200,
 merchOrderId: 'kothanzawlynn-172597',
 formToken: 'd9422446-2532-49de-8d0e-9db221bf0597',
 transactionNum: '9186115919',
 sign: '71005BCDDF3AF7968A504B64012B1E680145E5D4568C9ACB1ADBE0E2F4C4DAC1',
 signType: 'SHA256'
 }
}