#priya_97027
1 messages ยท Page 1 of 1 (latest)
๐ Would recommend reading through this: https://docs.stripe.com/docs/payments/accept-a-payment-deferred
I did. My question is just for mounting do we need the clientSecretKey? For now we are using CardElement and creating paymentIntent once user submits the payment.
So our flow is wherein once paymentIntent is created we do the payment. But in case of Payment Element looks like clientSecretKey (getting via creating payment intent) is mandate and we would need to call it and we don't want payment to process at this point.
This doc step demonstrates instantiating the payment element without a client secret https://docs.stripe.com/payments/accept-a-payment-deferred?platform=web&type=payment#add-the-payment-element-to-your-checkout-page
Thank you so much ๐
Another question, for adding other payment methods we add payment_method_types to the payment intent option but on adding this to the options to Elements without calling intent it's not rendering.
I tried
const options = {
mode: 'payment',
amount: 1099,
currency: 'usd',
// Fully customizable with appearance API.
appearance: {/.../},
layout: "tabs",
payment_method_types: ["card", "ideal"]
};
Is an error appearing in your developer console? That setup looks fine to me at first glance
Nope I am not able to see the other payment options.
Below is the basic code i am using
import React from 'react';
import {Elements} from '@stripe/react-stripe-js';
import {loadStripe} from '@stripe/stripe-js';
import CheckoutForm from './CheckoutForm';// Import CheckoutForm component
const stripePromise = loadStripe('pk_test_A7jK4iCYHL045qgjjfzAfPxu');
export const PaymentInfo = () => {
const options = {
mode: 'payment',
amount: 1099,
currency: 'usd',
// Fully customizable with appearance API.
appearance: {/.../},
layout: "tabs",
payment_method_types: ["card", "ideal"]
};
return (
<Elements stripe={stripePromise} options={options}>
<CheckoutForm />
</Elements>
);
};
export default PaymentInfo;
Ah it looks like iDEAL requires the payment to be in EUR https://docs.stripe.com/payments/ideal
Hmm now if I want to make it flexible for every type of currency how can I do that?
I think you can include different payment methods that take different currencies in the payment method options and we will only show the ones that support your specified currency
okay
On including below one
const options = {
mode: 'payment',
amount: 2000,
currency: 'cad',
// Fully customizable with appearance API.
appearance: {/.../},
layout: "tabs",
payment_method_types: ["card", "klarna", "afterpay_clearpay", "bancontact"]
};
Throws below console error
controller-4f2e2092970f51ef94ca6315f36e89a4.js:1 The currency provided (cad) is invalid. Payments with bancontact support the following currencies: eur.
I feel a mapping is required here. We cannot specify all the payment methods.
Interesting. I am not sure why that would error but ideal w/ USD did not. Looking in to this and will get back to you
That being said, if you leave that param out, we will determine which payment methods are compatible automatically https://docs.stripe.com/js/elements_object/create_without_intent#stripe_elements_no_intent-options-paymentMethodTypes
So as long as the PMs are turned on in your dashboard that will be a much simpler solution
okay. Another thing I wanna point out is I am trying to use accordion layout but I still see tabs layout somehow.
import React from 'react';
import {Elements} from '@stripe/react-stripe-js';
import {loadStripe} from '@stripe/stripe-js';
import CheckoutForm from './CheckoutForm';// Import CheckoutForm component
const stripePromise = loadStripe('pk_test_A7jK4iCYHL045qgjjfzAfPxu');
export const PaymentInfo = () => {
const options = {
mode: 'payment',
amount: 2000,
currency: 'cad',
layout: {
type: 'accordion'
},
// Fully customizable with appearance API.
appearance: {/.../},
payment_method_types: ["card", "klarna", "afterpay_clearpay"]
};
return (
<Elements stripe={stripePromise} options={options}>
<CheckoutForm />
</Elements>
);
};
export default PaymentInfo;
I need the accordion view with radio buttons here.
Layout is a parameter on the Payment Element itself, rather than a top level setting that you set when creating the overall Elements instance https://docs.stripe.com/js/elements_object/create_payment_element#payment_element_create-options-layout
Yes tried this as well
import React from 'react';
import { PaymentElement } from '@stripe/react-stripe-js';
export const CheckoutForm = () => {
const options = {
layout: {
type: 'accordion'
}
};
return (
<form style={{ margin: '30px' }}>
<PaymentElement options={options}/>
<button>Pay now</button>
</form>
);
};
export default CheckoutForm;
Another thing that's weird is the moment I add affirm to the payment method type console throws below error even tho amount is 2000.
controller-4f2e2092970f51ef94ca6315f36e89a4.js:1 Amount must be no less than $50.00 CAD for the Affirm payment method.
Here's the code
import React from 'react';
import {Elements} from '@stripe/react-stripe-js';
import {loadStripe} from '@stripe/stripe-js';
import CheckoutForm from './CheckoutForm';// Import CheckoutForm component
const stripePromise = loadStripe('pk_test_A7jK4iCYHL045qgjjfzAfPxu');
export const PaymentInfo = () => {
const options = {
mode: 'payment',
amount: 2000,
currency: 'cad',
appearance: {},
payment_method_types: ["card", "affirm", "klarna", "afterpay_clearpay"]
};
return (
<Elements stripe={stripePromise} options={options}>
<CheckoutForm />
</Elements>
);
};
export default PaymentInfo;
Strange, that same code where you set the options on the PaymentElement works for me. Trying to think of what may be happening here
I hope it's not the stripe version
"stripe": "^14.16.0", "@stripe/react-stripe-js": "^2.4.0", "@stripe/stripe-js": "^2.4.0",
This is what I have. Thinking maybe released in a different one.
I am sending all the code below
import React from 'react'; import {Elements} from '@stripe/react-stripe-js'; import {loadStripe} from '@stripe/stripe-js'; import CheckoutForm from './CheckoutForm';// Import CheckoutForm component const stripePromise = loadStripe('pk_test_A7jK4iCYHL045qgjjfzAfPxu'); export const PaymentInfo = () => { const options = { mode: 'payment', amount: 2000, currency: 'cad', appearance: {}, payment_method_types: ["card", "affirm", "klarna", "afterpay_clearpay"] }; return ( <Elements stripe={stripePromise} options={options}> <CheckoutForm /> </Elements> ); }; export default PaymentInfo;
import React from 'react'; import { PaymentElement } from '@stripe/react-stripe-js'; export const CheckoutForm = () => { const options = { layout: "accordion" }; return ( <form style={{ margin: '30px' }}> <PaymentElement options={options}/> <button>Pay now</button> </form> ); }; export default CheckoutForm;
Hello! I'm taking over and catching up...
Is it possible your browser is caching an older version of the code? Have you tried a hard refresh (hold shfit while reloading the page)?
Also wondering if you can share a screenshot of the Payment Element you're seeing. Something might become apparent if we can see what you're currently seeing?
๐ค
If you view the source in your browser using the dev tools can you confirm it's using the code that's specifying accordion?
ok this is weird. My bad. The checkout form is not using the updated code.
yep restarted the server. Working now. thank you. I wanted to check about the multiple payment methods being defined regardless of the currency.
It's throwing an error in console.
message : "The currency provided (cad) is invalid. Payments with ideal support the following currencies: eur." param : "deferred_intent.payment_method_types" request_log_url : "https://dashboard.stripe.com/test/logs/req_9sO5LVo0FvPt5y?t=1707930332"
Is it like we need to feed in payment type based on currency?
Yeah, if you specify specific payment method types some of them may not be compatible with the currency you're using. iDEAL, as the error states, only supports EUR as documented here: https://docs.stripe.com/payments/ideal
okay. Last question here ... If I add affirm to the method type then it throws min amount error as below even tho the amount sent is 2000.
code
:
"amount_too_small"
doc_url
:
"https://stripe.com/docs/error-codes/amount-too-small"
message
:
"Amount must be no less than $50.00 CAD for the Affirm payment method."
param
:
"deferred_intent.payment_method_types"
request_log_url
:
"https://dashboard.stripe.com/test/logs/req_TpZcgYQMfYFGl1?t=1707930463"
status
:
400
type
:
"invalid_request_error"
const options = {
mode: 'payment',
amount: 2000,
currency: 'cad',
appearance: {},
payment_method_types: ["card", "klarna", "afterpay_clearpay", "affirm"]
};