#theplay3r_docs

1 messages ¡ Page 1 of 1 (latest)

zealous thicketBOT
#

👋 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.

wispy lodgeBOT
strange loom
#

Can you share an example balance tranaction ID, so that I can check how you integrate with Stripe?

zenith totem
#

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):

  1. 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 for customer.subscription.created, customer.subscription.resumed and customer.subscription.updated for managing this Subscription, retrieve related Product (via subscription.items.data.subscription_item.price) and "cascade" the metadata from the Product to PaymentIntent that was created by Stripe for this subscription.

  2. 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?

zenith totem
strange loom
#

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?

zenith totem
#

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.

strange loom
#

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

zenith totem
#

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?

strange loom
#

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

zenith totem
#

Is there any event that I can listen to that I could use for this?

strange loom
#

One way I can think of is:

  1. Listen to invoice.* event
  2. Check the lines to get the items details, subscription for the subscription that it is paid for, and payment_intent that is used for this specific payment
  3. Populate the product information from lines to the payment_intent
wispy lodgeBOT
zenith totem
#

So, if I'm only creating Subscriptions with 1 item, is this setup sufficient?

  • Listen to invoice.created event
  • Check if invoice.subscription != null
  • Retrieve Product from Subscription
  • Map metadata from Product to PaymentIntent
pallid trellis
#

Hi @zenith totem I'm taking over this thread.

#

It's a long thread, can you tell me what you want to achieve?

zenith totem
#

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.

pallid trellis
#

I see, so you want to attach a metadata to the paymentIntent associated with a subscription-created invoice?

zenith totem
#

Correct - I'm "cascading" the metadata from Product to PaymentIntent.

pallid trellis
#

Got it, yes your approach looks good to me.

zenith totem
#

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?

pallid trellis
#

You mean direct connection between a payment_intent and prodcut/price?

zenith totem
#

I mean between a payment/transaction and product/price.

#

Seems like such a connection could come in handy.

pallid trellis
#

PaymentIntent just focus on payment (currency, amount), and there's no direct relationship beteween PaymentIntents and Prodcuts/Prices

zenith totem
#

I see, well anyhow, my issue was resolved, thanks for the help!