Please download the sample app for NCMC API usage example as well as Printer SDK integration for generating custom receipts.
[NCMC] Integration via App Invoke
Sample App
Integration Steps
1. Changes in Manifest
Once the user completes the payment, you can receive the payment results from the payments App by making the following changes in the manifest:
- Define launchMode of the Activity(from where EDC App is started through DeepLink) as singleTask in Manifest.
- Define an IntentFilter with Custom Action and Default Category as defined below (this custom action should uniquely identify your activity in your package).
<activity
android:name=".DeepLinkV2Activity"
android:label="@string/title_activity_deeplink_v2"
android:launchMode="singleTask"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="com.paytm.pos.payment.CALL_BACK_RESULT" />
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
2. Send Payment Request
Complete the transaction by invoking the payments app with the following payment request.
String EDC_PACKAGE = "com.paytm.pos"; // If you are using Debug EDC App then
// Use “com.paytm.pos.debug”
String packageName = getPackageName(); // Package name of your Application
String PAY_DEEP_LINK = “sampledeeplink://payment”; // It should be different for
// different operations :-Payment, Status & Void
String callbackAction = “com.paytm.pos.payment.CALL_BACK_RESULT”; //This action
// is same as defined in the manifest file, if this field is null then
// you will get the result in Launcher Activity of your application
String orderId = “123456789”; // Make sure this is unique for every payment
String payMode = “All”; // Possible values are “CARD”, “QR” & “ALL”, this field is optional
String amount = “1200”; //1200 means ₹12.00, last two digits are for paise
String param1 = “val1”; // Optional additional parameter, which if sent in request will be
// returned as it is in response. There can be any number of
// additional parameters, and their name can be anything, but
// make sure their name does not match with any of the
// Pre-Defined parameters(which will be described later)
String param2 = “val2”; // Optional additional parameter
String subWalletInfo = "FOOD:2000|GIFT:3000" // Optional Parameter for payment through
// Different types of Paytm wallets, only
// applicable for QR Payments
// Amounts are in Paise.
String printInfo = "Merchanttxnid:82938938983|CaNumber:34567777|BillNumber:xyz123"
// printInfo parameter can be used to pass any numbers of extra parameters(key, value pairs) in request which needs to be printed on receipt.
// The printInfo parameter should be in a valid uri form and merchants can add any no of key, value pairs in query in the uri.
// Key and Value both should be of String type
String gstIn = "08TESTF0078P1ZP"; // Mandatory parameter for GST information
String gstBrkUp = "CGST:100|SGST:100|IGST:100|CESS:100|GSTIncentive:100|GSTPCT:100"; // Mandatory parameter for GST info, format should be same where each break-up portion should be
// separated by '|', and within each break-up portion name and value should be separated by ':'
String gstInvoiceDate = "20210517132020"; // Mandatory parameter for GST info, format should be yyyyMMddHHmmss
String gstInvoiceNo = "Invoice3423432155555"; // Mandatory parameter for GST info
String deepLink = "paytmedc://paymentV2?" + "callbackAction=" + callBackAction + "&stackClear=true" + "&callbackPkg=” + packageName + “&callbackDl=” + PAY_DEEP_LINK + “&requestPayMode=” + payMode + “&orderId=” + orderId + “&amount=” + amount + “¶m1=” + param1 + “¶m2=” + param2 + “&subWalletInfo=” + subWalletInfo + “&printInfo=” + printInfo
+"&gstIn=" + gstIn + "&gstBrkUp=" + gstBrkUp + "&gstInvoiceDate=" + gstInvoiceDate + "&gstInvoiceNo=" + gstInvoiceNo;
Intent launchIntent = getPackageManager().getLaunchIntentForPackage(EDC_PACKAGE);
if (launchIntent != null) {
launchIntent.putExtra("deeplink", deepLink);
startActivity(launchIntent);
}
3. Receive Payment Result
Finally, the merchant’s app needs to process the payment result returned by the Payments App.
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
if (intent != null && intent.hasExtra("deeplink")) {
String dl = intent.getStringExtra("deeplink");
Uri uri = Uri.parse(dl);
switch (uri.getHost()) {
case “payment”:
String amount = uri.getQueryParameter("amount");
String orderId = uri.getQueryParameter("orderId");
String status = uri.getQueryParameter("status");
// Process Payment result
break;
}
}
}
// If launchMode of your Activity is not “singleTask”, then a new instance of your
// activity will be created and you will get the result in onCreate() method instead of
// onNewIntent() method
4. Optional: Integrate Printer SDK
You can use this SDK for customised receipts. Customised receipts can be printed from the merchant application using the printer which is embedded in the Paytm POS Machine. Please see the sample project for printer sdk integration.
Sample Requests and Responses
Following are three sample requests and responses:
- Sample Payment Request and Responses (DeepLink : paytmedc://paymentV2)
- Sample Status Check Request and Responses (DeepLink : paytmedc://txnStatusV2)
- Sample Void Transaction request and responses (DeepLink : paytmedc://voidV2)
1. Sample Payment Request and Responses
DeepLink : paytmedc://paymentV2
Use Case : To initiate payment request from EDC app.
Note: To check the sample requests and responses, click on +.
- Sample 1
Request
paytmedc://paymentV2?callbackAction=com.paytm.pos.payment.CALL_BACK_RESULT&stackClear=false&callbackPkg=com.paytm.sampledeeplinkapp&callbackDl=sampledeeplink://payment&amount=100&orderId=123456&requestPayMode=all¶m1=a¶m2=b&subWalletInfo=FOOD:2000|GIFT:3000&completeOrderTimeout=30&printInfo=MerchantTxnId:82938938983|CaNumber:34567777|BillNumber:xyz123&gstIn=08TESTF0078P1ZP&gstBrkUp=CGST:100|SGST:100IGST:100|CESS:100|GSTIncentive:100|GSTPCT:100&gstInvoiceNo=Invoice3423432155555&gstInvoiceDate=20210517132020
Response
sampledeeplink://payment?amount=200&RRN=000011386118&txnid=20201229111212800100168512000623512&stan=000022&status=SUCCESS&orderId=123456&responsePayMode=EMI&cardType=CREDIT&txnDate=29%20Dec%202020%2C%2006%3A19%3A29%20PM&authCode=000166&tid=12349162&aid=A0000000031010&cardScheme=VISA&bankResponseCode=00&bankMid=5PT000000000878&bankTid=5P004052&emiTxnType=bank&emiTenure=12&emiInterestRate=5.0&emiMonthlyAmount=17&emiTotalAmount=204&bankOfferApplied=false&subventionCreated=false&acquiringBank=ICICI
- Sample 2
- Sample 3
- Failed response
2. Sample Status Check Request and Responses
DeepLink : paytmedc://txnStatusV2
Use Case : It gives the status of a particular transaction initiated via the EDC app. If the merchant app has not received any callback for any transaction (due to app crash like rare scenarios), this deeplink can be invoked to get the status of that txn.
Note: To check the sample requests and responses, click on +.
- Sample 1
Request
paytmedc://txnStatusV2?callbackAction=com.paytm.pos.payment.CALL_BACK_RESULT&stackClear=true&callbackPkg=com.paytm.sampledeeplinkapp&callbackDl=sampledeeplink://txnStatus&orderId=54323¶m1=sd¶m2=df
Response
sampledeeplink://txnStatus?amount=200&RRN=null&txnid=null&stan=000020&status=SUCCESS&cardNo=&orderId=54323&responsePayMode=null&cardType=null&acquirer=null¶m1=sd¶m2=df
- Sample 2
- Sample 3
3. Sample Void Transaction request and responses
DeepLink : paytmedc://voidV2
Use Case : This service is called for reversing the amount to customer’s source payment mode.
- Sample 1
Request
paytmedc://voidV2?callbackAction=com.paytm.pos.payment.CALL_BACK_RESULT&stackClear=true&callbackPkg=com.paytm.sampledeeplinkapp&callbackDl=sampledeeplink://void&orderId=54323¶m1=add¶m2=ggg&callbackIsService=false
Response
sampledeeplink://void?status=SUCCESS&amount=200&orderId=54323¶m1=add¶m2=ggg
- Sample 2
- Sample 3