42

From the Stripe dashboard I can view a receipt (click preview link in invoice details). The receipt is then shown inside a popup but there is a permalink in it, so it can be viewed as a separate page. The URL of an emailed receipt looks like this:

https://dashboard.stripe.com/emails/receipts/invrc_xxxxxxxxxxxx

This URL does not require authentication, and so would be perfect for allowing me to show links to receipt details from inside my app's billing page. Except that there seems to be no way to get the magical invrc_xxxxxxxxxxxx id from the API, so I am unable construct the URL.

Or for some strange reason, Stripe engineers went through the trouble of designing an unauthenticated receipt view page, but have decided not to expose it via the API. Why??

This issue has been brought up in Stripe API - Receipts Listing (see comments section at the bottom), but no explanation, solution or justification was provided. Hope this more specific question can help.

UPDATE: As of January 17 2019, this is now possible to do. The Charge object has the receipt_url property that lets you access this information whether an email receipt was sent or not!

koopajah
  • 23,792
  • 9
  • 78
  • 104
jbelis
  • 575
  • 2
  • 6
  • 16

5 Answers5

22

That's unfortunately not something currently supported. There isn't any way through the API to get an receipt ID to be used here. That endpoint was built with the intent that it would only be used to permalink to a receipt from the body of a receipt email. That said, we are considering building out this functionality at some point in the future.

EDIT: Looks like my colleagues in Stripe support beat me to the punch here.

UPDATE: as of 2019-01-17, this is now supported via the receipt_url property on Charges (https://stripe.com/docs/api/charges/object#charge_object-receipt_url).

Peter Raboud
  • 381
  • 1
  • 5
  • 23
    This is absolutely a critical feature - anyone wanting to offer customers access to their invoices from within their app (which is common) must now recreate those invoices entirely- which is duplicative and stupid. (Also, can we get invoices as PDFs!) Thanks – Yarin Jul 29 '15 at 16:16
  • 4
    @peter-raboud Does Stripe have a public feature request site where we can upvote this? We have many, many clients asking to review copies of their receipts or for PDF copies. As Yarin mentioned it would be duplicate work for us to create that on our side and whatever we produce would be unlikely to (continue to) match the Stripe receipts. – jwadsack Aug 02 '16 at 21:35
  • Is this "considering" trackable? This would be very useful (for the customers who need it). It's available in the dashboard... but not scriptable! Which makes no sense. – Andy Hayden Jan 24 '17 at 00:52
  • 4
    any updates on this? does stripe provides this option now – Amal Kumar S Nov 02 '17 at 10:13
  • 1
    04/2018 update from Stripe support: Still not possible. They recommend using one of their invoicing partners (https://stripe.com/works-with/categories/invoicing). – jansokoly Apr 20 '18 at 13:35
  • 1
    Is this possible with new stripe billing platform? – TWilly May 16 '18 at 15:03
  • @peter-raboud So I see a way to get link for hosted pdf invoice, but invoices are not receipts meaning and invoice always shows as unpaid. Can you link to a hosted pdf of the receipt that shows payment was made? – jsherk Apr 27 '19 at 22:51
  • Is this also applicable on subscription charges? – mrudult Aug 26 '20 at 14:05
  • With subscription charges the receipt_url on the charge object is just a link to stripe hosted representation of the receipt, containing downloadable links. Is it possible to get the infamous download link: "https://dashboard.stripe.com/emails/receipts/invrc_xxxxxxxxxxxxxxxxxxx/pdf" – GossipDolphin Jun 02 '22 at 10:31
5

The invoice object has attributes for this:

hosted_invoice_url - string - The URL for the hosted invoice page, which allows customers to view and pay an invoice. If the invoice has not been finalized yet, this will be null.

invoice_pdf - string - The link to download the PDF for the invoice. If the invoice has not been finalized yet, this will be null.

smac89
  • 39,374
  • 15
  • 132
  • 179
Chris Martin
  • 30,334
  • 10
  • 78
  • 137
  • Note that invoice links expire 30 days after the invoice due date: https://stripe.com/docs/invoicing/hosted-invoice-page?locale=en-GB#invoice-urls – Cocowalla Aug 31 '23 at 14:08
1

Solved using screenshot API If you are using React try this but you can just use the ajax request to show the receipt in your app

const [recipt, setrecipt] = useState({loading: false,img: '',});

get the url from the strip response receipt_url const url = receipt_url

const result = await axios.get(`https://screenshotapi.net/api/v1/screenshot url=${url}&token=yourtokenhere`,);

then you can find the png URL from result.data.screenshot then you can use img tag to display it make sure to replace token with yours

Leul Tekle
  • 11
  • 2
0

Is this to resend a new email? There is an option send emails to the customer in the settings on successful payment. Another idea is to have the email send to something like Mandrill for processing and extract the URL:

http://help.mandrill.com/entries/21699367-Inbound-Email-Processing-Overview

David Nguyen
  • 8,368
  • 2
  • 33
  • 49
  • 1
    Thanks but no I don't want to resend an email. I want to show the receipt from my app. I just need to be able to construct the invoice receipt url using the Stripe API. This should not require a third party service. – jbelis Mar 03 '15 at 07:13
0

Yes, it's possible

The trick is to give expand: ['latest_charge'] as a parameter. That will return a lot more information for the payment_intent, including a receipt_url.

Example

(this uses ruby but it will be similar for other languages):

require 'stripe'

# Id of payment intent
payment_intent_id = "pi_3NcGv9Bn74CpQJ8BC8kJU"  

# Call api 
response = Stripe::PaymentIntent.retrieve(
  { id: payment_intent_id, expand: ['latest_charge'] }
)

# Access receipt_url
response.latest_charge.receipt_url
=> "https://pay.stripe.com/receipts/payment/CAcaFwmC71adF8xTlp5cVdSVDI4UU1SNUhXKP-SwP0majgw4UwY6LBYjNcus8XsJxgeD71QMWCmZWtZvMwc9hJpJwync86sjFH2gJ0-ukROFt6EA"

Specific styles can be configured here:

enter image description here

Note

  • expand: ['latest_charge'] tells the API to return not just the id of the latest_charge, but all the associated info as well (including the receipt_url)

References

For Stripe Connect

For Stripe Connect, you must give expand: ['latest_charge'] as a parameter and the stripe account id as an option.

Example:

require 'stripe'

# Id of payment intent
payment_intent_id = "pi_3NcGv9Bn74CpQJ8BC8kJU" 

# Id of account funds were paid to
stripe_account_id = "acct_1NJyqN2Ab3GCK1HW" 

# Call api 
response = Stripe::PaymentIntent.retrieve(
  { id: payment_intent_id, expand: ['latest_charge'] },
  { stripe_account_id: stripe_account_id }
)

# Access receipt_url
response.latest_charge.receipt_url
=> "https://pay.stripe.com/receipts/payment/CAcaFwmC71adF8xTlp5cVdSVDI4UU1SNUhXKP-SwP0majgw4UwY6LBYjNcus8XsJxgeD71QMWCmZWtZvMwc9hJpJwync86sjFH2gJ0-ukROFt6EA"
stevec
  • 41,291
  • 27
  • 223
  • 311