gpt4 book ai didi

ios - 对于 ApplePay paymentAuthorizationViewController 委托(delegate)创建 nil PKSummaryItem

转载 作者:行者123 更新时间:2023-11-29 02:09:47 25 4
gpt4 key购买 nike

引用这个question , 感谢您缩小范围。但遗憾的是我必须配置这个委托(delegate)

- (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,因此处理过程永远不会得到修复。请帮忙!提前谢谢你。

最佳答案

那么答案,嗯?我使用 Stripe 作为与 ApplePay 进行交易的中间媒介,因此使用他们的 SDK 和教程来设置 ApplePay以及。总之,Passkit 的 PKPaymentAuthorizationViewController 使用两个单独的协议(protocol),可以配置这些协议(protocol)以帮助简化实现。我同时使用了两者,即;

- (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;

但是,我注意到当调用后面的那个时,即 didSelectShippingAddressPasskit 有点停滞,所以我删除了它,只使用了第一个一个是 didSelectShippingMethod 来帮助实现整个事情,无限处理再也没有发生过!希望它也适合你 (:

关于ios - 对于 ApplePay paymentAuthorizationViewController 委托(delegate)创建 nil PKSummaryItem,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29412849/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com