0

In reference to this question, thank you for narrowing it down. But sadly I have to configure this 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];
}

in order to show the user what products summary really is. Sadly I am getting PKPaymentSummaryItem *foodItem as nil and consequently the processing doesn't ever gets fixed. Please HELP! Thank you in advance.

Community
  • 1
  • 1
Mohsin Khubaib Ahmed
  • 1,008
  • 16
  • 32

2 Answers2

1

So the answer, eh? I was using Stripe as an intermediate medium for transactions with ApplePay and hence used their SDK and tutorials to setUp ApplePay as well. Anyhow, the Passkit's PKPaymentAuthorizationViewController uses two separate protocols that can be configured in order to help ease up the implementation. I was using both, namely;

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

And...

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

However, what I noticed was when the later one was called, that is, didSelectShippingAddress, the Passkit kind of stalled, so I removed it and only used the first one that is didSelectShippingMethod to help implement the entire thing, and the infinite processing never occurred again! Hope it works out for you too (:

Mohsin Khubaib Ahmed
  • 1,008
  • 16
  • 32
0

PKPaymentSummaryItem is available from iOS 8, so if you are trying to use it with a less recent iOS version, you'll get nil instead of expected value.

I just got stuck with this too

Thibaud David
  • 496
  • 2
  • 11
  • Naah! Using iOS8 man! Btw I figured out that it'll remain the same. But does the "Processing" on Apple Pay go away? – Mohsin Khubaib Ahmed Apr 28 '15 at 09:38
  • Can you try creating your PKPAymentSummaryItem with this ? NSDecimal decimalAmount = [@(totalPrice) decimalValue]; NSDecimalNumber *amount = [NSDecimalNumber decimalNumberWithDecimal:decimalAmount]; PKPaymentSummaryItem *summaryItem = [PKPaymentSummaryItem summaryItemWithLabel:@"Total Products Cost" amount:amount]; – Thibaud David Apr 29 '15 at 12:47