1
votes

I have a flow in my app where the user enters an address they wish to ship to during checkout but before the Apple Pay prompt. That address may be the same as on their card, it may be different. However, when the Apple Pay prompt comes up, the shipping address is that default one attached to their card rather than the one I provide before I call authorize():

       let checkout = PayCheckout(
            id: checkoutId.rawValue,
            lineItems: lineItems,
            giftCards: nil,
            discount: nil,
            shippingDiscount: nil,
            shippingAddress: self.shippingAddress, // this provided value is from what the user input in the form
            shippingRate: nil, 
            currencyCode: "USD",
            subtotalPrice: subtotal,
            needsShipping: true,
            totalTax: tax,
            paymentDue: subtotal + tax
        )

        ShopifyClient.shared.getShopName { shopName in
            guard let shopName = shopName else {
                self.showErrorForCheckout("Unable to complete checkout. Please try again.")
                self.isCheckingOut = false
                return
            }

            let paySession = PaySession(
                shopName: shopName,
                checkout: checkout,
                currency: PayCurrency.USD,
                merchantID: "merchant.myshopName"
            )
            paySession.delegate = self
            self.paySession = paySession
            paySession.authorize()
        }

The shippingAddress provided into the object here is what the user entered in the form.

How can I change the shipping address value that shows when Apple Pay pops up? Thanks

1

1 Answers

0
votes

I was looking for the same information, it's actually not supported by mobile-buy-sdk-ios from Shopify as you can see on the following lines: https://github.com/Shopify/mobile-buy-sdk-ios/blob/1acced28d1db48e41abadbfebc0bd0b7e8a9318a/Pay/PaySession.swift#L185

If you want the shipping address contained in your checkout you can patch the sdk and add the parameter shippingContact to request. You can easily initialize this one with the checkout parameter.

NOTE: shippingContact is typed as PKContact, you can find the informations of this object here and construct this one with informations contained in checkout: https://developer.apple.com/documentation/passkit/pkcontact