#nathan9745354-checkout
1 messages · Page 1 of 1 (latest)
Hi Karbi
I am create a checkout session and work fine with my website
But I want to identify which user is purchased the product
So i need to collect the cookies sessionid to match the database
the cookies appear success.html
Because When user click the check out page will redirect to stripe checkout page
when checkout session is done. will redirect to $domain/success.html
this time the cookies what I need
?
Sorry I'm not fully following - which part of the above flow are you struggling with? Or are you asking just in general how to do this?
ah...
Did you read the photo?
the flow is:
customer login to account with email address in my website
click the button
go to stripe checkout page
payment done and redirect to success.html
Easily to get it
But at stripe checkout session page the event does not have any information about client email address right?
I want the event also have my website email account. otherwise I need collect the sessionid in success.html to match the email address with database
"But at stripe checkout session page the event does not have any information about client email address right?"
Are you referring to the webhook event checkout.session.completed? Or are you talking about grabbing the users email from the success page?
For instance. Checkout session page need identified which user purchased the products.
In my situation that using email account login
I want to collect this event type
in success.html I only can see the cookies of sessionid
the sessionid could help me identify which user purchased
this is second way
the first way I want to collect my customers what email address/user name is login to the website
Gotcha, so the way we usually recommend to users is to add "?session_id={CHECKOUT_SESSION_ID}" to your success URL and then from your success page we'll populate that with the checkout session ID so you can retrieve it and pull all the necessary information about the session + customer. https://stripe.com/docs/payments/checkout/custom-success-page#modify-success-url
yes i am still reading the article but seen not work for this case?
what 's the main purpose ?
of this
auto fill in the customer name?
What about it doesn't work for you? From what you described, it sounds like you just need a solution for getting the email used with a Checkout Session from the success page that a user is redirected to. Am I misunderstanding your ask?
I not sure but I need test
Do you have a request ID or the Checkout Session ID I can take a look at?
Those messages have your test secret keys in there so I deleted them
ok I delete it again
They're just your test mode keys so it's not a huge deal, but still better to be safe
Don't worries
I am a ethical hacker
Checkout session page
<?php
require 'vendor/autoload.php';
\Stripe\Stripe::setApiKey('sk_test_51JZVslERg7yCZcir1A5JW4vVBMQoI5R5hmRwlsvbkfskrgql4WKemiDsSpjOHClMrH73MZzqInoVxiqXxaGDvAlxxxxxxx');
header('Content-Type: application/json');
$YOUR_DOMAIN = 'http://prosfinity.com/public';
$checkout_session = \Stripe\Checkout\Session::create([
'line_items' => [[
# TODO: replace this with the price of the product you want to sell
'price' => 'price_1Jb6XXERg7yCZcirJSBSxxx',
'quantity' => 1,
]],
'payment_method_types' => [
'card',
],
'mode' => 'payment',
'success_url' => $YOUR_DOMAIN . '/success?session_id={CHECKOUT_SESSION_ID}',
'cancel_url' => $YOUR_DOMAIN . '/cancel.html',
]);
header("HTTP/1.1 303 See Other");
header("Location: " . $checkout_session->url);
Here is success.php
<?php
// This example sets up an endpoint using the Slim framework.
// Watch this video to get started: https://youtu.be/sGcNPFX1Ph4.
use Slim\Http\Request;
use Slim\Http\Response;
use Stripe\Stripe;
require 'vendor/autoload.php';
$app = new \Slim\App;
$app->add(function ($request, $response, $next) {
// Set your secret key. Remember to switch to your live secret key in production.
// See your keys here: https://dashboard.stripe.com/apikeys
\Stripe\Stripe::setApiKey('sk_test_51JZVslERg7yCZcir1A5JW4vVBMQoI5R5hmRwlsvbkfskrgql4WKemiDsSpjOHClMrH73MZzqInoVxiqXxaGDvAlxxxxxxxx');
return $next($request, $response);
});
$app->get('/order/success', function (Request $request, Response $response) {
$session = \Stripe\Checkout\Session::retrieve($request->get('session_id'));
$customer = \Stripe\Customer::retrieve($session->customer);
return $response->write("<html><body><h1>Thanks for your order, $customer->name!</h1></body></html>");
});
$app->run();
In this edition of Stripe Developer Office Hours, follow along as CJ Avilla walks through the fundamentals of PHP with Slim.
Resources
- Slim web framework http://www.slimframework.com/
- curl command line tool https://curl.haxx.se/
- phpdotenv https://github.com/vlucas/phpdotenv
- Stripe Webhooks Guide https://stripe.com/docs/webhooks/bui...
Before it's success.html but now need change to php
I not sure slim framework does it work for my sever-side
Before I used composer install stripe lib
I have to sleep. Please answer me that I will read the message woke up
👍 Sorry for the wait, it got busy in here very quickly. Will leave an answer for you soon!
I think your code is slightly wrong - the success url from your screenshot is http://prosfinity.com/public/success?session_id=cs_test_xxx, but your code has $app->get('/order/success', function (Request $request, Response $response).
I believe you need to change your success url to be http://prosfinity.com/order/success?session_id=cs_test_xxx to match what you have in your code