1. Make 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. Add Code Snippet in Launcher Intent
To display the Merchant application’s icon in the EDC Launcher Application, add the following category in <intent-filter> of the Launcher Activity of your application.
<category android:name="com.paytm.edc.launcher" />
Note :-
- The third-party app icon will not be visible on Production Paytm POS devices if this attribute is not included.
- Above category should be added along with MAIN action.
3. 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);
}
4. 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
5. 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.
Note: Paytm Team will provide the Printer SDK