对于ApplePay paymentAuthorizationViewController,委托将创建零PKSummar



关于这个问题,感谢您缩小范围。但遗憾的是,我必须配置这个代理

- (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller
               didSelectShippingMethod:(PKShippingMethod *)shippingMethod                   
completion:(void (^)(PKPaymentAuthorizationStatus, NSArray *summaryItems))completion
{
    completion(PKPaymentAuthorizationStatusSuccess, [self summaryItemsForShippingMethod:shippingMethod]);
}
- (NSArray *)summaryItemsForShippingMethod:(PKShippingMethod *)shippingMethod
{
    totalPrice = 5;
    NSString *prices = [NSString stringWithFormat:@"%d",totalPrice];
    NSDecimalNumber *num = [[NSDecimalNumber alloc] initWithString:prices];
    PKPaymentSummaryItem *foodItem = [PKPaymentSummaryItem summaryItemWithLabel:@"Total Products Cost" amount:num];
    NSDecimalNumber *total = [foodItem.amount decimalNumberByAdding:shippingMethod.amount];
    PKPaymentSummaryItem *totalItem = [PKPaymentSummaryItem summaryItemWithLabel:@"Video Mantis Productions, INC." amount:total];
    return @[foodItem, shippingMethod, totalItem];
}

为了向用户展示产品摘要的真实含义。遗憾的是,我将PKPaymentSummaryItem*foodItem设置为零,因此处理永远无法修复。请帮忙!提前谢谢。

答案是什么?我使用Stripe作为ApplePay交易的中间媒介,因此也使用了他们的SDK和教程来设置Apple Payasskit的PKPaymentAuthorizationViewController使用两个独立的协议,可以对其进行配置,以帮助简化实施。我同时使用了两者,即;

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

而且。。。

- (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller
                  didSelectShippingAddress:(ABRecordRef)address
                                completion:(void (^)(PKPaymentAuthorizationStatus status, NSArray *shippingMethods, NSArray *summaryItems))completion;

然而,我注意到,当调用后一个,即didSelectShippingAddress时,Passkit有点停滞,所以我删除了它,只使用第一个DidSelectSshippingMethod来帮助实现整个过程,而无限处理再也没有发生过!希望它也对你有用(:

PKPaymentSummaryItem可从iOS 8获得,因此,如果您试图将其与不太新的iOS版本一起使用,您将获得nil而不是预期值。

我也被这个问题卡住了。

相关内容

  • 没有找到相关文章