An array of payment summary item objects that summarize the amount of the payment.
SDKs
- iOS 8.0+
- Mac Catalyst 13.0+
- watchOS 3.0+
Framework
- Pass
Kit (Apple Pay and Wallet)
Declaration
var paymentSummaryItems: [PKPayment Summary Item] { 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 payment
array as the grand total for the purchase shown in Listing 1. The PKPayment
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.
Note
In versions of iOS prior to version 12.0 and watchOS prior to version 5.0, the amount of the grand total must be greater than zero.
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;