# Apple Pay web sdk with auth + deferred capture with different amount

**URL:** <https://developer.squareup.com/forums/t/apple-pay-web-sdk-with-auth-deferred-capture-with-different-amount/8560>\
**Category:** Questions\
**Tags:** payments-api, web-payments-sdk\
**Created:** [February 13, 2023, 5:55pm UTC](https://developer.squareup.com/forums/t/apple-pay-web-sdk-with-auth-deferred-capture-with-different-amount/8560 "2023-02-13T17:55:14Z")\
**Posts on this page:** 20\
**Page:** 5

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [March 14, 2024, 4:37pm UTC](https://developer.squareup.com/forums/t/apple-pay-web-sdk-with-auth-deferred-capture-with-different-amount/8560/81 "2024-03-14T16:37:15Z")

</div>

Okay, you cannot dynamically change the value of the tag in the AndroidManifest.xml at runtime since the manifest is compiled into the APK. However, you can achieve the desired functionality by using a different approach.

One way to handle this scenario is to set the application ID programmatically at runtime based on the garage location. You can remove the tag from the AndroidManifest.xml and instead set the application ID in your code before initializing the Square In-App Payments SDK.

Here’s an example of how you might do this in your application:

```auto
// Determine the garage location (US or Canada)
String garageLocation = getGarageLocation();

// Set the application ID based on the garage location
String squareApplicationId = "";
if ("US".equals(garageLocation)) {
    squareApplicationId = "US_APPLICATION_ID";
} else if ("Canada".equals(garageLocation)) {
    squareApplicationId = "CANADA_APPLICATION_ID";
}

// Initialize the Square In-App Payments SDK with the appropriate application ID
PaymentsSdk.INSTANCE.initialize(context, squareApplicationId);

```

In this example, `getGarageLocation()` is a method that you would implement to determine the garage location (US or Canada). You would replace “US\_APPLICATION\_ID” and “CANADA\_APPLICATION\_ID” with the actual application IDs for your US and Canada locations, respectively.

By setting the application ID programmatically, you can ensure that the correct ID is used based on the garage location, and you won’t need to modify the AndroidManifest.xml file for each location. 🙂

---

<div class="post-metadata">

**Author:** ![anveshtokala](https://avatars.discourse-cdn.com/v4/letter/a/6f9a4e/32.png) [@anveshtokala](https://developer.squareup.com/forums/u/anveshtokala)\
**Post date:** [March 15, 2024, 10:33am UTC](https://developer.squareup.com/forums/t/apple-pay-web-sdk-with-auth-deferred-capture-with-different-amount/8560/82 "2024-03-15T10:33:07Z")

</div>

hi @Bryan-Square

Could you please let us know the dependency used for the following code?

```auto
PaymentsSdk.INSTANCE.initialize(context, squareApplicationId);

```

1. It would be great if you could provide documentation on integrating the In-App Payments SDK without using a meta tag from the AndroidManifest.xml in Android app Project?

2. Where should the SDK be installed? At application level ?

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [March 15, 2024, 4:17pm UTC](https://developer.squareup.com/forums/t/apple-pay-web-sdk-with-auth-deferred-capture-with-different-amount/8560/83 "2024-03-15T16:17:31Z")

</div>

The dependency used for the code `PaymentsSdk.INSTANCE.initialize(context, squareApplicationId);` is the Square In-App Payments SDK for Android. To integrate the SDK into your Android app project without using a meta tag in the AndroidManifest.xml, you can follow the steps below:

1. Add the Square In-App Payments SDK dependency to your app’s `build.gradle` file:

```auto
dependencies {
    implementation 'com.squareup.sdk.in-app-payments:card-entry:1.5.0'
    implementation 'com.squareup.sdk.in-app-payments:google-pay:1.5.0'
}

```

1. Initialize the SDK in your `Application` class or `Activity` class:

```auto
import com.squareup.sdk.inappayments.PaymentsSdk;

public class MyApplication extends Application {

    @Override
    public void onCreate() {
        super.onCreate();
        String squareApplicationId = "REPLACE_WITH_YOUR_APPLICATION_ID";
        PaymentsSdk.INSTANCE.initialize(this, squareApplicationId);
    }
}

```

1. If you are not using a meta tag in the AndroidManifest.xml to specify the Square application ID, make sure to initialize the SDK before performing any payment-related operations.

The SDK should be installed at the application level, typically in the `Application` class, to ensure it is initialized before any payment operations are performed.

For more detailed documentation on integrating the In-App Payments SDK, you can refer to the official Square Developer documentation: [https://developer.squareup.com/docs/in-app-payments-sdk/setup](https://developer.squareup.com/docs/in-app-payments-sdk/setup)

Keep in mind that the version number in the `build.gradle` dependency may change, so always check the latest version in the Square Developer documentation or on the Square GitHub repository: [GitHub - square/in-app-payments-android-quickstart: In-App Payments Quick Start Sample Android App](https://github.com/square/in-app-payments-android-quickstart). 🙂

---

<div class="post-metadata">

**Author:** ![anveshtokala](https://avatars.discourse-cdn.com/v4/letter/a/6f9a4e/32.png) [@anveshtokala](https://developer.squareup.com/forums/u/anveshtokala)\
**Post date:** [March 18, 2024, 8:17am UTC](https://developer.squareup.com/forums/t/apple-pay-web-sdk-with-auth-deferred-capture-with-different-amount/8560/84 "2024-03-18T08:17:16Z")

</div>

Hi @Bryan-Square  
We have added the given dependencies, but we are unable to import the PaymentsSDK. It seems there is no class named PaymentsSDK with the import you provided. We have tried both the latest version (1.6.5) and the version provided (1.5.0), but we are still unable to import the PaymentsSDK.

```auto
import com.squareup.sdk.inappayments.PaymentsSdk;

```

Could you please let us know what we are missing here?  
Please reply ASAP.

---

<div class="post-metadata">

**Author:** ![anveshtokala](https://avatars.discourse-cdn.com/v4/letter/a/6f9a4e/32.png) [@anveshtokala](https://developer.squareup.com/forums/u/anveshtokala)\
**Post date:** [March 19, 2024, 5:35pm UTC](https://developer.squareup.com/forums/t/apple-pay-web-sdk-with-auth-deferred-capture-with-different-amount/8560/86 "2024-03-19T17:35:45Z")

</div>

Hi @Bryan-Square

We have added the given dependencies, but we are unable to import the PaymentsSDK. It seems there is no class named PaymentsSDK with the import you provided. We have tried both the latest version (1.6.5) and the version provided (1.5.0), but we are still unable to import the PaymentsSDK.

```auto
import com.squareup.sdk.inappayments.PaymentsSdk;

```

Could you please let us know what we are missing here?  
Please reply ASAP.

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [March 19, 2024, 5:59pm UTC](https://developer.squareup.com/forums/t/apple-pay-web-sdk-with-auth-deferred-capture-with-different-amount/8560/87 "2024-03-19T17:59:42Z")

</div>

The `paymentsSDK` is the In-App Payments SDK. Are you not able to initialize it? 🙂

---

<div class="post-metadata">

**Author:** ![anveshtokala](https://avatars.discourse-cdn.com/v4/letter/a/6f9a4e/32.png) [@anveshtokala](https://developer.squareup.com/forums/u/anveshtokala)\
**Post date:** [March 19, 2024, 6:20pm UTC](https://developer.squareup.com/forums/t/apple-pay-web-sdk-with-auth-deferred-capture-with-different-amount/8560/88 "2024-03-19T18:20:18Z")

</div>

Hi @Bryan-Square

Yes, We were not able to initialize with the given dependencies. It seems there is no PaymentSdk class.

```auto
dependencies {
    implementation 'com.squareup.sdk.in-app-payments:card-entry:1.5.0'
    implementation 'com.squareup.sdk.in-app-payments:google-pay:1.5.0'
}

```

Adding screenshots for reference

 ![image (29)](https://global.discourse-cdn.com/square/original/2X/3/3ead2c054da87149a9135e8204e9bbbd7d4d941f.png)

 ![image (30)](https://global.discourse-cdn.com/square/original/2X/b/bee9c8628a3e78adaf4431d2c7a826d9dd74993c.png)

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [March 19, 2024, 6:38pm UTC](https://developer.squareup.com/forums/t/apple-pay-web-sdk-with-auth-deferred-capture-with-different-amount/8560/89 "2024-03-19T18:38:07Z")

</div>

Sorry yes, it doesn’t have `paymentsSDK`. If you try `SQIPInAppPaymentsSDK` does it work? 🙂

---

<div class="post-metadata">

**Author:** ![anveshtokala](https://avatars.discourse-cdn.com/v4/letter/a/6f9a4e/32.png) [@anveshtokala](https://developer.squareup.com/forums/u/anveshtokala)\
**Post date:** [March 22, 2024, 7:50am UTC](https://developer.squareup.com/forums/t/apple-pay-web-sdk-with-auth-deferred-capture-with-different-amount/8560/90 "2024-03-22T07:50:41Z")

</div>

Hi @Bryan-Square,

We have tried using `SQIPInAppPaymentsSDK`, its not working.

 ![image](https://global.discourse-cdn.com/square/original/2X/a/a18a35ec6f7ff43c1aeda1adf4361904e7b18c3b.png)

Can you please provide the proper documentation for Android Google Pay integration with multiple Square accounts?

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [March 22, 2024, 3:55pm UTC](https://developer.squareup.com/forums/t/apple-pay-web-sdk-with-auth-deferred-capture-with-different-amount/8560/91 "2024-03-22T15:55:38Z")

</div>

Here is the documentation on installing the [In-App Payments SDK for Android](https://developer.squareup.com/docs/in-app-payments-sdk/installation). You’ll need to make sure the application ID that you want to install it with is configured with the right account. 🙂

---

<div class="post-metadata">

**Author:** ![anveshtokala](https://avatars.discourse-cdn.com/v4/letter/a/6f9a4e/32.png) [@anveshtokala](https://developer.squareup.com/forums/u/anveshtokala)\
**Post date:** [March 25, 2024, 6:56am UTC](https://developer.squareup.com/forums/t/apple-pay-web-sdk-with-auth-deferred-capture-with-different-amount/8560/92 "2024-03-25T06:56:38Z")

</div>

Hi @Bryan-Square  
We have added the given dependencies, but we are unable to import the PaymentsSDK. It seems there is no class named PaymentsSDK with the import you provided. We have tried both the latest version (1.6.5) and the version provided (1.5.0), but we are still unable to import the PaymentsSDK.

```auto
import com.squareup.sdk.inappayments.PaymentsSdk;

```

We have separate application IDs for our US and Canada locations (2 Application IDs) and need to access the respective ID based on the garage location.

```auto
<meta-data
            android:name="sqip.SQUARE_APPLICATION_ID"
            android:value="@string/GOOGLE_PAY_APPLICATION_ID"/>

```

1. How can we dynamically set the application ID in the `<meta-data>` tag of AndroidManifest.xml based on the specific location, considering that the manifest can only hold one ID at a time and cannot have duplicate names?

Please reply ASAP.

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [March 25, 2024, 5:19pm UTC](https://developer.squareup.com/forums/t/apple-pay-web-sdk-with-auth-deferred-capture-with-different-amount/8560/93 "2024-03-25T17:19:07Z")

</div>

I was mistaken and there is no PaymentsSDK. Are you able to get the In-App Payments SDK going as per our documentation for one Square account application? 🙂

---

<div class="post-metadata">

**Author:** ![anveshtokala](https://avatars.discourse-cdn.com/v4/letter/a/6f9a4e/32.png) [@anveshtokala](https://developer.squareup.com/forums/u/anveshtokala)\
**Post date:** [March 25, 2024, 7:07pm UTC](https://developer.squareup.com/forums/t/apple-pay-web-sdk-with-auth-deferred-capture-with-different-amount/8560/94 "2024-03-25T19:07:15Z")

</div>

Hi @Bryan-Square

Yes, we were able to get the Square SDK running for a single square account. However, we have two accounts—one for the US and another for Canada. We intend to offer Google Pay as an option in both regions. It’s imperative that this SDK supports multiple Square app IDs without relying on the tag in the Android manifest.xml file. This functionality is crucial for our Android app.

Please reply ASAP.

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [March 25, 2024, 8:48pm UTC](https://developer.squareup.com/forums/t/apple-pay-web-sdk-with-auth-deferred-capture-with-different-amount/8560/95 "2024-03-25T20:48:02Z")

</div>

Currently the SDK relies on the application ID that is configured in the `AndroidManifest.xml`. 🙂

---

<div class="post-metadata">

**Author:** ![anveshtokala](https://avatars.discourse-cdn.com/v4/letter/a/6f9a4e/32.png) [@anveshtokala](https://developer.squareup.com/forums/u/anveshtokala)\
**Post date:** [March 27, 2024, 9:51am UTC](https://developer.squareup.com/forums/t/apple-pay-web-sdk-with-auth-deferred-capture-with-different-amount/8560/96 "2024-03-27T09:51:10Z")

</div>

Hi @Bryan-Square

Yes we understand currently the SDK relies on Application ID that is configured in `AndroidManifest.xml` using `<meta-data>` tag.

Unfortunately we cannot have two different `<meta-data>` tags for different Application IDs. And two APK’s isn’t a solution.

Our App supports for both US and Canada region, hence we have two Square Accounts. Now for implementing the transaction smoothly between the two regions we need to configure the Application ID dynamically based on the region.

This is our at most priority and crucial as we have to roll out Google Pay supporting Canada region. Could you please let us know how we can assign Application ID dynamically. ASAP.

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [March 27, 2024, 5:25pm UTC](https://developer.squareup.com/forums/t/apple-pay-web-sdk-with-auth-deferred-capture-with-different-amount/8560/97 "2024-03-27T17:25:15Z")

</div>

According to the team you can set the application id programmatically instead of XML.

````auto
/**
 * Lets the application read and write the Square application ID via the [squareApplicationId]
 * property. You can also specify the application ID at build time in the AndroidManifest.xml:
 *
 * ```
 * <application>
 * <meta-data
 * android:name="sqip.SQUARE_APPLICATION_ID"
 * android:value="your application id"/>
 * </application>
 * ```
 *
 * @property squareApplicationId The Square application ID used to obtain a card nonce.
 */
object InAppPaymentsSdk {

  @JvmStatic
  var squareApplicationId: String by SquareApplicationId
}

````

You can initialize the In-App Payments SDK by doing `InAppPaymentsSdk.squareApplicationId = USD_APP_ID` 🙂

---

<div class="post-metadata">

**Author:** ![anveshtokala](https://avatars.discourse-cdn.com/v4/letter/a/6f9a4e/32.png) [@anveshtokala](https://developer.squareup.com/forums/u/anveshtokala)\
**Post date:** [March 28, 2024, 11:24am UTC](https://developer.squareup.com/forums/t/apple-pay-web-sdk-with-auth-deferred-capture-with-different-amount/8560/98 "2024-03-28T11:24:56Z")

</div>

Hi @Bryan-Square

1. We have implemented the above solution in the sandbox environment for both Canada and US region using below code.

2. We confirmed that the same Canada sandbox credential when initialised from the `AndroidManifest.xml` file, it works as expected.

Can you please let us know are there any other steps to be implemented after this code `InAppPaymentsSdk.squareApplicationId = squareApplicationId` to make it work.

Or are there any other ways of achieving multiple Square application Id at runtime in single APK.

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [March 29, 2024, 4:36pm UTC](https://developer.squareup.com/forums/t/apple-pay-web-sdk-with-auth-deferred-capture-with-different-amount/8560/100 "2024-03-29T16:36:53Z")

</div>

Were you able to generate a token that was passed to the server or is this failing on the client? 🙂

---

<div class="post-metadata">

**Author:** ![anveshtokala](https://avatars.discourse-cdn.com/v4/letter/a/6f9a4e/32.png) [@anveshtokala](https://developer.squareup.com/forums/u/anveshtokala)\
**Post date:** [April 1, 2024, 8:03am UTC](https://developer.squareup.com/forums/t/apple-pay-web-sdk-with-auth-deferred-capture-with-different-amount/8560/101 "2024-04-01T08:03:33Z")

</div>

Hi @Bryan-Square

This is failing on the client side. We receive the below error as soon as we click on the GPay button.

 ![canada_gpay](https://global.discourse-cdn.com/square/original/2X/3/3e3b7e28c96204ecbf47ff1298339e196722b705.png)

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [April 1, 2024, 4:19pm UTC](https://developer.squareup.com/forums/t/apple-pay-web-sdk-with-auth-deferred-capture-with-different-amount/8560/102 "2024-04-01T16:19:15Z")

</div>

What is the `location_id` that your trying to process a payment for? 🙂

[Previous page](https://developer.squareup.com/forums/t/apple-pay-web-sdk-with-auth-deferred-capture-with-different-amount/8560.md?page=4)

[Next page](https://developer.squareup.com/forums/t/apple-pay-web-sdk-with-auth-deferred-capture-with-different-amount/8560.md?page=6)
