Instance Property

paymentSummaryItems

An array of payment summary item objects that summarize the amount of the payment.

Declaration

var paymentSummaryItems: [PKPaymentSummaryItem] { get set }

Discussion

A typical transaction includes separate summary items for the order total, shipping cost, tax, and the grand total. See Listing 1 for an example.

Apple Pay uses the last item in the paymentSummaryItems array as the grand total for the purchase shown in Listing 1. The PKPaymentAuthorizationViewController class displays this item differently than the rest of the summary items. As a result, there are additional requirements placed on both its amount and its label.

  • Set the grand total amount to the sum of all the other items in the array. This amount must be greater than or equal to zero.

  • Set the grand total label to the name of your company. This label is used to represent the person or company being paid.

Your payment processor might have additional requirements, such as a minimum or maximum payment amount.

Listing 1

Setting the payment summary items

// 12.75 subtotal
NSDecimalNumber *subtotalAmount = [NSDecimalNumber decimalNumberWithMantissa:1275
 exponent:-2 isNegative:NO];
self.subtotal = [PKPaymentSummaryItem summaryItemWithLabel:@"Subtotal" amount:subtotalAmount];
 
// 2.00 discount
NSDecimalNumber *discountAmount = [NSDecimalNumber decimalNumberWithMantissa:200 exponent:-2 isNegative:YES];
self.discount = [PKPaymentSummaryItem summaryItemWithLabel:@"Discount" amount:discountAmount];
 
// 12.75 - 2.00 = 10.75 grand total
NSDecimalNumber *totalAmount = [NSDecimalNumber zero];
totalAmount = [totalAmount decimalNumberByAdding:subtotalAmount];
totalAmount = [totalAmount decimalNumberByAdding:discountAmount];
self.total = [PKPaymentSummaryItem summaryItemWithLabel:@"My Company Name" amount:totalAmount];
self.summaryItems = @[self.subtotal, self.discount, self.total];
request.paymentSummaryItems = self.summaryItems;

See Also

Setting the Payment Summary Items

class PKPaymentSummaryItem

Defines a summary item in a payment request—for example, total, tax, discount, or grand total.