#deepesharora
1 messages · Page 1 of 1 (latest)
hi @gentle plover can i add a colleague here too?
Hello đź‘‹
Subscription is linked to a PaymentIntent via the invoice.
So when you retrieve the PaymentIntent, you can expand the invoice
https://stripe.com/docs/api/payment_intents/object#payment_intent_object-invoice
Expanding the invoice should let you access subscription field
https://stripe.com/docs/api/invoices/object#invoice_object-subscription
Sure
I have first created a subscription object...that gave me the invocie
can you point me how to associate the subscription & payment intent to each other?
basically i'm expecting that the customer hits "subscribe" to something on our website and we create a subscription object and then get to them to stripe so they enter their cc information and pay
i hope that makes sense...if there is a step by step doc, i'm happy to follow it and ping you if I'm stuck. So happy to have your help 🙏
how do i add another person to this thread? any idea?
If the subscription you created requires a payment (i.e. there's no trial or 100% discounts being applied) then subscription creates an invoice which you can look at by looking up latest_invoice on the subscription object
latest_invoice should give you an invoice object which then should have a PaymentIntent linked to it.
You can just mention them using @
i have a latest_invoice object yes. how do i take the payment intent and pass it to the user so they interact with it?
latest_invoice is an expandable parameter
https://stripe.com/docs/api/subscriptions/object#subscription_object-latest_invoice
You can expand it
https://stripe.com/docs/api/expanding_objects
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
ok chcking
by any chance would you have sample code on building a full subscription integration? ...ie which steps shoudl we follow and in what order? crate subscription first or payment intent first? is there a best practice @gentle plover
i want to do this the correct and scalable way....
Yes, you linked the guide earlier
https://stripe.com/docs/billing/subscriptions/build-subscriptions?ui=elements
ok. i'll take few minutes...can i message you within few minutes or will this thread close automatically?
i'm going to try a few things
this is helpful i think
I can keep it open for a bit 👍
ok thank you so much my friend. I think you've shown me the way. now i just need to hack around a bit to see if i get it right 🙂
i was being blind....
your current coumentation says...
On the backend, create the subscription with status incomplete using payment_behavior=default_incomplete. Then return the client_secret from the subscription’s first payment intent to the frontend to complete payment.
suggestion ...
what will help is if you guys modify this sentences in your guide to talk about expanding the latest_invoice to get the payment_itnet attached to the subscription
i'm trying again
I'll flag your feedback with our docs team and see if we can get it updated
{
"id": "sub_1NSLKuHjXNLgtBFuHZyXnm7K",
"object": "subscription",
"application": null,
"application_fee_percent": null,
"automatic_tax": {},
"billing_cycle_anchor": 1689000312,
"billing_thresholds": null,
"cancel_at": null,
"cancel_at_period_end": false,
"canceled_at": null,
"cancellation_details": {},
"collection_method": "charge_automatically",
"created": 1689000312,
"currency": "usd",
"current_period_end": 1691678712,
"current_period_start": 1689000312,
"customer": "cus_OEoy4pc8kMbnvT",
"days_until_due": null,
"default_payment_method": null,
"default_source": null,
"default_tax_rates": [],
"description": null,
"discount": null,
"ended_at": null,
"items": {},
"latest_invoice": "in_1NSLKuHjXNLgtBFujsYDDChq",
"livemode": false,
"metadata": [],
"next_pending_invoice_item_invoice": null,
"on_behalf_of": null,
"pause_collection": null,
"payment_settings": {},
"pending_invoice_item_interval": null,
"pending_setup_intent": null,
"pending_update": null,
"plan": {},
"quantity": 1,
"schedule": null,
"start_date": 1689000312,
"status": "incomplete",
"test_clock": null,
"transfer_data": null,
"trial_end": null,
"trial_settings": {
"end_behavior": {
"missing_payment_method": "create_invoice"
}
},
"trial_start": null
}
is this correct...it says >>> "pending_setup_intent": null,
and trying to exapand it like this
$subs_obj->id,
['expand' => ['latest_invoice']]
);```
@gentle plover LMK
Correct, pending setup intent is only generated for subscriptions with a trial (or with 100% discounts) where a payment isn't required up front.
Yes, PaymentIntnet is generated by the invoice
we dont want customer to get options for pay with link or cash app..we've turned those off but its still appearing on the payment link url >> see >>
PaymentMethods on a subscription can be controlled via this setting on the dashboard
https://dashboard.stripe.com/settings/billing/invoice
Is this the page we are looking for and if yes, how do we customize this page
ok so it took the paymetn for $50 for this test and charged us 1.75 in fees
how do i know its setup to charge next month also and what will it charge me in fees next month?
if the subscription is in active state then it should be good to go.
Aside from that you can use test clocks to simulate subscription behaviour
https://stripe.com/docs/billing/testing/test-clocks
!!
Is this the page we are looking for
That's the invoice page, Is that what you are looking for?
We have docs on customization
https://stripe.com/docs/invoicing/customize
awesome! thanks so much @gentle plover
this was amazing help