- Created by user-8f2bd, last modified on Oct 04, 2018
Introduction
App2App payment support for Pay With Zeta (PWZ) eases the process of getting customer’s authorization on e-commerce mobile apps by overlaying a Swipe to Pay option, thereby avoiding the 2-step authentication process which consumes time in events of high frequency of payments.
Merchant partners can now seamlessly get customer’s consent for an intended payment directly within the mobile app ecosystem where the complexity of payment handling and user authentication are safely handled by the App2App payment support, allowing the merchants to only focus on accepting online payment from Zeta users.
Integration Method
PayWithZeta can be integrated using the checkout flow. The details of the flow are described below.
Checkout Flow
The details of the typical checkout flow of the App2App payment support is described below:
- User adds items to the cart on the merchant e-commerce app and goes to the checkout page.
User clicks on PayWithZeta option, shown on merchant page, to complete the payment.
- The merchant app shares the payment details (as per the Request app2app authorization API contract mentioned below) with the Zeta app installed on the same device.
- The Zeta app gets the customer’s authorization by overlaying a Swipe to Pay option.
When using Swipe to Pay,
- If the customer swipes to authorize the payment, Zeta app will respond back to the merchant to the callback URL shared by the merchant app in step 3.
- If the customer denies the authorization, Zeta app will return the Error payload mentioned below.
Once the merchant app gets the user’s consent (when user authorizes payment in step 5(a)), merchant will get the payment charged by making a server to server API call (ref contract Charge a transaction with Auth API).
Mobile OS Integration
The App2App feature is available for Android and iOS platforms. The details of each method is described below.
Before You Begin
Take care of following before you integrate Android and iOS apps:
- For Android integration, ensure that the Zeta app version is 3.12.25.1 or greater, as this feature does not work on older versions (App version can be found in About Us screen).
- For iOS integration, ensure that the Zeta app version is greater than 2.11.0, as this feature doesn't work on lesser versions.
Android Integration
Request and response for the Android version of app takes place through Intents (a messaging object used to request an action). Upon a request, intents start an activity for Swipe to Pay authorization and will emit a success/failure state of the authorization as activity result.
Please follow below steps for integration:
When payment authorization is needed, create the following intent:
Intent intent = new Intent(Intent.ACTION_VIEW, "zetapay://payAuth");
- Prepare the request payload. Convert it to JSON and pass it in the intent.
Add the request payload to the intent, with the key as “data”.
intent.putExtra("data", payload);
Check if the intent can be handled.
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("zetapay://payAuth")); PackageManager packageManager = getPackageManager(); if (intent.resolveActivity(packageManager) != null) { //Success - app is present and this version of Zeta app can handle the intent intent.setPackage("in.zeta.android"); //Package name for staging - "in.zeta.android.debug" //Package name for production - "in.zeta.android" intent.putExtra("data", gson.toJson(paymentRequest)); startActivityForResult(intent, REQUEST_CODE); } else { //Failure - Zeta app not found/Zeta app is not up to date }
The intent cannot be found in the older versions of the app.
Start the activity to see if the intent can be handled, as specified above.
startActivityForResult(intent, REQUEST_CODE);
On a valid request, swipe to pay screen is launched. On invalid request, the error callback intent is sent as result.
If authorization is successful, activity result is Activity.RESULT_OK, along with the success response payload(JSON) as an intent extra with key “data”.
iOS Integration
Please follow below steps for integration:
Zeta app should be invoked for user’s authorization by invoking a Zeta app URL of the following format:
zetapay://payAuth?req=<json string>
The above Zeta app URL is invoked by the openUrl method.
Before calling the openUrl method, you must ensure if the above URL can be handled by the user’s device with the help of canOpenUrl method.
If the canOpenUrl method returns NO, you must not attempt to invoke the URL and must instead use some other fallback mechanism to complete the payment flow.
Generate
<json string>
which is an encoded string version of the request payload using the below code:NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dict options:kNilOptions error:NULL]; NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; jsonString = [string stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet alphanumericCharacterSet]];
You must define a custom URL scheme for the callBackUrl, which must be present in the request payload.
Example
For a merchant app named Starbucks, the custom URL scheme is
starbucks://
and the callBackUrl sent in the request payload isstarbucks://zetaAuth.
You must handle callBackUrl invocation by the Zeta app through the App Delegate. Success or failure authorization will be depicted using query parameter in the callBackUrl as shown below:
<callBackUrl>?resp=<json string><callBackUrl>?error=<json string>
Convert
<json string>,
which is a string encoded version of the response payload, to a proper NSDictionary object using the below code:https://gist.github.com/apurva14/3016b988056343a603711ffc79e1c3a4
Download and install Zeta Staging app through TestFlight to test out these features. We will send out invitations to apple ids of iOS developers, for accessing the TestFlight build.
FAQs
Intents are messaging objects used to request an action, through which requests and responses take place for the Android app. Upon a request, intents will start an activity for swipe to pay authorization and will emit a success/failure state of the authorization as activity result.
If immediate refunds are not honoured, a CRON (running every one hour) will reverse the transaction. If in rare cases, the refund cannot be honoured, then the refund will get dropped after n configurable number of attempts (currently 30) and the customer will be refunded in 3 days.
For Android: Zeta app version must be 3.12.25.1 or greater.
For iOS: Zeta app app version must be greater than 2.11.0
The transaction will not be terminated. User will be redirected to web app for completing the transaction.
Timeout period is 30 seconds.
The user is directly prompted to swipe2pay and then prompt for PIN if needed, without the need to go to Zeta app at all.
You should send the request to the server within 5 minutes of receiving the authorisation payload from user app.
On this page: