I'm working on an app that uses Apple Pay as a choice in payment method. Normal payment works fine. We have a product involving a subscription, and this works okay as well. We get the apple pay payment info, and then charge the user monthly server-side, using the merchant provider.
We are running into a problem where we have a subscription promo with the first month free. Apple Pay does not seem to support a $0.00 purchase, which would be the first month's cost. Normally we'd receive their credit card details, not charge the first month, but automatically charge monthly after that.
Specifically Apply Pay's PaymentRequest's paymentSummaryItems can't accept a an item with a $0.00 cost, and the total must add up to more than $0.00. Apple pay docs state:
Set the grand total amount to the sum of all the other items in the array. This amount must be greater than zero.
The initWithPaymentRequest
call otherwise returns nil, and the modal presentation crashes the app. Error handling could avoid, but it doesn't help get the payment info as needed.
What is the best way to get payment info for a free trial month subscription, if apple pay doesn't accept $0.00 payment?
PKPaymentRequest *paymentRequest = [Stripe paymentRequestWithMerchantIdentifier:APPLE_MERCHANT_ID];
paymentRequest.requiredShippingAddressFields = PKAddressFieldEmail | PKAddressFieldName;
NSDecimalNumber *amount = [Util decimalNumberFromCostStr:cartModel.totals.grandtotalFormattedString];
paymentRequest.paymentSummaryItems = @[
[PKPaymentSummaryItem summaryItemWithLabel:cartModel.totals.grandtotalFormattedString amount:amount],
[PKPaymentSummaryItem summaryItemWithLabel:@"Company Name" amount:amount]
];
if ([Stripe canSubmitPaymentRequest:paymentRequest]) {
PKPaymentAuthorizationViewController *paymentController;
paymentController = [[PKPaymentAuthorizationViewController alloc] initWithPaymentRequest:paymentRequest];
paymentController.delegate = self;
paymentController.modalPresentationStyle = UIModalPresentationFormSheet;
[[Util topMostController] presentViewController:paymentController animated:YES completion:nil];
} else {
[Util alertWithTitle:nil message:@"Cannot submit payment request" delegate:nil];
}