#Sophia Wong
1 messages ยท Page 1 of 1 (latest)
You can't associate a Payment Link with an existing subscription. The Payment Link would create any subscription upon success
Perhaps you mean the Hosted Invoice Page? https://stripe.com/docs/invoicing/hosted-invoice-page
Hmmm, I'm not sure. I need to provide subscription service for users, let them pay on my site, and then check subscription-status. Would you give the simpliest way to accomplish that?
Here is what I did earlier today:
- prepare my product and price. 2. create customer via API in stripe for the ones who want to purchase our service. 3. use customer_id and price_id to create a checkout session with subscription mode. 4. redirect user to checkout session payment url 5. (here my problem comes) I should record the subscription_id so that I can check if this user has paid and then let him/her access our products, right? I must use a webhook to get a subscription_id ?
webhook seems a little complicated to use ๐
So I'm trying to find a simpler way.
Now I'm working with Codeigniter - a PHP framework.
Webhooks are a critical part of any Stripe integration, especially billing/recurring payments. See: https://stripe.com/docs/billing/subscriptions/build-subscriptions?ui=checkout#provision-and-monitor
Cann't I just create a subscription and check it's status afterwords? If the subscription is not active, for example, incomplete or past-due , I can remind user and show them a payment link.
Sure, but then what happens if a future recurring payment is declined or failed? Or a customer cancels their subscription? How are you updated about that so that you can revoke access?
If you don't want to manage the development overhead for webhooks, look at using something like Zapier instead
But you can't really get around using webhooks/events with a Stripe integration, especially for subscriptions
"if a future recurring payment is declined or failed? Or a customer cancels their subscription?", in these cases, status of the subscription should be abnormal, I think I just need to check the status and decide if user is allowed to access products. This logic sounds simple. Is it wrong? If people want to repurchase it after they cancel or reject a exist subscription, I can schedule a new subscription for them.
I think I just need to check the status and decide if user is allowed to access products.
Sounds like a pretty manual process to me!
I don't have enough time, so I want it to be as simple as possible. If I'm demanded to handle the events, I'll dig in some more. But not necessary for now.
Then how can I help?
If I do it in this way like I just said. Should I create a subscription at first, and then get last_invoice_id, and then manage to get a payment link? Lots of thanks for your time. I really appretiate!
I thought you were using Checkout?
Right. Currently I build checkout session for subscription. But I can't get subscription_id from API return data. I was told to use webhook to get subscription_id, which I'm trying to get around now.... ๐
API return data
Which is what? What object?
$data = [
'customer' => $params['customer_id'],
'mode' => 'subscription',
....
];
$checkout_session = \Stripe\Checkout\Session::create($data);
log_message('error', print_r($checkout_session, true));
the create checkout session API
Yes, because at that point you've only created the session. The customer has completed it
There's no subscription at that point
yes. So I'm trying to find another possible way like creating subscription first so that I can get a subscription_id directly.
This is why you listen for checkout.session.completed events, which will include the associated sub_xxx ID you need
If you want to do that, then you'd use the hosted_invoice_url field from the generated invoice: https://stripe.com/docs/api/invoices/object#invoice_object-hosted_invoice_url
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.