#Steven Gauerke - Checkout page data
1 messages · Page 1 of 1 (latest)
id of transaction? something so when a webhook comes through, I know it matches this session I just created
the webhook has an "invoice id".
I think that's what I'd like to look for
or is that included in the return of the create session
Got it.
So Each session will have a unique Session ID, You can embed that into your return URL and access it client side
`$price = $stripe->prices->retrieve(
$_REQUEST['priceId'],
[]
);
$mode = $price->type == "recurring" ? "subscription" : "payment";
try {
$session = $stripe->checkout->sessions->create([
'line_items' => [[
'price' => $price->id,
'quantity' => 1,
]],
'customer' => $_REQUEST['customerId'],
'mode' => $mode,
'allow_promotion_codes' => true,
'success_url' => 'https://watch.t2gsports.com/complete.php',
'cancel_url' => 'https://watch.t2gsports.com/closer.php',
]);
echo json_encode(array("status" => 1, "url" => $session->url));
} catch(\Stripe\Exception\ApiErrorException $e) {
$return_array = [
"message" => $e->getMessage(),
];
echo json_encode($return_array);
}`
how do I get the session ID if the success_url is part of the process of making the session?
You can use `{CHECKOUT_SESSION_ID} template variable to your success_url as demonstrated here
https://stripe.com/docs/payments/checkout/custom-success-page#modify-success-url
is there any way I can pass meta data to the checkout session so the webhook will return that same meta data?
heres the use case......they want to rent this video.....theres not a product for that specific video rental but instead the product is "1 Rental for 24 hours" so somehow I need to get in the webhook, what specifically is purchased and I need to pass that from the beginning
I'm not sure about this off the top of my head
Have you tried this in test mode?
I know how to do just this if I was not using the hosted checkout pages. But I the reason I'm using the hosted checkout is so we can track which "viewing plans" are being bought
for reporting
is there any way I can pass meta data to the checkout session so the webhook will return that same meta data?
It'd definitely depend on which webhook event you're listening to as we don't usually copy metadata on associated objects.
ok ill try to get creative
ok I ran into a weird situation. I have a promocode I created for 100% off. And its not restricted to 1 time use or first time or specific product or customers. When I try to use that promo code on a mode "payment" with a one time purchase item, it says invalid. But if I have a subscription item and use mode "subscription", then the code works.
coupon id lIrD2NkC
can you share a subscription ID with that coupon applied?
sub_1KUGjJAvXb0N1jioLwktFbmy
Thanks looking
so I have 2 subscription options and one 1 time option. If I choose the one-time option, the coupon code says invalid
if I choose a subscription option, it works
One time payments have a minimum amount of $0.50 so 100% coupons fail at Checkout
so is there no way to give someone something for free?
I guess then I can't use hosted checkout pages
For one-time purchases, I think so.
when a customer had an issue, instead of a refund, I wanted to give them a coupon code for their next one free.
Ok well thank you
Hmm you can technically handle this client-side but I don't think it'd be possible to log that as purchase with Stripe. AFAIK it isn't. Checking if there's a workaround
how about this.....I know I can pass a discount coupon ID to the create checkout session. Can I keep "allow_promo_codes" to false?
so they can't enter something?
Yes you should be able to do that
ok so I'm going to ask client side for the coupon code before the checkout page is even created. if its not 100% off then I'll pass the coupon ID when making the checkout page
yup that sounds feasible