#2Clutch - Subscription Info
1 messages ยท Page 1 of 1 (latest)
Hello! Yep, that looks like info that's available on the Invoices endpoints. Are you having trouble finding one particular piece of information?
yes.
invoice_due_timestamp & invoice_paid_timestamp
also, i'm fetching those as soon as a payment is processed. is that viable? or should i wait for some time before trying to retrieve this data?
Invoice API returns this object and I think they are in: https://stripe.com/docs/api/invoices/object
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
We have invoice's due_date rather than due timestamp, and paid timestamp would be when you receive the invoice.paid webhook
ok.
good luck ๐
thank you!
Currently dealing with the error above. How do I refresh my test keys? I believe they were automatically generated the first time I connected to the stripe cli
my connection expired so i had to login again, but now I'm getting that as an error
Hello ๐
Discord is a little busy
Give me a few to catch up ๐
np ๐
ah seems like you are using a restricted key.
You can create a new one by visiting this page
https://dashboard.stripe.com/test/apikeys
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
got it.
when a customer is created the following metadata as part of the event:
{'api_version': '2020-08-27',
'created': 1651156967,
'data': {'object': {'address': None,
'balance': 0,
'created': 1651156967,
'currency': None,
'default_source': None,
'delinquent': False,
'description': '(created by Stripe CLI)',
'discount': None,
'email': None,
'id': 'cus_Lak2PwBTB4jtEr',
'invoice_prefix': '29936F8C',
'invoice_settings': {'custom_fields': None,
'default_payment_method': None,
'footer': None},
'livemode': False,
'metadata': <StripeObject at 0x1089ecdb0> JSON: {},
'name': None,
'next_invoice_sequence': 1,
'object': 'customer',
'phone': None,
'preferred_locales': [],
'shipping': None,
'tax_exempt': 'none',
'test_clock': None}},
'id': 'evt_1KtYYOJF8oW0qG5scAdJsWis',
'livemode': False,
'object': 'event',
'pending_webhooks': 2,
'request': {'id': 'req_xJ2vUtdL0kgxlV',
'idempotency_key': '75b0d71f-1c2e-4c60-9888-b6239c1e72ef'},
What steps would I need to take to get the invoice_id related to this transaction?
Hmm I'm not sure if that's the best event to rely on in this case
What's the usecase here?
Can you provide more context?
Hi ๐ I've opened this thread @potent scaffold
thank you!
subscription management.
Okay, there's LOTS of context here. It may take a minute or two for me to catch up ๐
when a user makes a subscription payment for their subscription, i wanted to store information about that transaction.
all good. i was just responding to the questions before the thread was closed.
take your time. i will be jumping in and out of calls as well, so it may take me some time to respond sometimes so pls bear with as well ๐
Okay so what information about the payment do you want to store? Each billing period for a subscription will generate both an Invoice and a Payment Intent record which will record the payment. Do you want to store data in your own system?
invoice_id
invoice_period_start_date
invoice_period_end_date
invoice_description
invoice_creation_timestamp
invoice_due_timestamp
invoice_paid_timestamp
this is what i'm looking for.
well at least that's how the columns are being called in the relevant table.
an assumption is that the id generated by stripe is unique for every transaction
Okay that sounds like you would want to listen for the invoice.payment_succeeded event:
https://stripe.com/docs/api/events/types#event_types-invoice.payment_succeeded
Using Stripe webhooks
https://stripe.com/docs/webhooks
The data object provided in that webhook request will be the paid invoice
why not listen to customer.subscription.created?
are there any pros and cons associated with listening to one event vs the other in regard to my use case?
user makes a subscription payment for their subscription
I am trying to identify the event that gets as close to this action as possible
The created event will only fire when a new subscription is created for a customer
true. but a subscription doesn't get created without a successful payment so that event should have it all?
fyi, i'm asking to get a better understanding of why one way is better than the other.
i would've thought customer.subscription.created would have been the way to go for new sign ups. if i'm wrong, then i want to understand why i am.
Okay but you didn't ask about new sign ups, only payments, so I didn't consider that
And subscriptions can be created without a successful payment, they would just be in an incomplete state
sorry i thought it was implied here.
so i want payment transactions for subscriptions
first at sign-ups
and then at every recurring payments
also want to catch upgrades and downgrades.
i'm guessing payment.intent would probably be the way to go from recurring payment?
The Invoice payment succeeded will also be fired for each recurring payment and it will contain the invoice object which has the fields you are looking for. That is why I recommended
is there a place in your docs where i can see a sample response object from invoice.payment_succeed?
when listening to this event, how would i know if a user has upgraded or downgraded their plan?
Yes there is
In the link I provided above it says the Event object will return an Invoice as the data object
The event object is shown here: https://stripe.com/docs/api/events/object
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
But instead of the subscription shown there the data object would be an invoice like shown here: https://stripe.com/docs/api/invoices/object
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.