【问题标题】:Changing Apple Pay Shipping Address Programmatically以编程方式更改 Apple Pay 送货地址
【发布时间】:2019-10-08 18:11:03
【问题描述】:

我的应用中有一个流程,用户在结账期间但在 Apple Pay 提示之前输入他们希望运送到的地址。该地址可能与他们卡上的地址相同,也可能不同。但是,当 Apple Pay 提示出现时,送货地址是他们卡上的默认地址,而不是我在致电 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()
        }

这里提供给对象的shippingAddress是用户在表单中输入的内容。

如何更改 Apple Pay 弹出时显示的送货地址值?谢谢

【问题讨论】:

    标签: ios swift shopify


    【解决方案1】:

    我正在寻找相同的信息,它实际上不受 Shopify 的 mobile-buy-sdk-ios 的支持,您可以在以下几行中看到: https://github.com/Shopify/mobile-buy-sdk-ios/blob/1acced28d1db48e41abadbfebc0bd0b7e8a9318a/Pay/PaySession.swift#L185

    如果您希望结帐时包含送货地址,您可以修补 sdk 并将参数 shippingContact 添加到 request。 您可以使用 checkout 参数轻松地初始化它。

    注意:shippingContact 输入为PKContact,您可以在此处找到该对象的信息,并使用结帐中包含的信息构造该对象: https://developer.apple.com/documentation/passkit/pkcontact

    【讨论】:

      猜你喜欢
      • 2014-12-16
      • 1970-01-01
      • 1970-01-01
      • 2016-04-04
      • 1970-01-01
      • 1970-01-01
      • 2016-04-20
      • 2023-03-27
      • 2019-07-10
      相关资源
      最近更新 更多