0

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

- (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设为 nil,因此处理从未得到修复。请帮忙!先感谢您。

4

2 回答 2

1

所以答案,嗯?我使用Stripe作为ApplePay交易的中间媒介,因此也使用了他们的SDK和教程来设置 ApplePay。无论如何,Passkit 的 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有点停滞,所以我删除了它,只使用第一个是didSelectShippingMethod来帮助实现整个事情,并且从未发生过无限处理再次!希望它也适合你(:

于 2015-04-30T13:44:11.310 回答
0

PKPaymentSummaryItem 在 iOS 8 中可用,因此如果您尝试将它与较新的 iOS 版本一起使用,您将得到 nil 而不是预期值。

我也被这个困住了

于 2015-04-28T09:33:05.153 回答