#codename-mid9it_code

1 messages ¡ Page 1 of 1 (latest)

fast plinthBOT
#

👋 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.

muted sinewBOT
#

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.

stuck coyote
#

// 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.

muted sinewBOT
short plank
#

Hi there, what problem do you face with the latest Stripe.js? Can you tell me more about that?

stuck coyote
#

nothing it's just that my code is using the v2

short plank
#

v2 is already deprecated for a long time, and I'd highly recommend you using the latest Stripe.js

stuck coyote
#

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

short plank
stuck coyote
short plank
#

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.

stuck coyote
short plank
#

Can you share with me the PaymentIntent ID?

#

One sec

stuck coyote
short plank
#

Looks like you didn't set the response code

#
header("HTTP/1.1 303 See Other");
header("Location: " . $checkout_session->url);```
stuck coyote
stuck coyote
#

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 {

short plank
#

What's the payment intent ID?

stuck coyote
#

i didn't define any in my code

short plank
#

Or share with me the subscription ID

stuck coyote
#

sub_1OyTCHDLt3ELpQcm9ggFAb2F

short plank
#

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?

stuck coyote
#

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

stuck coyote
#

you can check this subID

#

sub_1OyTTXDLt3ELpQcmIeabJCU4

short plank
#

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.

stuck coyote
#

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?

short plank
#

The code snippets that you shared earlier look OK to me, but the error is thrown from other part of the code.