#raghubendrasingh_code
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/1215649948780199936
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
๐ happy to help
hello @exotic robin
are you using the deferred flow?
yes
would you mind sharing your code please?
yes sure
var elementOptions = {
paymentMethodCreation: 'manual',
mode: 'payment',
amount: self.getElementsAmount(),
currency: self.getElementsCurrency()
};
if (this.getStripeParam("supportedMethods")) {
var supportedMethods = this.getStripeParam("supportedMethods");
var methodTypes = [...supportedMethods];
if ($.inArray('apple_pay', methodTypes) !== -1) {
methodTypes.splice($.inArray('apple_pay', methodTypes), 1);
}
if ($.inArray('google_pay', methodTypes) !== -1) {
methodTypes.splice($.inArray('google_pay', methodTypes), 1);
}
elementOptions.payment_method_types = methodTypes;
}
self.elements = self.stripe.elements(elementOptions);
self.ccField = self.elements.create('payment', self.getPaymentElementOptions());
self.ccField.mount('#' + self.getCode() + '-intents');
self.ccField.addEventListener('change', self.handleStripeChange.bind(self));
supportedMethods can have multiple values
like card,klarna,affirm,afterpay_clearpay
I get this error
{
error: {
code: "amount_too_small",
doc_url: "https://stripe.com/docs/error-codes/amount-too-small",
message: "Amount must be no less than $50.00 USD for the Affirm payment method.",
param: "deferred_intent.payment_method_types",
request_log_url: "https://dashboard.stripe.com/test/logs/req_71Z4YIzqi1kA8R?t=1709897582",
type: "invalid_request_error"
}
}
and the element fails to render
do you need any further information?
I'm trying to reproduce
Okay
yes that's expected behavior
what do you suggest then?
you can take a look at this video
it will help you understand the issue better
if you don't pass in the PaymentMethod types then we will use our judgement to show the supported payment methods
right, I know that
but our requirement is to let the user choose what options they want to use
so we set the methods conditionally
you can use the PaymentElement accordion with radio buttons layout https://docs.stripe.com/payments/payment-element#layout
can we do something where we skip the method and still render the others?
in my example the list will exclude Affirm, while the others render fine
not with the deferred flow
because you don't really know yet which PaymentMethods are supported or not
whereas if you create the Intent first and you pass a PM types array, we will filter out the ones that won't work
I understand, that's the definition of the deferred flow
but there's little you can do here
you either need to catch the errors on the front end and change the PM types
or move to the non-deferred flow
I do have a solution though
I will remove Affirm from the list when the amount is less than $50
the problem with this approach is, the minimum amount for Affirm can be configured in the dashboard
and if that changes we will have the problem again
exactly
can you point me to a reference for this?
I don't think we do have a proper documentation for this
I haven't tested that tbh, but I think you can surround the elements.create with a try/catch block