在PKPaymentRequest中为苹果支付

时间:2015-12-30 18:05:50

标签: ios objective-c applepay

基于Apple文档:PKPaymentRequest_Ref

每个PKPaymentRequest都有一个requiredShippingAddressFields和shippingContact。我有一个预先填写的送货地址。这是用户在选择Apple pay to checkout之前插入的地址,但我想让用户根据需要选择任何其他地址。

这就是我提出要求的方式:

- (PKPaymentRequest *)paymentRequest {
    PKPaymentRequest *paymentRequest = [[PKPaymentRequest alloc] init];
    paymentRequest.merchantIdentifier = @"merchant.com.myCompany.sandbox";
    paymentRequest.requiredShippingAddressFields = (PKAddressFieldPostalAddress|PKAddressFieldPhone|PKAddressFieldName);
    paymentRequest.requiredBillingAddressFields = (PKAddressFieldPostalAddress|PKAddressFieldPhone|PKAddressFieldName);
    paymentRequest.supportedNetworks = @[PKPaymentNetworkAmex, PKPaymentNetworkVisa, PKPaymentNetworkMasterCard];
    paymentRequest.billingContact = [self contactForAddress:self.info.billingAddress];
    paymentRequest.shippingContact = [self contactForAddress:self.info.shippingAddress];
    paymentRequest.merchantCapabilities = PKMerchantCapability3DS;
    paymentRequest.countryCode = [self.info.country uppercaseString];
    paymentRequest.currencyCode = [self.info.currency uppercaseString];
    paymentRequest.paymentSummaryItems = [self summaryItems];
    paymentRequest.shippingMethods = [self shippingMethod];
    return paymentRequest;
}

但是当苹果付费窗口出现时,它不显示预先设定的送货联系人(我设置为paymentRequest.shippingContact)。但在文件中它说

  

此送货地址显示在付款单中。当。。。的时候   提供了PKPaymentAuthorizationViewController类,用户可以   保留您指定的地址或输入其他地址。

我的代码有什么问题吗?

1 个答案:

答案 0 :(得分:1)

我尝试使用shippingAddress而不是shippingContact,它可以正常工作。 示例代码:

  

https://github.com/PersianDevelopers/ApplePay-Manager