I have a very basic website that runs a stripe checkout with 2 product. This all works fine and I am able to sell products and they appear in the dashboard. Now I want to automate the whole shipping process and get the shipping address for each new purchase along with what was purchased. I can get the address through the stripe API but I can't find any GET commands that can tell me which product sku was ordered along with the Charge. This seems like something that should be pretty easy to find out? It shows up in the web GUI dashboard but not in the web requests. I've read through the documents here https://stripe.com/docs/api but I'm not finding much help.
I have a working web request in python that can return all of my charges that were created but it has no product info.
Alright I found out how to do it. It's a little convoluted and should be streamlined by stripe but here is how you can do it.
First requests a list of events like this (I'm using python)
import stripe
foo = stripe. PaymentIntent.list(type='checkout.session.completed',limit=10)
Once you get the events you can find the payment intent buried inside of the json object.
payment_intent = foo['data']['object']['payment_intent']
Once you have a payment intent you can retrieve the payment_intent object from stripe like this
charges = stripe.PaymentIntent.retrieve(payment_intent)['charges']['data'][0]
which will yield a charges object that has all the billing data in it.
Now to the get the product that was ordered from that payment intent. This can be found in the event object at
item = events['data'][<insert or loop over this list element>]['data']['object']['display_items'][0]['sku']['attributes']['name']
And doing this you can get the shipping and item that was sold.
Related
I am currently building an application where we want to user Stripe Payment links rather then building our own version of UI to support the same functionality. However I notice that Stripe Payment Links create a new customer every single time. Is there a way to attach my customer id to the payment link so that a new customer is not created when they attempt to buy more then one product? I would prefer not to have to have a single user have multiple customer ids inside of my database.
Thanks!
Payment Links are not specific to a Customer record. The documentation does include examples of how you might append data to them to aid in reconciling payments to a specific individual.
If you want to make use of the Stripe hosted UI while still assigning specific Customer records then I would recommend making use of Stripe Checkout.
Quite suprisingly, it is not possible to automatically generate an invoice after as successfull checkout session with Stripe.
An invoice must always come before a payment in the stripe system.
I am left with having to recreate the invoice through a bunch of API calls fetching the PaymentIntent or the CheckoutSession that was just performed to recompute the data for the invoice and mark it as paid (not even sure I can retrieve everything I need)
This seems quite hacky... Is this the right way to do it or shall I just handle invoicing outside of stripe (quite annoying too) ?
just want clarify if you need Invoice or Receipt, because they are two different things
Invoice is something you send to customer to ask for payment (before payment)
Receipt is a proof of succeeded payment (after payment)
My understanding is that the payment is already collected upon a succeeded checkout session, so you probably want to send receipts to customers. To enable email receipts, you can go to Settings -> Emails and tick the Email customers about Successful payment box. Please note that emails won't be sent in test mode.
Let me explain a solution that you can use to generate invoices after payment in stripe. This solution is based on Zapier connectors.
There are three systems that we should connect.
Stripe
Zapier
Plumsail Documents
First, you have to set up a Stripe connection to Zapier. Go to Zapier, create a Zap, find the Stripe connection, and select "New Payment" as the trigger event. Then, connect your Stripe account with Zapier and make a test in Zap. If everything ok, go to the second step.
Second. After you have done the Zap connection for Stripe, go to Plumsail Documents, create the process, and make a template for your invoice.
Third. Set up a Plumsail Documents connection to Zapier. Go to your Zap (where you have made the connection to Stripe before), find the Plumsail Documents action, and set the Start Process as Action Event. Next, you have to select your process and match output data from Stripe payment with your invoice template in Plumsail Documents.
It seems a bit complicated, so you can read the article with a more detailed description of this solution. Also, there are screenshots for all processes.
As a result, you will get a fully automated custom invoice generation whenever you will get a payment in Stripe.
Max, product manager at Plumsail.
I'm trying to integrate the Docusign eSignature API with Stripe.
I've created a Quickstart application and have successfully run through the process, signing the contract and making a test payment.
However, I noticed that the payment in Stripe does not have a customer object attached to it:
I'd like to know if it's possible to specify a customerId, or create one as part of the process. I did notice that the PaymentDetails constructor accepts a customerId parameter, but I could not see any relevant documentation for this, and specifying it in my request didn't seem to make any difference.
Any advice appreciated.
Thanks
Dan,
For regular payments that are one time and right away - DocuSign will not create a customer record. This is "by design" and is meant to support quick payments without any customer record.
You can set recurring/future payments and then you'll get customer records when you set the gateway. If you want, your recurring payment or future payment can be just one time in the near future and then you can achieve what you want and get a customer record.
I would like to see how I can send subscription invoices with auto charge.
From the Invoice API, billing can be either set to charge automatically or send to customers for manual payment.
But I want to charge my customers automatically and send them the invoices. It seems that it's a common option in Saas monthly subscription. Not sure how I can achieve it.
I've finished creating a subscription for a customer. But the record and invoice are only on the Stripe dashboard.
One way I thought of is to get the invoice pdf file from API and send them on my own. I am using Python / Django now.
Can someone help me out?
There are 2 ways to go about it:
1) Send the invoice with the send_invoice (see the Python example). It will know that the payment was already settled for that invoice based on the invoice ID.
2) Add a webhook endpoint to your Django app and subscribe to the webhook events invoice.created, invoice.finalized, invoice.sent, invoice.payment_succeeded. This way though you need to create your own template (email or PDF up to you)
Can someone please help me understand how coupon codes works with Stripe relay?
According to the api docs, you can pass a coupon code when creating an order:
https://stripe.com/docs/api#create_order
However, what should this coupon code be? From what I understand, coupons created are only available for subscriptions. In the new dashboard, they coupon page is also only found under subscriptions -> coupons.
So, what should the coupon field contain?
I can't handle the discount logic on my side, as you pass the SKU id's of the products, when creating an order, so you don't pass any amount that you can manipulate yourself.
Thanks.
You can use subscription coupons with Relay's orders. Coupons started out as part of the subscriptions API, and are still grouped under "Subscriptions" in the dashboard and the API reference, but they're also usable with Relay.