#theplay3r_docs
1 messages ¡ Page 1 of 1 (latest)
đ Welcome to your new thread!
â˛ď¸ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question. Thank you for your patience!
âąď¸ We automatically close idle threads, which makes them read-only. Make sure you stick around to chat in realtime! If this thread is closed and you have another question you'll need to start a new thread.
đ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1214048616897847317
đ Have more to share? You can add more detail below, including code, screenshots, videos, etc.
Can you share an example balance tranaction ID, so that I can check how you integrate with Stripe?
Because of the limitation of the length of the message in the form, I will provide more information here:
I'm trying to create a system, that will each month take all payouts from the previous month and map transactions to each respective product.
This is because products are created by users and I want to know how much revenue each user has generated.
I also need to know how much of this revenue was cut due to fees - thus why I decided to use Payouts, as they represent what ends up on our account.
After doing some research, my current solution is as follows (for context, I'm using Checkout Sessions for everything):
-
Subscriptions
Simple flow - I create a new checkout session in SUBSCRIPTION mode, the Price in this Session is linked to a Product, which has necessarry metadata to identify the owner of the Product.
I'm listening forcustomer.subscription.created,customer.subscription.resumedandcustomer.subscription.updatedfor managing this Subscription, retrieve related Product (viasubscription.items.data.subscription_item.price) and "cascade" the metadata from the Product to PaymentIntent that was created by Stripe for this subscription. -
One-time payments
Similar flow as with Subscriptions, but instead of listening to webhooks, I'm taking advantage of PaymentIntentData and putting metadata directly when creating the session.
So my real question is:
Is this a good/reliable way of doing this? I'm sure that at least with one-time payments this should work, but I'm not so sure with Subscriptions - does the PaymentIntent stay the same for payment recollection on every interval, does it have the same metadata?
Sure, if it's still relevant, here is one of the transaction IDs: pm_1OLNbNE63yJzXD3GiiNehstb
metadata doesn't populate from one object to another, i.e. metadata set on the subscription / product object will not be present in payment intent object.
For subscription integration on Checkout Session, where do you intend to get the product information from? From the Subscription, Invoice or Payment Intent?
I'm aware that it doesn't populate from one to another, thus why I'm listening to the events on Subscription to do it manually - from Product to PaymentIntent.
With your flow that you set the metadata from the subscription product to payment intent manually, I'm afraid this is the only way to have the metadata in payment intent
There is no straightforward way to do this
That doesn't pose a issue, as long as we can depend on it even with later payments in the same Subscriptions. When we set the metadata on the intial PaymentIntent when the Subscription is created, is the same PaymentIntend (and metadata) used in later payment collections for the same Subscription?
No, the payments for the future billing cycles will be a different Payment Intent
To set the metadata on the Payment Intent, it should be set every time when new Invoice of the subscription is created
Is there any event that I can listen to that I could use for this?
One way I can think of is:
- Listen to
invoice.*event - Check the
linesto get the items details,subscriptionfor the subscription that it is paid for, andpayment_intentthat is used for this specific payment - Populate the product information from
linesto thepayment_intent
So, if I'm only creating Subscriptions with 1 item, is this setup sufficient?
- Listen to
invoice.createdevent - Check if
invoice.subscription!= null - Retrieve Product from Subscription
- Map metadata from Product to PaymentIntent
Hi @zenith totem I'm taking over this thread.
It's a long thread, can you tell me what you want to achieve?
Sure, basically I need to get Product information from Transaction that is inside of a Payout. The only way to achieve this seems to be to put metadata directly to PaymentIntent.
This is simple with one-time payments, where I can modify the metada of PaymentIntent using PaymentIntentData.
However with Subscriptions it's a bit more complicated, because a new PaymentIntent is created for each payment collection of Subscription.
My current approach for this is described in my latest message.
I see, so you want to attach a metadata to the paymentIntent associated with a subscription-created invoice?
Correct - I'm "cascading" the metadata from Product to PaymentIntent.
Got it, yes your approach looks good to me.
Alright then, glad I was able to somehow make this work.
Just a question out of curiosity, is there any reason to why there is no direct connection from transaction to Product/Price?
You mean direct connection between a payment_intent and prodcut/price?
I mean between a payment/transaction and product/price.
Seems like such a connection could come in handy.
PaymentIntent just focus on payment (currency, amount), and there's no direct relationship beteween PaymentIntents and Prodcuts/Prices
I see, well anyhow, my issue was resolved, thanks for the help!