Transfer Bank

Pre-request Script Example

var CryptoJS = require("crypto-js");
var moment = require("moment");
var navigator = {}; //fake a navigator object for the lib
var window = {}; //fake a window object for the lib
eval(postman.getGlobalVariable("jsrsasign-js")); //import javascript jsrsasign


const secretKey = pm.environment.get('SECRET_KEY');
const path = "/snap/v1.1/emoney/transfer-bank"
signRequest(pm.request, path)

pm.globals.set("trx_id",  _.random(1,99999999));


function signRequest(request, path) {

    const date = new Date().toISOString();
    const dateIso = moment(date).format('YYYY-MM-DDTHH:mm:ssZ') 
     pm.globals.set('X-TIMESTAMP', dateIso);
    
    console.log('date: ' + dateIso);
    const method = request.method;
    console.log('method: ' + method);
    console.log('path: ' + path);
    const body = request.body.raw;
    var jsonObject = JSON.parse(body);
    var minifyJsonObject = JSON.stringify(jsonObject, null, 0)
    console.log('minifyJsonObject: ' + minifyJsonObject);
    const bodyToHash = CryptoJS.SHA256(minifyJsonObject);
    // const bodySha256 = CryptoJS.enc.Base64.stringify(CryptoJS.SHA256(minifyJsonObject)).toLowerCase();
    const bodySha256 = bodyToHash.toString(CryptoJS.enc.Hex);
    const accessToken = pm.globals.get('ACCESS_TOKEN');
    console.log('access token :' + accessToken);
    console.log('bodySha256: ' + bodySha256);
    const data = `${method}:${path}:${accessToken}:${bodySha256}:${dateIso}`
    console.log('stringtosign: ' + data);

   const signatureHash =  createSignature(data, secretKey)
   console.log('signature :' + signatureHash);
    pm.globals.set("X-SIGNATURE", signatureHash);
    
}

function createSignature(rawData, secretKey){
    let signatureUtf8 = CryptoJS.enc.Utf8.parse(rawData);
    var secretUtf8 = CryptoJS.enc.Utf8.parse(secretKey);
    console.log("secretKey: " + secretKey);
    var signatureBytes = CryptoJS.HmacSHA512(signatureUtf8,secretUtf8);
    var requestSignatureBase64String = CryptoJS.enc.Base64.stringify(signatureBytes);
    return requestSignatureBase64String;
}

Transfer Bank

post
Header parameters
X-EXTERNAL-IDstringRequired

Numeric String. Reference number that should be unique in the same day (Request Id)

Example: 41807553358950093184162180797837
X-PARTNER-IDstringRequired

Client Id for merchant that generated by DOKU

Example: BRN-0240-1657686175289
X-SIGNATUREstringRequired

Symmetric Signature with Get Token (Default)HMAC_SHA512 (clientSecret, stringToSign) dengan formula stringToSign = HTTPMethod +”:“+ EndpointUrl +":"+ AccessToken +":“+ Lowercase(HexEncode(SHA-256(minify(RequestBody))))+ ":“ + TimeStamp

Example: ieNOENDdN4MnectGytx5UvmOfASZ2oGWMCJ8gVqkw3tB98ofgY9cbxSeY4IYoYeoKs+0QP4h8BTBhemlfeXp1w==
X-TIMESTAMPstringRequired

Client's current local time with format YYYY-MM-DDTHH:mm:ssZD

Example: 2020-12-21T14:56:11+07:00
CHANNEL-IDstringOptional

refers to a unique identifier for the channel or method used to initiate a payment transaction

Example: H2H
Body
partnerReferenceNostring · max: 64Required

Transaction identifier on service consumer system, generated by KD partners. Must be unique per request.

Example: hsjkans284b2he54
customerNumberstring · max: 32Required

Customer Account Number in Phone Number format

Example: 628115678890
beneficiaryAccountNumberstring · max: 32Required

Destination account number

Example: 8377388292
beneficiaryBankCodestringRequired

Bank code

Example: 014
sessionIdstring · max: 25Optional

Inquiry invoice id

Example: I0438729855304540
feeTypeany · max: 25Optional
Responses
200

Transfer bank processed

application/json
post
POST /snap/v1.1/emoney/transfer-bank HTTP/1.1
Host: api-sandbox.doku.com
X-EXTERNAL-ID: text
X-PARTNER-ID: text
X-SIGNATURE: text
X-TIMESTAMP: text
Content-Type: application/json
Accept: */*
Content-Length: 607

{
  "partnerReferenceNo": "hsjkans284b2he54",
  "customerNumber": "628115678890",
  "beneficiaryAccountNumber": "8377388292",
  "beneficiaryBankCode": "014",
  "amount": {
    "value": "200000.00",
    "currency": "IDR"
  },
  "sessionId": "I0438729855304540",
  "feeType": "",
  "additionalInfo": {
    "channelCode": "07",
    "beneficiaryFirstName": "FHILEA",
    "beneficiaryLastName": "HERMANUS",
    "beneficiaryPhoneNumber": "62811600174",
    "beneficiaryBankName": "Bank BCA",
    "beneficiaryAccountName": "FHILEA HERMANUS",
    "senderCountryCode": "ID",
    "senderFirstName": "JOHN",
    "senderLastName": "DOE",
    "senderPersonalId": "89012345",
    "senderPersonalIdType": "KTP",
    "remark": "Remark test"
  }
}
{
  "responseCode": 2004300,
  "responseMessage": "Successful",
  "referenceNo": "DK01123220",
  "partnerReferenceNo": "2020102900000000000001",
  "transactionDate": "2022-11-11T10:51:48+07:00",
  "referenceNumber": "39448581-c741-44f9-b3af-98616e2229b1",
  "additionalInfo": {
    "sessionId": "I0438729855304540",
    "amount": "200000.00"
  }
}

Last updated

Was this helpful?