Max Mattini
Max Mattini

Reputation: 41

Using Stripe/Apple Pay, how to request an email-receipt for successful payments in the app

Using Stripe/iOS, the user of the app can pay by credit card or by Apple Pay. I want, from the app (not the server), to request an email receipt when payment is successful. For Credit Card payment I do the following:

let paymentIntentParams = STPPaymentIntentParams(clientSecret: <paymentIntentClientSecret>)
paymentIntentParams.paymentMethodParams = paymentMethodParams
if let receiptEmail = self.receiptEmail {
      paymentIntentParams.receiptEmail = <email address>
}
let paymentHandler = STPPaymentHandler.shared()
paymentHandler.confirmPayment(withParams: paymentIntentParams,
authenticationContext: authenticationContext) { 
 … 
}

However for Apple Pay payment I don’t know which property to set. In the app, I implement the STPApplePayContextDelegate protocol. Question: For Apple Pay payment, what and where I need to set the email-address for the receipt? Can you please provide a code snippet?

Thanks

Upvotes: 0

Views: 671

Answers (1)

Max Mattini
Max Mattini

Reputation: 41

After discussion with Stripe support, it seems that using STPApplePayContextDelegate there is no way to set the receiptEmail property in the payment intent.

  • The best approach is to change the server and set the receiptEmail at the server

  • If you still want to make the change at the app, the workaround is to use the REST API to update the payment intent.

Below is the reply from Stripe support:

The STPApplePayContext does not support this directly -- it needs to be set on the payment intent. The iOS flow for card payments is described in [0] and support receiptEmail in the STPPaymentIntentParams [1], but the Apple Pay flow is different. If not set when you create the payment intent, you would then want to make a call to your server to update the payment intent [2] in the payment flow where you call the completion. Alternately, confirm the payment intent server-side after collecting the Apple Pay payment method client-side [3].

[0] https://stripe.com/docs/payments/accept-a-payment?platform=ios&ui=custom#ios-submit-payment

[1] https://stripe.dev/stripe-ios/docs/Classes/STPPaymentIntentParams.html#/c:@M@Stripe@objc(cs)STPPaymentIntentParams(py)receiptEmail

[2] https://stripe.com/docs/api/payment_intents/update#update_payment_intent-receipt_email

[3] https://stripe.com/docs/apple-pay?platform=ios#client-side

Upvotes: 0

Related Questions