#rpanda624-3ds-failed
1 messages · Page 1 of 1 (latest)
Hey. Which test card data were you using when 3DS failed?
Can you share the ID of a failed Payment Intent
yes
Live Demo at CodexWorld - Stripe Subscription Payment API Integration in PHP by CodexWorld
i just copied the code
When i applied in my folder
it is faied due to 3d authntication failed
Live Demo at CodexWorld - Stripe Subscription Payment API Integration in PHP by CodexWorld
this is working well
Are u still with me?
That link isn't really much help here I'm afraid. I've no idea who wrote that or what the source code is doing!
Can you share the ID of a failed Payment Intent?
You can find this from your Stripe Dashboard
Yep, please bear with me
Are u checking?
I am
The bank/card issuer requested an 3DS/auth check in this instance. This is reflected on the PI status: requires_action
Ah, you're an Indian merchant. Will be probably be because of RBI regulations: https://support.stripe.com/questions/rbi-regulations-affecting-payments-from-india-issued-cards
Find help and support for Stripe. Our support center provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
Which requires auth for all payments
You'll need to handle this accordingly using Stripe.js
Well you'd need to share your code for me to be able to answer that!
How are you returning the Payment Intent to your client application?
Well you'd need to share your code for me to be able to answer that!
Thanks
i am giving you a file
can you check plz
I can't download that I'm afraid. You can just paste the relevant code into this chat
<?php
// Subscription plans
// Minimum amount is $0.50 US
// Interval day, week, month or year
$plans = array(
'1' => array(
'name' => 'Weekly Subscription',
'price' => 1,
'interval' => 'week'
),
'2' => array(
'name' => 'Monthly Subscription',
'price' => 1,
'interval' => 'month'
),
'3' => array(
'name' => 'Yearly Subscription',
'price' => 950,
'interval' => 'year'
)
);
$currency = "USD";
/* Stripe API configuration
- Remember to switch to your live publishable and secret key in production!
- See your keys here: https://dashboard.stripe.com/account/apikeys
*/
define('STRIPE_API_KEY', 'sk_test_Eq65nS4rqhsxG5rAA9KcPDMy00ZbyAYJqP');
define('STRIPE_PUBLISHABLE_KEY', 'pk_test_LPuAjxWw5zDIQI8x3T9iZoTp00guT10hhu');
?>
View Page
Payment.php
Only problem is 3d authnticate failed
Yeah your integration is very dated. It's using older APIs (tokens) and doesn't factor in 3DS auth
I'd recommend following this guide here: https://stripe.com/docs/billing/subscriptions/build-subscription?ui=elements
Or look at the subscription code samples here: https://github.com/stripe-samples/subscription-use-cases
What's a dynamic price?
suppose one customer put price , this price will automatically going to stripe checkout page
Then you'd need to build the UI to enable that selection yourself. But that's no different to a 'fixed price' subscription
let me check
can u tell me plz
i want to show one text box and fill the amount
it will redirct to stripe checkout page
This is a good guide to use Checkout with subscriptions: https://stripe.com/docs/billing/quickstart
I can help you with a specific question/issue, yes. Is there an error?
<form action="/create-checkout-session" method="POST">
<!-- Add a hidden field with the lookup_key of your Price -->
<input type="hidden" name="lookup_key" value="pricedynamically" />
<button id="checkout-and-portal-button" type="submit">Checkout</button>
</form>
<form action="/create-checkout-session" method="POST">
Where it get create-checkout-session
page
ynnoj
Did you understand
What i am saying?
Are u there?
Where it get create-checkout-session
That's outlined at the link I shared. You'd create a backend function to handle the Checkout Session creation
Have you considering a low-code solution like Payment Links? https://stripe.com/docs/payments/no-code
I need code but
it should be simple code
- One text box
then enter amount
then redirect to stripe checkout page
We don't write code/integrations for users here
I can help with specific issues, but we don't write the code
Ok i understand
but can you tell me what is the exact issue
const STRIPE_PUBLISHIABLE_KEY = "pk_test_LPuAjxWw5zDIQI8x3T9iZoTp00guT10hhu";
const STRIPE_SECRET_KEY = "sk_test_Eq65nS4rqhsxG5rAA9KcPDMy00ZbyAYJqP";
const SUBSCRIPTION_PLAN_ID = "";
const PRODUCT_NAME = 'PHP Video Tutorials with eBook';
const PRODUCT_TYPE = 'service';
What i put in the SUBSCRIPTION_PLAN_ID
I'm not sure what this is referencing here, but I guess it would be the ID of a Price object
A Plan is an older object/API: https://stripe.com/docs/billing/migration/migrating-prices
Pass it where?
lib/Config.php
<?php
namespace Phppot;
class Config
{
const STRIPE_PUBLISHIABLE_KEY = "pk_test_LPuAjxWw5zDIQI8x3T9iZoTp00guT10hhu";
const STRIPE_SECRET_KEY = "sk_test_Eq65nS4rqhsxG5rAA9KcPDMy00ZbyAYJqP";
const SUBSCRIPTION_PLAN_ID = "";
const PRODUCT_NAME = 'PHP Video Tutorials with eBook';
const PRODUCT_TYPE = 'service';
}
?>
Sir
Are u still connect with me?
You would use that price_xxx ID when creating the Subscription/Checkout Session
Ok
but how to pass this id in const SUBSCRIPTION_PLAN_ID = "";
Do you have any idea
what do you mean by 'how to pass'?
price_xxx ID - how do i pass this id in const SUBSCRIPTION_PLAN_ID = "";
you enter it. const SUBSCRIPTION_PLAN_ID = "price_xxx";
it works (Prices work in any API that requires a Plan, it's forwards compatible.
i know SUBSCRIPTION_PLAN_ID = "price_xxx";
but price id is dynamic accroding the price
tell me plz what is the variable i will use
Just like
const STRIPE_PUBLISHIABLE_KEY = "pk_test_LPuAjxWw5zDIQI8x3T9iZoTp00guT10hhu";
const STRIPE_SECRET_KEY = "sk_test_Eq65nS4rqhsxG5rAA9KcPDMy00ZbyAYJqP";
that question doesn't make sense I'm afraid.
this file is for static configuration of static things. If the price is dynamic you wouldn't use a static Price ID in a config file, you'd write some specific custom code instead.
you'd write code to create a Price for the amount you want at the time of the customer creating the subscription.
you kind of already have that in some of the code you shared above where you called \Stripe\Plan::create before creating a subscription. Same idea.
what does that mean?
public function createPlan()
{
$plan = \Stripe\Plan::create([
'amount' => 2000,
'currency' => 'usd',
'interval' => 'month',
'product' => ['name' => Config::PRODUCT_NAME],
]);
return $plan;
}
public function createCheckoutSession($planId)
{
$session = \Stripe\Checkout\Session::create([
'payment_method_types' => ['card'],
'subscription_data' => [
'items' => [[
'plan' => $planId,
]],
],
'success_url' => 'https://www.yourdomain.com/stripe-checkout/success.php?session_id={CHECKOUT_SESSION_ID}',
'cancel_url' => 'https://www.yourdomain.com/stripe-checkout/cancel.php',
]);
return $session;
}
$planId is creating but it is not redirecting to stripe checkout page
what does "not redirecting" mean? that code you posted doesn't directly do a redirect.
redirect means
stripe checkout page
<script>
var stripe = Stripe('<?php echo Config::STRIPE_PUBLISHIABLE_KEY; ?>');
//Setup event handler to create a Checkout Session when button is clicked
document.getElementById("subscribe").addEventListener("click", function(evt) {
createCheckoutSession('<?php echo Config::SUBSCRIPTION_PLAN_ID; ?>').then(function(data) {
// Call Stripe.js method to redirect to the new Checkout page
stripe.redirectToCheckout({
sessionId: data.id
}).then(handleResult);
});
});
</script>
it is not SUBSCRIPTION_PLAN_ID
indeed.
Thats why it is not redirectinbg stripe checkout page
I agree!
then maybe change the code? I don't know where you call that createPlan() function from. But I would probably
- change the signature of the frontend
createCheckoutSessionfunction to not take an ID and remove the reference to the Config class - on the backend, change the logic so that when that endpoint is called, you call
createPlan(), take the ID returned, and then call into yourcreateCheckoutSessionPHP function with it.
can you tell me without craeting product using api , can i create plan_id
using price
you always need a Product(and then a Price or a Plan). The Product is required.
but when i click on this link and submit the button
it is automatocally created product
repeatly
yes, it does (that's what happens when using product => [...] in the \Stripe\Plan::create function to pass Product details ad-hoc), it creates a "backfilled" Product archived object. Shouldn't be a problem. Did you have a question?