AmazonPay S2S Tokenised Flow

Prerequisites

All prerequisites and authorization required for Amazonpay shall be completed by merchant

  • Account creation with Amazon Pay
  • Configure the credentials provided by Amazonpay on Juspay Dashboard and set the direct debit flag as true
  • Merchant’s App name and SHA256 key has to be whitelisted at Amazonpay end
  • The API key generated for the new secure profile created at Amazonpay has to be whitelisted at their end
  • Configure Juspay’s set of callback URLs at Amazonpay’s end for the Seller ID
  • sdkWalletIndentifier is necessary and needs to be configured by merchant before testing. Merchant can do this by creating and configuring their Seller ID on Amazon dashboard. Without sdkWalletIdentifier - testing will be blocked.
  • Configure Juspay webhooks - this is critical to get real time transaction status from Amazonpay.
  • Minimum SDK Version - Android version shall be equal to or greater than 2.0.4rc34. For iOS version shall be equal to or greater than 2.0.92

Dependencies - Android

Ensure that the following dependencies are added

dependencies {
 implementation 'in.juspay:amazonpay-silentpay-sdk:1.2.0'
 implementation 'in.juspay:amazonpay-hardened-silentpay-sdk:1.3.0'  
  
 implementation 'com.jakewharton.timber:timber:4.7.1'
 implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
 implementation 'androidx.work:work-runtime:2.7.1'
  
 implementation "androidx.browser:browser:1.3.0"
}

Dependencies - iOS

SDK dependencies for Amzonpay have already been added inside HyperSDK. Ensure the following things are done:

  • Add the following properties in your app's Info.plist file:
<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleURLName</key>
        <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>juspay-$(PRODUCT_BUNDLE_IDENTIFIER)</string>
            <string>amzn-$(PRODUCT_BUNDLE_IDENTIFIER)</string>
        </array>
    </dict>
</array>
  • Add your AmazonPay API key with the key name APIKey in the plist file.
  • Add the following code in the AppDelegate's application:openurl:options function if the project is not using SceneDelegate:
let juspayRegex = try? NSRegularExpression(pattern: "amzn-.*|juspay-.*", options: [])
if (juspayRegex?.numberOfMatches(in: url.absoluteString, options: [], range: NSRange(location: 0, length: url.absoluteString.count)) ?? 0) > 0 {
    return HyperServices.handleRedirectURL(url, sourceApplication: options[UIApplication.OpenURLOptionsKey.sourceApplication] as? String ?? "")
}
NSRegularExpression *juspayRegex = [NSRegularExpression regularExpressionWithPattern:@"amzn-.*|juspay-.*" options:0 error:nil];
if ([juspayRegex numberOfMatchesInString:[url absoluteString] options:0 range:NSMakeRange(0, [[url absoluteString] length])] > 0) {
    return [HyperServices handleRedirectURL:url sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey]];
}
  • For the project that is using SceneDelegate, add the following code in SceneDelegate’s scene:openURLContexts: function:
func scene(_ scene: UIScene, openURLContexts URLContexts: Set) {
    if let URLContext = URLContexts.first {
        if URLContext.url.absoluteString.contains("juspay-") || URLContext.url.absoluteString.contains("amzn-") {
            HyperServices.handleRedirectURL(URLContext.url, sourceApplication: URLContext.options.sourceApplication ?? "")
        }
    }
}
- (void)scene:(UIScene *)scene openURLContexts:(NSSet<UIOpenURLContext *> *)URLContexts {
    UIOpenURLContext *URLContext = [URLContexts allObjects].firstObject;
    if (URLContext && URLContext.URL && ([URLContext.URL.absoluteString containsString:@"juspay-"] || [URLContext.URL.absoluteString containsString:@"amzn-"])) {
        [HyperServices handleRedirectURL:URLContext.URL sourceApplication:URLContext.options.sourceApplication];
    }
}

User Experience

  • Link transaction : The user will be redirected to Amazonpay login page on Chrome custom tab/ CCT. The user shall login into Amazon Pay account and successfully link Amazon Pay wallet and land on the payment page
  • Pay (with sufficient balance): The Amazonpay wallet balance will be displayed to the user on the payment page. If the funds are sufficient to complete the transaction, the amount will be automatically debited
  • Pay (with insufficient balance): If the funds are insufficient to complete the transaction, the user will be redirected to Amazonpay page, where he can pay the balance amount using a payment instrument of choice