#codename-mid9it_subscription-manual-redirect
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/1222160877265092672
๐ 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_code, 4 hours ago, 47 messages
- codename-mid9it_webhooks, 4 days ago, 12 messages
- codename-mid9it_code, 4 days ago, 80 messages
- codename-mid9it_error, 6 days ago, 14 messages
the rest of the code below
// Create the subscription with the found product ID
$subscription = $stripe->subscriptions->create([
'customer' => $customer,
'items' => [['price' => $product_id]],
"currency" => $_currency,
"description" => $paydesc,
//'amount' => $finalamount,
'expand' => ['latest_invoice.payment_intent'],
]);
// Add var_dump() here to check payment_intent status and next_action type
var_dump($subscription->latest_invoice->payment_intent->status);
var_dump($subscription->latest_invoice->payment_intent->next_action->type);
$log_content = ob_get_clean(); // Get the buffered content
file_put_contents('payment_intent_log.txt', $log_content, FILE_APPEND); // Append content to log file
// 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;
//var_dump($redirectUrl);
header("HTTP/1.1 303 See Other");
header("Location: " . $redirectUrl->url);
exit();
} else {
{
ah, were you on stackoverflow earlier too?
but yeah anyway you need to "re-confirm" the PaymentIntent if you really want to do it this way instead of using the SDK.
$paymentIntent = $stripe->paymentIntents->confirm($subscription->latest_invoice->payment_intent->id, ['return_url' => "https://myexample.com/success"]);
where do i add this piece please?
I'd probably do it after checking if ($subscription->latest_invoice->payment_intent->status === 'requires_action')
codename-mid9it_subscription-manual-redirect
i'm being redirected to my homepage,
i understand the use of confirming the paymentintent but my payment intent next action still says use_stripe_sdk
make sure you're looking at the variable returned by calling the API and not the old one
like after you run that code $paymentIntent->next_action->type would definitely be redirect_to_url; and then you can the logic to do the redirect using $paymentIntent->next_action.
i still don't understand i'm sorry
this is my code, yeah?
now if i add the $paymentIntent = $stripe->paymentIntents->confirm($subscription->latest_invoice->payment_intent->id, ['return_url' => "https://myexample.com/success"]);
after the // Check if 3DS authentication is required, I'll still get the same issue
Hi there ๐ jumping in as my teammate needs to step away. Can you share the ID of a request (req_) where you made that follow-up confirmation request passing a return_url? So I can take a closer look at what is happening in your flow.
sub_1OyZqGDLt3ELpQcmkRkSnLwn
Hm, the output of your confirmation request is showing next_action contains redirect_to_url :
https://dashboard.stripe.com/test/logs/req_ZFBhPTSIgLvMW5
Are you seeing something different?
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
from the request post body no, the url is correct.\
but the authentication modal doesn't show up and dashboard still says the payment is incomplete
Let's take a step back.
This started because you wanted to see redirect_to_url as the next_action instead of use_stripe_sdk. That indicates that you want to handle redirecting the customer to the authentication flow instead of letting our SDK handle that for you.
You pass a return_url when making a server-side confirmation request to trigger that behavior, which we see happening in the request that I shared.
Are you now directing your customer to the URL that is provided to you so they can complete the authentication flow?
no, i believe i'm not because the url that is provided to me in my "if" logic.
so are you saying i put this
$paymentIntent = $stripe->paymentIntents->confirm(
$subscription->latest_invoice->payment_intent->id,['return_url' => "https://xxxxxx/xxxxx
/MyAccount.php"]);
// Update $subscription with the latest information
$subscription = $stripe->subscriptions->retrieve($subscription->id, ['expand' => ['latest_invoice.payment_intent']]);
before the "if" logic?
I'm not exactly sure I'm following, but maybe. You have the request now that is giving you the URL you need to send the customer to so they can complete the required authentication, you'll now to need to adjust your logic to detect the presence of that URL and direct your customer to it.
this is my initial code then i was asked to add the confirm paymentIntent line
but i did it after my "if" logic
so if my the confirm paymentIntent code changes the use_stripe_sdk to redirect url does it mean that i should place the confirm paymentIntent code before my "if" logic?
Sounds like it, does the flow work as expected in your testing if you do?
okaaayyyy yes it did change the use sdk to redirect url
but i'm getting a new error
Notice: Trying to get property 'url' of non-object on line 221
and line 221 is
header("Location: " . $redirectUrl->url);
exit();
What is the code you're running? What object is it looking at? What is the structure of that object?
this is the code i'm currently running
// Create the subscription with the found product ID
$subscription = $stripe->subscriptions->create([
'customer' => $customer,
'items' => [['price' => $product_id]],
"currency" => $_currency,
"description" => $paydesc,
'expand' => ['latest_invoice.payment_intent'],
]);
//Confirm Payment Intent
$paymentIntent = $stripe->paymentIntents->confirm(
$subscription->latest_invoice->payment_intent->id,['return_url' => "https://bnlf.org.uk/join-us/MyAccount.php"]);
// Update $subscription with the latest information
$subscription = $stripe->subscriptions->retrieve($subscription->id, ['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("HTTP/1.1 303 See Other");
header("Location: " . $redirectUrl->url);
exit();
} else {
i was given this header by another support few hours ealier
header("HTTP/1.1 303 See Other");
header("Location: " . $redirectUrl->url);
exit();
i believe the url is supposed to be gotten from stripe to redirect to the user bank and the return_url should be after the user has authenicated the payment from their bank
It seems like you're probably already getting the URL directly inside of $redirectUrl and don't need to point to it with ->url. If you log out the contents of $redirectUrl, what does it contain?