#martyn-checkout

1 messages ยท Page 1 of 1 (latest)

topaz hedge
#

would you mind sharing how you're currently creating the checkout session? in particular, what mode are you using to create the session?

plain depot
#

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')

topaz hedge
#

hmm, sorry - how are you redirecting them to the stripe-hosted page? are you using payment links?

plain depot
#

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',
[]
);"

topaz hedge
#

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

plain depot
#

Oh ot it sorry

#

Ok apologies - are there any examples of using the retrieve call?

topaz hedge
#

you'd do something like:

$session = $stripe->checkout->sessions->retrieve(
  'cs_test_b1G1qxWk8WbCCNUKzLI5EUdVpIVm4NlKOuPgtZtaU4FWFWetKQiJy9swXP',
  []
);
$session->customer
plain depot
#

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

topaz hedge
#

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?

plain depot
#

Correct mate yep, sets up a recurring subscription

topaz hedge
#

๐Ÿ‘

plain depot
#

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?

topaz hedge
#

you'd use $stripe->subscriptions->all(['limit' => 3, 'customer' => $session->customer])

#

(well, the limit there isn't really necessary, particularly if you don't support >1 subscription per customer. you can just leave that param out if desired)

plain depot
#

ah you star mate, thanks! That works well

#

Much apprecaited