---
page_source: https://juspay.io/in/docs/amazonpay/docs/amazon-pay-balance/enable-amazon-pay
page_title: Enable Amazon Pay
---


# Adding the Amazon Pay flow




### **Step 3:** Enable Amazonpay flow on your payment page



---

## Integration type : Juspay HyperCheckout (Payment Page)


### 3.1 Juspay Enablements


* Juspay will send the URLs that needs to be whitelisted at Amazon end for both sandbox and production environment and enable the necessary configuration required at our end and release to CUG environment for testing.




### 3.2 Upgrade Juspay SDK / Add dependencies


**Android:** 

Ensure that the Juspay Hyper SDK version integrated at your end is the [most recent SDK version](https://juspay.io/in/docs/resources/docs/sdk--release-notes/android--release-notes). Please update the SDK version if lower version is used currently. 

* Minimum Juspay Hyper SDK version required: 2.2.5
* No dependencies need to be added to the code since our SDK handles this from version 2.2.5 and more
* **SDK version:**  Refer to the release notes for the most recent SDK version [here](https://docs.juspay.in/resources/docs/sdk--release-notes/android--release-notes).

**iOS:** 

* **SDK version:**  Refer to the release notes for the most recent SDK version [here](https://juspay.io/in/docs/resources/docs/sdk--release-notes/ios--release-notes).
* The HyperAPay version is tied to the version of your iOS Hyper SDK. If you're using the latest SDK version (2.2.5), the corresponding HyperAPay version should also be 2.2.5.
* SDK dependencies for Amazonpay can be added by the following pod:
  
  
  #### Podfile Code Snippet:
  
  ```podfile
  pod 'HyperAPay', '2.2.5'
  
  ```
* Add the following properties in your app's Info.plist file: 
  
  
  #### info.plist Code Snippet:
  
  ```info.plist
  <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 the following code in the AppDelegate's **application:openurl:options**  function if the project is not using SceneDelegate:
  
  
  #### Swift Code Snippet:
  
  ```swift
  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 ?? "")
  }
  ```
  
  #### Objective-C Code Snippet:
  
  ```objective-c
  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:
  
  
  #### Swift Code Snippet:
  
  ```swift
  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 ?? "")
          }
      }
  }
  ```
  
  #### Objective-C Code Snippet:
  
  ```objective-c
  - (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];
      }
  }
  ```




### 3.3 Adding of APIKey.txt file in Android and iOS


Please follow the below steps to obtain the APIKey from the Amazon Dashboard and add in your project files.[https://docs.amazonpay.amazon.in/documentation.html?documentationUrl=/content/ap-balance/section1/setup_client_side_api_keys/](https://docs.amazonpay.amazon.in/documentation.html?documentationUrl=/content/ap-balance/section1/setup_client_side_api_keys/)




### Step 1.1. Note


* No payload changes are required while opening the Juspay HyperCheckout Payment Page




### 3.4 Consume updated payment response


* Backend changes are required on your end to handle Amazonpay transaction related webhook requests and order status responses.
  
  * [Order Status response](https://juspay.io/in/docs/amazonpay/docs/amazon-pay-balance/order-status)
  * [Webhooks](https://juspay.io/in/docs/amazonpay/docs/amazon-pay-balance/webhooks)




### 3.5 Managing Amazonpay Wallet


* To provide users with the option to unlink their linked AmazonPay wallet,  paymentManagement flow can be used.



---

## Integration type : Juspay Express Checkout SDK


### 3.1 Juspay Enablements


* Juspay will send the URLs that needs to be whitelisted at Amazon end for both sandbox and production environment




### 3.2 Upgrade Juspay SDK / Add dependencies


**Android:** 

Ensure that the Juspay Hyper SDK version integrated at your end is the [most recent SDK version](https://juspay.io/in/docs/resources/docs/sdk--release-notes/android--release-notes). Please update the SDK version if lower version is used currently.

* Minimum Juspay Hyper SDK version required: 2.2.5
* No dependencies need to be added to the code since our SDK handles this from version 2.2.5 and more
* **SDK version:**  Refer to the release notes for the most recent SDK version [here](https://docs.juspay.in/resources/docs/sdk--release-notes/android--release-notes).

**iOS:** 

* **SDK version:**  Refer to the release notes for the most recent SDK version [here](https://juspay.io/in/docs/resources/docs/sdk--release-notes/ios--release-notes).
* The HyperAPay version is tied to the version of your iOS Hyper SDK. If you're using the latest SDK version (2.2.5), the corresponding HyperAPay version should also be 2.2.5.
* SDK dependencies for Amazonpay can be added by the following pod:
  
  
  #### Podfile Code Snippet:
  
  ```podfile
  pod 'HyperAPay', '2.2.5'
  
  ```
* Add the following properties in your app's Info.plist file: 
  
  
  #### info.plist Code Snippet:
  
  ```info.plist
  <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 the following code in the AppDelegate's **application:openurl:options**  function if the project is not using SceneDelegate:
  
  
  #### Swift Code Snippet:
  
  ```swift
  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 ?? "")
  }
  ```
  
  #### Objective-C Code Snippet:
  
  ```objective-c
  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:
  
  
  #### Swift Code Snippet:
  
  ```swift
  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 ?? "")
          }
      }
  }
  ```
  
  #### Objective-C Code Snippet:
  
  ```objective-c
  - (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];
      }
  }
  ```




### 3.3 Adding of APIKey.txt file in Android and iOS


Please follow the below steps to obtain the APIKey from the Amazon Dashboard and add in your project files.[https://docs.amazonpay.amazon.in/documentation.html?documentationUrl=/content/ap-balance/section1/setup_client_side_api_keys/](https://docs.amazonpay.amazon.in/documentation.html?documentationUrl=/content/ap-balance/section1/setup_client_side_api_keys/)




### 3.4  RefreshWalletBalances


* Use the [Refresh Wallet SDK Call](https://juspay.io/in/docs/amazonpay/docs/amazon-pay-balance/refresh-wallet-sdk-call) call to check if the user is already linked the Amazonpay Wallet or fetch the wallet balance if already linked.
* If Amazonpay not linked: 
  
  * If the Amazonpay response is not received or the `linked` parameter within Amazonpay block is `false` in the response, display Amazonpay wallet with the **Link**  CTA.
  * When user clicks on the Link CTA proceed to C**reate Wallet**  step.
* If Amazonpay linked already:
  
  * If the Amazonpay wallet is linked already, the parameter `linked:true` will be received for Amazonpay wallet. The `balance` parameter can be consumed to display the Amazonpay wallet with balance and **Pay Now / Proceed to Pay**  CTA.
  * When user clicks on **Pay Now / Proceed to Pay**  CTA proceed to **Wallet Transaction**  step.




### 3.5 Create Wallet 


* Use the [Create Wallet SDK call](https://juspay.io/in/docs/amazonpay/docs/amazon-pay-balance/amazonpay-create-wallet-sdk-call) to initiate the wallet linking flow for the user.
* Android:
  
  * If the amazon app is present in the device with the account logged in, the app will be invoked to link the user.
  * If the amazon app is not present, then the user will be redirected to Amazon page in chrome tab to link the wallet.
* iOS:
  
  * In iOS, the default flow is redirection to Amazon page to link the wallet.
* Once the user is linked the **balance**  and the **direct_wallet_token** will be received in the response. This **direct_wallet_token**  should be used for initiating a direct debit wallet transaction.




### 3.6 Payload Changes


* Use the [Wallet Transaction SDK call](https://juspay.io/in/docs/amazonpay/docs/amazon-pay-balance/amazonpay-transaction-sdk-call) to initiate the direct debit transaction.
  
  * If the funds are sufficient to complete the transaction, the amount will be automatically debited.
  * 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.




### 3.7 Consume updated payment response


* Backend changes are required on your end to handle AmazonPay transaction-related webhook requests and order status responses.
  
  * [Order Status response](https://juspay.io/in/docs/amazonpay/docs/amazon-pay-balance/order-status)
  * [Webhooks](https://juspay.io/in/docs/amazonpay/docs/amazon-pay-balance/webhooks)




### 3.8 Managing Amazonpay Wallet


* To provide users with the option to unlink their linked AmazonPay wallet, the [Delink Wallet API](https://juspay.io/in/docs/amazonpay/docs/amazon-pay-balance/delink-wallet-api) or [Delink Wallet SDK call](https://juspay.io/in/docs/amazonpay/docs/amazon-pay-balance/delink-wallet-sdk-call) can be used.

