#codename-mid9it_code
1 messages ¡ Page 1 of 1 (latest)
đ Welcome to your new thread!
â˛ď¸ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
âąď¸ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
đ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1222048827599491122
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
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.
- codename-mid9it_webhooks, 3 days ago, 12 messages
- codename-mid9it_code, 4 days ago, 80 messages
- codename-mid9it_error, 5 days ago, 14 messages
// Create the subscription with the found product ID
$subscription = $stripe->subscriptions->create([
'customer' => $customer,
'items' => [['price' => $product_id]],
"currency" => $_currency,
"description" => $paydesc,
//'amount' => $finalamount,
'payment_behavior' => 'default_incomplete',
'payment_settings' => ['save_default_payment_method' => 'on_subscription'],
'expand' => ['latest_invoice.payment_intent'],
]);
// Check if 3DS authentication is required
if ($subscription->latest_invoice->payment_intent->status === 'requires_action' &&
$subscription->latest_invoice->payment_intent->next_action->type === 'redirect_to_url'
) {
// Redirect the customer to the 3DS authentication page
$redirectUrl = $subscription->latest_invoice->payment_intent->next_action->redirect_to_url->url;
header('Location: ' . $redirectUrl);
exit();
} else {
i can also echo this response
// Return the subscription ID and client secret as a JSON response.
header('Content-Type: application/json');
$stripeResponse = json_encode([
'subscriptionId' => $subscription->id,
'clientSecret' => $subscription->latest_invoice->payment_intent->client_secret,
]);
my problem is the redirect doesn't work to 3DS. instead i'm redirect to my homepage.
Hi there, what problem do you face with the latest Stripe.js? Can you tell me more about that?
Hello, Jack
nothing it's just that my code is using the v2
v2 is already deprecated for a long time, and I'd highly recommend you using the latest Stripe.js
i didn't write the original code and it's not in my job scope to upgrade their api. it's for my client not a personal code but i do understand that v3 would be the best
but currently i can only work with i wwas given
so is there anything wrong with my logic? i'm trying to authentic on my server then redirect the user
OK, if that's the case, you can manually redirect your customer to the 3DS page https://docs.stripe.com/payments/3d-secure/authentication-flow?platform=web#manual-redirect
but that is was i did in my code, yeah?
I saw you did extract the redirect URL, but I'm not sure calling header('Location: ' . $redirectUrl); is the best way to redirect your customer to another URL.
so wwhat do you suggest please? (anyhting that doesn't included me upgrading to v3. that is not an option for me please)
an example subscription id you mean?
Looks like you didn't set the response code
header("HTTP/1.1 303 See Other");
header("Location: " . $checkout_session->url);```
https://docs.stripe.com/payments/accept-a-payment?platform=web&ui=stripe-hosted&lang=php#redirect-customers this is the PHP example code to redirect customer to the checkout session page. Can you add in header("HTTP/1.1 303 See Other"); in your code and try again?
hmmm. i don't have this in my code true
okay give me a few, i'll be right back asap
so i'm getting this errors
Unexpected Payment Status
Warning: Cannot modify header information - headers already sent by (output started at /xxxxxxxxxxus/payment.php:22) in xxxxxxxxxxxxxus/payment.php on line 304
// Check if 3DS authentication is required
if ($subscription->latest_invoice->payment_intent->status === 'requires_action' &&
$subscription->latest_invoice->payment_intent->next_action->type === 'redirect_to_url'
) {
// Redirect the customer to the 3DS authentication page
$redirectUrl = $subscription->latest_invoice->payment_intent->next_action->redirect_to_url->url;
header("HTTP/1.1 303 See Other");
header("Location: " . $redirectUrl->url);
exit();
} else {
What's the payment intent ID?
i didn't define any in my code
Or share with me the subscription ID
ph okay
sub_1OyTCHDLt3ELpQcm9ggFAb2F
The payment intent isn't in require_action status, so the code to redirect shouldn't be executed
Looks like the error is related to your application (Cannot modify header information - headers already sent by (output started at /xxxxxxxxxxus/payment.php:22) in xxxxxxxxxxxxxus/payment.php on line 304) , can you pair with an experience PHP engineer to troubleshoot?
i believe this happens because of this in my code
'payment_behavior' => 'default_incomplete',
'payment_settings' => ['save_default_payment_method' => 'on_subscription'],
because usually in the event log without the above code, i'll see a " payment ...... waiting for a user verification...." line
brb lemme ajust the code to show response
everyone is busy sadly
hi,
you can check this subID
sub_1OyTTXDLt3ELpQcmIeabJCU4
The error (can't modify header information) isn't Stripe specific. I suggest you should work with your peers when they are available to go through your code.
oh alright, but you agree at least fr now my php logic is correct
although i understand it'll be adjusted as time goes but for now if the headers are fixed i should be good to go yeah?
The code snippets that you shared earlier look OK to me, but the error is thrown from other part of the code.