Description
Running into a similar issue as #214 although it's not clear how that was solved.
I can't get my customized payment form working without providing a client secret to stripe.elements() - I'm using the Appearance API to modify the form, so I need to call it like this:
const elements = stripe.elements({clientSecret, appearance});
If I pass a totally bogus value as clientSecret, the Elements JS fails to run and the form doesn't get initalized. If I pass a value in the correct format pi_blah_secret_blah then the JS runs but I see in the console a 400 to https://api.stripe.com/v1/elements/sessions and a 404 to https://api.stripe.com/v1/payment_intents however it seems like the payment still goes through. If I pass in any client secret from any past PaymentIntent made through the example Commerce templates (which can be found digging through the intentData in the stripe_paymentintents DB table) it works with no 400 errors, although that's clearly not what I should be doing. Not sure how using a client secret for a different transaction would impact things - it hasn't caused any strange behaviour yet in testing though (maybe if my Stripe account were in live mode this would break things, I dunno).
Not sure that this is necessarily a bug or just a documentation issue, but in any case, are you able to provide an example of the correct way to get either the client secret, Stripe reference number, or PaymentIntent for the current cart and/or the current subscription plan? If I had the ref I could get the client secret as below (in a custom module). However, I'm not sure if its possible to get the ref value for the current cart/subscription transaction prior to any payment being sent to Stripe (as the payment form hasn't even been initialized yet).
$ref = 'pi_XXXXXXXXXXXXXXXXX';
$intent = StripePlugin::getInstance()->getPaymentIntents()->getPaymentIntentByReference($ref);
$intentData = json_decode($intent->intentData);
$clientSecret = $intentData->client_secret;
Additional info
- Craft CMS version: 4.3.1
- Stripe for Craft Commerce version: 3.0.1
- PHP version: 8.1.5
Description
Running into a similar issue as #214 although it's not clear how that was solved.
I can't get my customized payment form working without providing a client secret to
stripe.elements()- I'm using the Appearance API to modify the form, so I need to call it like this:const elements = stripe.elements({clientSecret, appearance});If I pass a totally bogus value as clientSecret, the Elements JS fails to run and the form doesn't get initalized. If I pass a value in the correct format
pi_blah_secret_blahthen the JS runs but I see in the console a 400 to https://api.stripe.com/v1/elements/sessions and a 404 to https://api.stripe.com/v1/payment_intents however it seems like the payment still goes through. If I pass in any client secret from any past PaymentIntent made through the example Commerce templates (which can be found digging through the intentData in the stripe_paymentintents DB table) it works with no 400 errors, although that's clearly not what I should be doing. Not sure how using a client secret for a different transaction would impact things - it hasn't caused any strange behaviour yet in testing though (maybe if my Stripe account were in live mode this would break things, I dunno).Not sure that this is necessarily a bug or just a documentation issue, but in any case, are you able to provide an example of the correct way to get either the client secret, Stripe reference number, or PaymentIntent for the current cart and/or the current subscription plan? If I had the ref I could get the client secret as below (in a custom module). However, I'm not sure if its possible to get the ref value for the current cart/subscription transaction prior to any payment being sent to Stripe (as the payment form hasn't even been initialized yet).
Additional info