#2Clutch - Subscription Info

1 messages ยท Page 1 of 1 (latest)

jaunty mist
#

Hello! Yep, that looks like info that's available on the Invoices endpoints. Are you having trouble finding one particular piece of information?

potent scaffold
#

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?

potent crown
#

We have invoice's due_date rather than due timestamp, and paid timestamp would be when you receive the invoice.paid webhook

potent scaffold
#

ok.

potent crown
#

good luck ๐Ÿ™‚

potent scaffold
#

thank you!

potent scaffold
#

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

ember obsidian
#

Hello ๐Ÿ‘‹
Discord is a little busy
Give me a few to catch up ๐Ÿ™‚

potent scaffold
#

np ๐Ÿ™‚

ember obsidian
potent scaffold
#

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?

ember obsidian
#

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?

brittle oracle
#

Hi ๐Ÿ‘‹ I've opened this thread @potent scaffold

potent scaffold
#

thank you!

potent scaffold
brittle oracle
#

Okay, there's LOTS of context here. It may take a minute or two for me to catch up ๐Ÿ˜…

potent scaffold
potent scaffold
#

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 ๐Ÿ˜…

brittle oracle
#

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?

potent scaffold
#
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

brittle oracle
#

The data object provided in that webhook request will be the paid invoice

potent scaffold
#

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?

brittle oracle
#

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

potent scaffold
#

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.

brittle oracle
#

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

potent scaffold
#

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?

brittle oracle
#

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

potent scaffold
#

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?

brittle oracle
#

Yes there is

#

In the link I provided above it says the Event object will return an Invoice as the data object

potent scaffold
#

ok i think i get it now.

#

can you leave this for the next couple of hours, while I try and go through implementing this?

#

i'll follow up with questions if I have any.