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.
PayWithZeta can be integrated using the checkout flow. The details of the flow are described below.
The details of the typical checkout flow of the App2App payment support is described below:
User clicks on PayWithZeta option, shown on merchant page, to complete the payment.
When using Swipe to Pay,
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).
The App2App feature is available for Android and iOS platforms. The details of each method is described below.
Take care of following before you integrate Android and iOS apps:
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"); |
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”.
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.
For a merchant app named Starbucks, the custom URL scheme is |
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. |
|
|