You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can use the APIs below to interface with DANA's MerchantManagementApi API.
To start using the API, you need to destruct instantiated DANA client. This client would be a singleton object that you can use across various api and operation.
import{Dana}from'dana-node';constdanaClient=newDana({partnerId: "YOUR_PARTNER_ID",// process.env.X_PARTNER_IDprivateKey: "YOUR_PRIVATE_KEY",// process.env.X_PRIVATE_KEYorigin: "YOUR_ORIGIN",// process.env.ORIGINenv: "sandbox",// process.env.DANA_ENV or process.env.ENV or "sandbox" or "production"clientSecret: "YOUR_CLIENT_SECRET",// process.env.X_CLIENT_SECRET});const{ merchantManagementApi }=danaClient;
Query member asset cards filtered by contact business type and asset type. JSON envelope uses `request.head`, `request.body`, and root `signature` (same Open API pattern as other `.htm` endpoints).
Query merchant profile information by login identifier (for example mobile number). JSON envelope uses `request.head`, `request.body`, and root `signature` (same Open API pattern as other `.htm` endpoints).
import{Dana}from'dana-node';import{CreateDivisionRequest,CreateDivisionResponse}from'dana-node/merchant_management/v1';constdanaClient=newDana({partnerId: "YOUR_PARTNER_ID",// process.env.X_PARTNER_IDprivateKey: "YOUR_PRIVATE_KEY",// process.env.X_PRIVATE_KEYorigin: "YOUR_ORIGIN",// process.env.ORIGINenv: "sandbox",// process.env.DANA_ENV or process.env.ENV or "sandbox" or "production"clientSecret: "YOUR_CLIENT_SECRET",// process.env.X_CLIENT_SECRET});const{ merchantManagementApi }=danaClient;constrequest: CreateDivisionRequest={// Define the request parameters for the API call here};constresponse: CreateDivisionResponse=awaitmerchantManagementApi.createDivision(request);
import{Dana}from'dana-node';import{CreateShopRequest,CreateShopResponse}from'dana-node/merchant_management/v1';constdanaClient=newDana({partnerId: "YOUR_PARTNER_ID",// process.env.X_PARTNER_IDprivateKey: "YOUR_PRIVATE_KEY",// process.env.X_PRIVATE_KEYorigin: "YOUR_ORIGIN",// process.env.ORIGINenv: "sandbox",// process.env.DANA_ENV or process.env.ENV or "sandbox" or "production"clientSecret: "YOUR_CLIENT_SECRET",// process.env.X_CLIENT_SECRET});const{ merchantManagementApi }=danaClient;constrequest: CreateShopRequest={// Define the request parameters for the API call here};constresponse: CreateShopResponse=awaitmerchantManagementApi.createShop(request);
import{Dana}from'dana-node';import{QueryAssetCardListRequest,QueryAssetCardListResponse}from'dana-node/merchant_management/v1';constdanaClient=newDana({partnerId: "YOUR_PARTNER_ID",// process.env.X_PARTNER_IDprivateKey: "YOUR_PRIVATE_KEY",// process.env.X_PRIVATE_KEYorigin: "YOUR_ORIGIN",// process.env.ORIGINenv: "sandbox",// process.env.DANA_ENV or process.env.ENV or "sandbox" or "production"clientSecret: "YOUR_CLIENT_SECRET",// process.env.X_CLIENT_SECRET});const{ merchantManagementApi }=danaClient;constrequest: QueryAssetCardListRequest={// Define the request parameters for the API call here};constresponse: QueryAssetCardListResponse=awaitmerchantManagementApi.queryAssetCardList(request);
import{Dana}from'dana-node';import{QueryDivisionRequest,QueryDivisionResponse}from'dana-node/merchant_management/v1';constdanaClient=newDana({partnerId: "YOUR_PARTNER_ID",// process.env.X_PARTNER_IDprivateKey: "YOUR_PRIVATE_KEY",// process.env.X_PRIVATE_KEYorigin: "YOUR_ORIGIN",// process.env.ORIGINenv: "sandbox",// process.env.DANA_ENV or process.env.ENV or "sandbox" or "production"clientSecret: "YOUR_CLIENT_SECRET",// process.env.X_CLIENT_SECRET});const{ merchantManagementApi }=danaClient;constrequest: QueryDivisionRequest={// Define the request parameters for the API call here};constresponse: QueryDivisionResponse=awaitmerchantManagementApi.queryDivision(request);
import{Dana}from'dana-node';import{QueryMerchantInfoRequest,QueryMerchantInfoResponse}from'dana-node/merchant_management/v1';constdanaClient=newDana({partnerId: "YOUR_PARTNER_ID",// process.env.X_PARTNER_IDprivateKey: "YOUR_PRIVATE_KEY",// process.env.X_PRIVATE_KEYorigin: "YOUR_ORIGIN",// process.env.ORIGINenv: "sandbox",// process.env.DANA_ENV or process.env.ENV or "sandbox" or "production"clientSecret: "YOUR_CLIENT_SECRET",// process.env.X_CLIENT_SECRET});const{ merchantManagementApi }=danaClient;constrequest: QueryMerchantInfoRequest={// Define the request parameters for the API call here};constresponse: QueryMerchantInfoResponse=awaitmerchantManagementApi.queryMerchantInfo(request);
import{Dana}from'dana-node';import{QueryMerchantResourceRequest,QueryMerchantResourceResponse}from'dana-node/merchant_management/v1';constdanaClient=newDana({partnerId: "YOUR_PARTNER_ID",// process.env.X_PARTNER_IDprivateKey: "YOUR_PRIVATE_KEY",// process.env.X_PRIVATE_KEYorigin: "YOUR_ORIGIN",// process.env.ORIGINenv: "sandbox",// process.env.DANA_ENV or process.env.ENV or "sandbox" or "production"clientSecret: "YOUR_CLIENT_SECRET",// process.env.X_CLIENT_SECRET});const{ merchantManagementApi }=danaClient;constrequest: QueryMerchantResourceRequest={// Define the request parameters for the API call here};constresponse: QueryMerchantResourceResponse=awaitmerchantManagementApi.queryMerchantResource(request);
import{Dana}from'dana-node';import{QueryShopRequest,QueryShopResponse}from'dana-node/merchant_management/v1';constdanaClient=newDana({partnerId: "YOUR_PARTNER_ID",// process.env.X_PARTNER_IDprivateKey: "YOUR_PRIVATE_KEY",// process.env.X_PRIVATE_KEYorigin: "YOUR_ORIGIN",// process.env.ORIGINenv: "sandbox",// process.env.DANA_ENV or process.env.ENV or "sandbox" or "production"clientSecret: "YOUR_CLIENT_SECRET",// process.env.X_CLIENT_SECRET});const{ merchantManagementApi }=danaClient;constrequest: QueryShopRequest={// Define the request parameters for the API call here};constresponse: QueryShopResponse=awaitmerchantManagementApi.queryShop(request);
import{Dana}from'dana-node';import{UpdateDivisionRequest,UpdateDivisionResponse}from'dana-node/merchant_management/v1';constdanaClient=newDana({partnerId: "YOUR_PARTNER_ID",// process.env.X_PARTNER_IDprivateKey: "YOUR_PRIVATE_KEY",// process.env.X_PRIVATE_KEYorigin: "YOUR_ORIGIN",// process.env.ORIGINenv: "sandbox",// process.env.DANA_ENV or process.env.ENV or "sandbox" or "production"clientSecret: "YOUR_CLIENT_SECRET",// process.env.X_CLIENT_SECRET});const{ merchantManagementApi }=danaClient;constrequest: UpdateDivisionRequest={// Define the request parameters for the API call here};constresponse: UpdateDivisionResponse=awaitmerchantManagementApi.updateDivision(request);
import{Dana}from'dana-node';import{UpdateShopRequest,UpdateShopResponse}from'dana-node/merchant_management/v1';constdanaClient=newDana({partnerId: "YOUR_PARTNER_ID",// process.env.X_PARTNER_IDprivateKey: "YOUR_PRIVATE_KEY",// process.env.X_PRIVATE_KEYorigin: "YOUR_ORIGIN",// process.env.ORIGINenv: "sandbox",// process.env.DANA_ENV or process.env.ENV or "sandbox" or "production"clientSecret: "YOUR_CLIENT_SECRET",// process.env.X_CLIENT_SECRET});const{ merchantManagementApi }=danaClient;constrequest: UpdateShopRequest={// Define the request parameters for the API call here};constresponse: UpdateShopResponse=awaitmerchantManagementApi.updateShop(request);
Enum Types
In Node.js, enums are located within each model class rather than being centralized in a separate enum file. Each enum is named after its parent model.
For example, to use the sizeType enum from ShopResourceInfo:
import{ShopResourceInfoSizeTypeEnum}from'dana-node/merchant_management/v1';// Use the enum valueconstsizeType=ShopResourceInfoSizeTypeEnum.Umi;
In this example the ShopResourceInfo is the parent model and SizeType is the enum name. In below list, the enums are listed in format of {ParentModel}{EnumName} (Enum Field).
This document explains how to use the WebhookParser utility from the `` SDK to securely verify and parse webhook notifications sent by DANA.
Example
import{WebhookParser}from'dana-node/webhook/v1';// Adjust import path as needed// Assuming you are in an Express.js route handler or similar framework context.// If using Express, you might import types like this:// import { Request, Response } from 'express';// Example route handler for DANA webhooks.// Replace `AnyRequestType` and `AnyResponseType` with types from your web framework (e.g., Express's Request, Response).asyncfunctionhandleDanaWebhook(req: AnyRequestType,res: AnyResponseType){// Retrieve the DANA public key from environment variables or a secure configuration.// Option 1: Public key as a stringconstdanaPublicKeyString: string|undefined=process.env.DANA_PUBLIC_KEY;// Option 2: Path to the public key file (recommended for production)constdanaPublicKeyPath: string|undefined=process.env.DANA_PUBLIC_KEY_PATH;if(!danaPublicKeyString&&!danaPublicKeyPath){console.error('DANA webhook public key not configured.');res.status(500).send('Webhook processor configuration error.');// Or appropriate error handlingreturn;}// Extract necessary data from the request objectconsthttpMethod: string=req.method!;// e.g., "POST"constrelativePathUrl: string=req.path!;// e.g., "/v1.0/debit/notify". Ensure this is the path DANA signs.// req.headers is typically an object like { 'header-name': 'value' }.// The WebhookParser expects Record<string, string>.// Node's IncomingHttpHeaders can have string[] for values, but X-SIGNATURE and X-TIMESTAMP// are expected to be single strings. Casting or careful handling might be needed.constheaders: Record<string,string>=req.headersasRecord<string,string>;// The body needs to be the raw JSON string.// If you're using a body-parsing middleware (e.g., express.json()),// req.body might already be a parsed JavaScript object.// The WebhookParser expects the raw string body that was signed.letrequestBodyString: string;if(typeofreq.body==='string'){requestBodyString=req.body;}elseif(req.body&&typeofreq.body==='object'){// If req.body is an object, it means middleware parsed it.// We need to stringify it back to pass to the parser,// assuming this stringified version matches what DANA signed.// IMPORTANT: This assumes JSON.stringify(parsedBody) is equivalent to the raw body DANA sent.// For robust parsing, it's best to get the raw body *before* any JSON parsing middleware,// e.g., using `express.raw({ type: 'application/json' })` for specific routes.requestBodyString=JSON.stringify(req.body);}else{console.error('Request body is not a string or a parseable object.');res.status(400).send('Invalid request body format.');return;}// Initialize WebhookParser.// The constructor prioritizes publicKeyPath if both are provided.constparser=newWebhookParser(danaPublicKeyString,danaPublicKeyPath);try{// Verify the signature and parse the webhook payloadconstfinishNotify=parser.parseWebhook(httpMethod,relativePathUrl,headers,requestBodyString);console.log('Webhook verified successfully:');console.log('Original Partner Reference No:',finishNotify.originalPartnerReferenceNo);// TODO: Process the finishNotify object (e.g., update order status in your database)res.status(200).send('Webhook received and verified.');}catch(error: any){// Catching as 'any' to access error.messageconsole.error('Webhook verification failed:',error.message);// Respond with an error status. DANA might retry if it receives an error.res.status(400).send(`Webhook verification failed: ${error.message}`);}}
publicKey (string, optional): The DANA gateway's public key as a PEM formatted string. This is used if publicKeyPath is not provided or is empty.
publicKeyPath (string, optional): The file path to the DANA gateway's public key PEM file. If provided, this will be prioritized over the publicKey string.
One of publicKey or publicKeyPath must be provided.