我们可以在Apple Pay中添加新的送货地址吗?

时间:2016-01-15 07:56:03

标签: ios objective-c iphone stripe-payments applepay

我已经在我的应用程序中添加了"送货地址" 我希望将该地址指定为shippingAddress shippingContact,而用户则需要{ {1}}。

  

我尝试使用以下代码" shippinAddress"是我的字典   已经有一个我想用作Apple Pay Shipping的地址   地址。

Apple Pay

PKPaymentRequest *paymentRequest = [Stripe paymentRequestWithMerchantIdentifier:merchantId]; paymentRequest.shippingContact = [self getShippingAddress_ApplePay]; -(PKContact*)getShippingAddress_ApplePay { PKContact *address = [[PKContact alloc] init]; NSPersonNameComponents *personName = [[NSPersonNameComponents alloc] init]; personName.givenName = [shippinAddress valueForKey:@"firstname"]; personName.familyName = [shippinAddress valueForKey:@"lastname"]; CNMutablePostalAddress * postalAddress = [[CNMutablePostalAddress alloc] init]; postalAddress.street = [shippinAddress valueForKey:@"street"]; postalAddress.city = [shippinAddress valueForKey:@"city"]; postalAddress.state = [shippinAddress valueForKey:@"region"]; postalAddress.postalCode = [shippinAddress valueForKey:@"postcode"]; postalAddress.ISOCountryCode = [shippinAddress valueForKey:@"country_id"]; CNPhoneNumber *phone = [[CNPhoneNumber alloc] initWithStringValue:[shippinAddress valueForKey:@"telephone"]]; address.name = personName; address.emailAddress = [KCustomerInfo valueForKey:@"email"]; address.postalAddress = postalAddress; address.phoneNumber = phone; return address; } 出现时,我没有收到此地址。

我已尝试过设置此paymentAuthorizationViewController

任何人都可以建议,我们可以分配这种方式我是,那么我用我的方式错了吗?

由于

1 个答案:

答案 0 :(得分:0)

基本上只要PKPaymentAuthorizationController出现,就无法获取地址。 您需要等待委托回调:

- (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller
                       didAuthorizePayment:(PKPayment *)payment
                                completion:(void (^)(PKPaymentAuthorizationStatus))completion

如您所知,您可以从PKPayment对象中提取地址信息。

如果用户在PKPaymentAuthorizationController中选择了一个地址,也会触发回调:

- (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller
                   didSelectShippingMethod:(PKShippingMethod *)shippingMethod
                                completion:(void (^)(PKPaymentAuthorizationStatus status, NSArray<PKPaymentSummaryItem *> *summaryItems))completion;

- (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller
                  didSelectShippingContact:(PKContact *)contact
                                completion:(void (^)(PKPaymentAuthorizationStatus status, NSArray<PKShippingMethod *> *shippingMethods,
                                                     NSArray<PKPaymentSummaryItem *> *summaryItems))completion NS_AVAILABLE_IOS(9_0);

<强>更新 好吧,似乎我误解了这个问题。 要将地址传递给PKAuthController,您需要将该地址存储在相应的地址簿联系人中。