#santiago-checkout-returnurl
1 messages · Page 1 of 1 (latest)
Hello! We'll be with you shortly. Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- santiago-checkout-csp, 2 days ago, 44 messages
santiago-checkout-returnurl
@daring grail there are no variables. Usually you have your own cookie logic to recognize who that customer is, what Session you created for them, etc.
I understand that koopajah, but I thought it'll also return something else to check for or checkout session as well ? if is valid? reason for that is because I do not want the customer access the 'success' page directly becaues i do have to create the cookie before the payment. but nothing stop customer for just not paying and going directly on success page by typing on the url. and accessing the session..
- I go on your website, you track me
- You send me to Checkout
- I pay
- I get sent back to your
success_url - Your code you wrote knows who I am, you tracked me at step #1 so you know what I was paying for, you have my Checkout Session id stored in your database for example
At that point you can check it in the API, confirm I paid, etc.
yes that's what i needed.. so i can access the chckout session id
thanks for the link iw as looking for them but coudlnt find them before
for the second link, where can I see docs of stripe library to see what other classes I have access to? can't find it.. but for example. the one that says $customer->name , etc what where can I see all the options
Hi, do you want to see in PHP only? It has a Github repo
yes php only is fine, where is the github repo? is for stripe hosted pages, i basically need to access the checkout.session.completed after the return to success
quick clarification, if i used the stripe hosted page, i won't be able to use the @file_get_contents('php://input'); that' shows on the first link to grab data, correct?
Yeah. Stripe Checkout Session only needs redirection
ok, and on redirection how i can track the checkout.session.completed so i know paid went through, i've read the github page but didn't find it, maybe i didn't read correctly. Also, as soon as a 'back button' is press.. does the session close, do i have to close it manually ?.
actually, before trying anyting , I tried the demo with customized success page, and i get this error
Fatal error: Uncaught Stripe\Exception\InvalidArgumentException: The resource ID cannot be null or whitespace. in /home/www/vendor/stripe/stripe-php/lib/Service/AbstractService.php:105 Stack trace: #0 /home/www/vendor/stripe/stripe-php/lib/Service/CustomerService.php(277): Stripe\Service\AbstractService->buildPath('/v1/customers/%...', NULL) #1 /home/www/guesthostad.lcsitmedia.com/success.php(7): Stripe\Service\CustomerService->retrieve(NULL) #2 {main} thrown in /home/www/vendor/stripe/stripe-php/lib/Service/AbstractService.php on line 10
You will track it via a webhook event checkout.session.completed covered here https://stripe.com/docs/payments/checkout/fulfill-orders
Not sure about the error, you would want to put some debug around /home/www/guesthostad.lcsitmedia.com/success.php(7): Stripe\Service\CustomerService->retrieve(NULL) to see how it is getting NULL
will check and see if i can figure it out.. I did see that link trying to use it with the session_id forward instead since i'm using stripe hosted redirect.
Hey, In my shop, only Mastercard works and not Klarna, Apple Pay, etc., even though it's active in Stripe. What can i do?
Also, i get this error with 'HTTP_STRIPE_SIGNATURE
i'm using stripe hosted
Notice: Undefined index: HTTP_STRIPE_SIGNATURE in /home/www/guesthostad.lcsitmedia.com/success.php on line 6
Looks like your request headers get stripped out somewhere. Do you use a language framework?
no, plain php
i can send you the code (it is straight from the demo to test)
havent added any error handling yet. as i'm just trying to make it work, i'm guessing to use the webhook i have to add it on the dashboard? to get the checkout.session.completed?
Please mask/remove your secret key value sk_test_xxx in your message
You shouldn't share secret key in a public place
true, forgot it is just a test key will do
<?php
require '../vendor/autoload.php';
$stripe = new \Stripe\StripeClient('*******');
print_r($GET['session_id']);
$event = null;
$sig_header = $SERVER['HTTP_STRIPE_SIGNATURE'];
$endpoint_secret = "wec";
try {
$session = $stripe->checkout->sessions->retrieve($_GET['session_id']);
print_r($session);
//print_r(checkout.session.completed);
//$customer = $stripe->customers->retrieve($session->customer);
// echo "<h1>Thanks for your order, $customer->name!</h1>";
http_response_code(200);
} catch (Error $e) {
http_response_code(500);
echo json_encode(['error' => $e->getMessage()]);
}
try {
$event = \Stripe\Webhook::constructEvent(
$session, $sig_header, $endpoint_secret
);
} catch(\UnexpectedValueException $e) {
// Invalid payload
http_response_code(400);
exit();
} catch(\Stripe\Exception\SignatureVerificationException $e) {
// Invalid signature
http_response_code(400);
exit();
}
?>
i think i understand it now , webhook is a separate page i thought all was in the same one..
Yes, and your code is a bit odd that it tries to Retrieve Checkout Session before construct event
This could help: https://stripe.com/docs/webhooks/quickstart?lang=php
yes I was just testing directly from the demo code to have an idea how your api works, will puti n order after.. it is using stripe_hosted so it has a success_url on it. but if i Use webhook, the webhook, i'll redirect from webhook instead from the stripe url?