Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

E-mail Receipts Not Generated with Stripe Payment

I have an application that uses Stripe Payments. We are creating one-off payments and not storing the customer as an object. So, we have server side Ruby code that looks something like this...

Stripe::Charge.create(
  currency: 'gbp',
  amount: some_amount,
  card: token,
  description: 'Payment for awesome thing'
)

The token is generated client side, using the Stripe JS libraries and contains (or, rather, represents) all the info the customer supplied, which is e-mail address, card number etc.

When the transaction hits Stripe it takes money from the customer, and in my Stripe dashboard I see all of the details that the customer supplied, such as code expiry etc. Against the card I see their name, but the name is set to an e-mail address.

Below all of this I'm then told...

No receipts sent — No email address for this payment

Am I missing something with regards to the way this API should be called. The token clearly contains that e-mail address (I see it as the card name on the Stripe dashboard).

Do I have to call this API in another way if I want Stripe to use the e-mail address that they've already captured to generate receipts?

like image 658
Martin Peck Avatar asked Mar 17 '23 10:03

Martin Peck


1 Answers

Stripe doesn't retrieve the email address from the token. When you create a one-time charge you have to set the email in the receipt_email field so that a receipt is sent to that email address if the charge succeeds.

You would either retrieve the email from the stripeEmail parameter if you're using Simple Checkout or otherwise from the parameter you stored it into and your code would just be:

Stripe::Charge.create(
  currency: 'gbp',
  amount: some_amount,
  card: token,
  description: 'Payment for awesome thing',
  receipt_email: email
)

Small warning, the email receipt will never be send in Test mode even if you provide that field.

EDIT I focused on why it wouldn't work before and not in which case you would get an email receipt.

First off, you need to check the settings to "Email customers for successful payments" in your dashboard settings. Then the customer needs to have the email field set. If those two are true, then when you create a charge for that customer, an email receipt will also be sent to that customer for you (in Live mode). The same would happen with non-free subscription where each invoice with a charge associated would email a receipt.

like image 184
koopajah Avatar answered Apr 01 '23 01:04

koopajah