#mni-santiago_api
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.
âąď¸ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
đ 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/1270442517732528199
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
This is the object that I have generated to create the subscription
{
customer: 'cus_Pz9HnjPF1gDyMT',
start_date: 'now',
end_behavior: 'cancel',
phases: [ { items: [Array], iterations: 3 } ],
metadata: {
softruckId: '4e81e1f4-eae1-4579-be3e-660b82c21fd2',
flokzuFormId: '28c517d1-6598-1129-c55c-0e5c75c95c0f',
flokzuProcessId: 'INGS-22',
type: 'Softruck'
}
}
Hi, this is expected as the metadata is not copied over between objects (with a few exceptions). We document this here: https://support.stripe.com/questions/how-metadata-works-with-related-objects.
In this case, you would need to update the payment intent, https://docs.stripe.com/api/payment_intents/update#update_payment_intent-metadata object explicitly.
Is there a way to do it from the creation of the subscription?
There is not https://docs.stripe.com/api/subscriptions/create
So how could I solve my problem. Let me give you context, I am trying to reuse a hook and to do so I want to pass metadata to differentiate from my code what type of payment it refers to. When entering the subscription from the panel I cannot see the metadata either.
You can create the subscription with the metadata, and then immediately update the PaymentIntent with the metadata.
How do I do it if I still don't have a payment intent at the time of creating the subscription?
Then at that point there is not any payment so you can't 'differentiate from my code what type of payment it refers to'.
Once the payment succeeds, you can update the payment intent
Is there any other event triggered by subscriptions that could help me?
Hello
Taking over..
Let me give you context, I am trying to reuse a hook and to do so I want to pass metadata to differentiate from my code what type of payment it refers to. When entering the subscription from the panel I cannot see the metadata either.
Not sure I fully grasp the context.. Can you share an example?
I have 2 payment methods within my app, subscriptions and normal payments. I have set up a hook that notifies me whenever there is a payment_intent_succeeded.
In order to differentiate the different payments, I want to pass metadata with a "type" and from my backend I capture that "type" and perform different operations depending on it.
This is my code when creating the subscription:
const subscriptionSchedule = await this.stripe.subscriptionSchedules.create({
customer: user.paymentInformation.stripeCustomerId,
start_date: 'now',
end_behavior: 'cancel',
phases: [
{
items: [
{
quantity: 1,
price: priceId,
},
],
iterations: iterations,
metadata: { ...metadata }
},
],
});
Resulting:
{
customer: 'cus_Pz9HnjPF1gDyMT',
start_date: 'now',
end_behavior: 'cancel',
phases: [ { items: [Array], iterations: 3 } ],
metadata: {
softruckId: '4e81e1f4-eae1-4579-be3e-660b82c21fd2',
flokzuFormId: '28c517d1-6598-1129-c55c-0e5c75c95c0f',
flokzuProcessId: 'INGS-22',
type: 'Softruck'
}
}
But when the hook notifies me, the metadata is empty. pgskc told me that the metadata cannot be maintained. So I wonder, is there any event specific to subscriptions to be able to differentiate them? Or some way to keep the metadata without updating the payment_intent?
Sorry if something is not understood, my English is not very good
Do you use invoicing for "normal" (one-time) payments?
If not, the easier route might be to check if the payment intent has an associated invoice: https://docs.stripe.com/api/payment_intents/object#payment_intent_object-invoice
If it does, then the PaymentIntent was for the subscription versus if it doesn't then the PaymentIntent was for one-time (normal) payment
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
How can I check if I am using invoicing for one-time payments?
The invoice.payment_succeeded event could serve me instead of payment_intent_succeeded?
How can I check if I am using invoicing for one-time payments?
If you create one-time invoices using the dashboard or use/v1/invoicesendpoint to create invoices then you're likely using invoicing
The invoice.payment_succeeded event could serve me instead of payment_intent_succeeded?
Yes, you can listen toinvoice.payment_succeededorinvoice.paidevents
each invoice would have a billing_reason parameter: https://docs.stripe.com/api/invoices/object#invoice_object-billing_reason
manual: Unrelated to a subscription, for example, created via the invoice editor.
subscription: No longer in use. Applies to subscriptions from before May 2018 where no distinction was made between updates, cycles, and thresholds.
subscription_create: A new subscription was created.
subscription_cycle: A subscription advanced into a new period.
subscription_threshold: A subscription reached a billing threshold.
subscription_update: A subscription was updated.
upcoming: Reserved for simulated invoices, per the upcoming invoice endpoint.
Great, I'm going to develop a solution with this information, thank you very much for your time.