#wiiim
1 messages ยท Page 1 of 1 (latest)
Hello ๐
Can you share more details?
Sure ๐
I'm trying to get the receipt number from either the invoice/charge object
Basically I want to sent the receipt via email to my customers on my own, not via stripe.
I wanted to use the receipt_number on the receipt email so it's kept in sync for easier tracking if the customer contacts me.
I now read on the docs that the receipt_number "will be null until a receipt has been sent."
I checked it and the receipt number is only present if I once viewed the Receipt via the dashboard.
Is there a way to generate that number programmitcally?
hmm, I don't think there's a way to generate the receipt_number without sending it unfortunately.
Well technically I wasn't sending it via the dashboard, I just viewed it.
As far as I know, that field is generated and filled when the user gets the email and visits the hosted page.
I think viewing the receipt via the dashboard also follows the same logic.
Quick question, do you see a receipt_url on the charge instead?
"receipt_number": null,
"receipt_url": "https://pay.stripe.com/receipts/invoices/CAcaFwoVYWNjdF8xTFE4dWdCZWRQZ3IwWnYyKN3ji6EGMgYdS6aspds6LBZOndRIpRMfAKK8P_az8c21K9xqUR9cp6nipKg421gOm3PshdRk5TEy7Qlz?s=ap",
Yes
Can I decode the CA... part with my secret key or something like that?
unfortunately, no. However, you could try sending a curl/get request to the url and see if the API counts that as a visit to the page and fills the receipt_number parameter
Okay, will try that.
One more question came up to my mind now: I also want to show the PaymentMethod used on the receipt. I get the ID from the webhook event invoice.payment_succeeded. With that I need to make another request to stripe's api to get the whole PaymentMethod object. Is there a way to like expand the webhook data that stripe sents so I do not need to fetch the payment method again? Would also consider the charge object too I guess.
(curl command actually did work, a little bit ugly to do in code, but I think that's my way to go)
The charge object should have the payment method listed on it
https://stripe.com/docs/api/charges/object#charge_object-payment_method
Alright, thank you ๐ Got it working now