#chronogen

1 messages ยท Page 1 of 1 (latest)

formal oakBOT
crisp glen
#

Hi there!

faint harbor
#

Hi

crisp glen
#

We automatically close inactive threads.

#

Can you summarize your quesiton here in this new thread?

faint harbor
#

I want to get a list of products (through the API) that the user has purchased. When a user buys a subscription, there is an invoice in the payment_intent object and I can find out which products were sold. But if the user buys a "one time product", then I cannot determine what the person bought, since there is no invoice in the payment_intent object. How can I understand which object the user bought?

Thank you.

crisp glen
#

When you create the PaymentIntent, you could store additional information in the metadata field.

faint harbor
#

I am not creating PyamentIntent via API. I create a product through a website. Then I set the price for the product. Then I create a link. And I publish the link. After that, I listen to webhooks to see who and what bought.

crisp glen
#

I am not creating PyamentIntent via API.
Are you a software developer?

faint harbor
#

When I receive webhooks, if it is a "one time purchase" then I don't know how to get information about which product was purchased.

crisp glen
#

Yes I already answerd that question. If the amount is not enough for you, you need to store additional information in the metadata property. There's no other way.

faint harbor
crisp glen
#

Yes feel free to share more information.

#

But a PaymentIntent for one time purchase will only contain an amount, and no information about the product being bought.
To solve this: when you create the PaymentIntent, set some metadata to store additional information (like the product and/or quantity being bought). Then in your webhook endpoint you can read that metadata to get more information.

faint harbor
#

I'm creating a new product in the Stripe dashboard. Then I set a price for this product and create a link to this product. I am sending this link to my client so that they can make a purchase. I do all this through the website and not through the API.

I have set up a webhook. It is possible to create two types of payment on Stripe - one time purchase and recurring.

#

Recurring. When a person buys a product that has the recurring option set, then I get the payment_intent.succeeded webhook. This webhook has an invoice field. Through this invoice, I can then understand what exactly my user bought. I make a request via API and receive an invoice object where there are IDs of purchased products. So I have no problems here.

#

One time puruchase. But when the user makes a one-time purchase, I again receive the payment_intent.succeeded webhook. But in this case there is no invoice. And I can't find out what product my user bought.

#

Question. How can I find out what product my user bought?

crisp glen
#

and create a link to this product
Can you clarify what you mean by this? A Payment Link? Or something else?

crisp glen
faint harbor
#

Oh sorry, this is output

crisp glen
#

This doesn't work for me.
Which part doesn't work? Did you use expand: ["line_items"] as I explained above

faint harbor
#

Here is my code

$s = \Stripe\Checkout\Session::retrieve(
    'my key',
    ['expand' => ['line_items']]
);
echo json_encode($s);
crisp glen
crisp glen
#

I think it should be:

$s = \Stripe\Checkout\Session::retrieve(
    ['id' => 'xxx', 'expand' => ['line_items']]
);
faint harbor
#

Damn, I guess I understand. I have Stripe SDK in my project. But it is very old. Maybe that's the problem. I'm currently trying to make a request via curl.

crisp glen
faint harbor
#

Great ๐Ÿš€

#

Huuuuuuuge thank you very much kind man ๐Ÿš€ ๐Ÿ™

crisp glen
#

Happy to help ๐Ÿ™‚

faint harbor
#

Can I rate this chat somewhere? ๐Ÿ‘€

crisp glen
#

No need, but thanks ๐Ÿ™‚

faint harbor
#

Thank you ๐Ÿ™