#martyn-checkout
1 messages ยท Page 1 of 1 (latest)
would you mind sharing how you're currently creating the checkout session? in particular, what mode are you using to create the session?
Hi mate! I'm currently not creating a checkout session - the user signs up to our page, jumps on the stripe servers, then gets redirected back with the checkout session appended
So we get something like "cs_test_b1G1qxWk8WbCCNUKzLI5EUdVpIVm4NlKOuPgtZtaU4FWFWetKQiJy9swXP" back, which is being stored, and then using the API to get the customer details
i.e.
$stripe->checkout->sessions->retrieve(
'cs_test_b1G1qxWk8WbCCNUKzLI5EUdVpIVm4NlKOuPgtZtaU4FWFWetKQiJy9swXP')
hmm, sorry - how are you redirecting them to the stripe-hosted page? are you using payment links?
Yeah sure thing. So the user signs up to the page, they are then auto redirected to "https://buy.stripe.com/14k3eO3260zF0rCeUV" which lets them complete the payment piece. That then redirects them to us, with the URL having the "checkoutsession={CHECKOUT_SESSION_ID}" appended to it
So we can take that checkout session and store it, thats all fine - API calls like this then work fine "$stripe->checkout->sessions->retrieve(
'cs_test_b1G1qxWk8WbCCNUKzLI5EUdVpIVm4NlKOuPgtZtaU4FWFWetKQiJy9swXP',
[]
);"
ah, got it
(that is payment links, fwiw)
there should be a customer attribute populated on the checkout session object when you fetch it via the retrieve call, in that case
you'd do something like:
$session = $stripe->checkout->sessions->retrieve(
'cs_test_b1G1qxWk8WbCCNUKzLI5EUdVpIVm4NlKOuPgtZtaU4FWFWetKQiJy9swXP',
[]
);
$session->customer
OH cool sorry yeah that works - apologies, get the customer attribute - would it be possible to get the call that I can use to get the customers subscription details?
Essentially we want when the login etc to be able to check their subscription status, as well as drive the cancel functionality etc
and just to be clear - the payment link you're referring to sets up a subscription, right? it's not making a one-off purchase, but you might want to have a subscription on the same customer later?
Correct mate yep, sets up a recurring subscription
๐
you'd want something like https://stripe.com/docs/api/subscriptions/list?lang=php, filtering by the customer param
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Great thanks. Apolgoies just for clarity, the call is
$stripe = new \Stripe\StripeClient(
'sk_test_51Kj4XXCLgKR3BTWZwZBrcSUQ3NXsZlCJltnGXeyjncIXE86wKrHxlGVSulo6dI1ZMahULBlgoKfhu0VYlFlDiTcK0009zlKdXK'
);
$stripe->subscriptions->all(['limit' => 3]);
To add the customer limit on it, can I just modify the "$stripe->subscriptions->all(['limit' => 3]);" line and include "Where customer = x" etc?