#raghubendrasingh_code

1 messages ยท Page 1 of 1 (latest)

trim templeBOT
#

๐Ÿ‘‹ 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.

wintry ravineBOT
exotic robin
#

๐Ÿ‘‹ happy to help

cold lotus
#

hello @exotic robin

exotic robin
#

are you using the deferred flow?

cold lotus
#

yes

exotic robin
#

would you mind sharing your code please?

cold lotus
#

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"
}
}

Learn more about error codes and how to resolve them.

#

and the element fails to render

#

do you need any further information?

exotic robin
#

I'm trying to reproduce

cold lotus
#

Okay

exotic robin
#

yes that's expected behavior

cold lotus
#

what do you suggest then?

#

you can take a look at this video
it will help you understand the issue better

exotic robin
#

if you don't pass in the PaymentMethod types then we will use our judgement to show the supported payment methods

cold lotus
#

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

exotic robin
cold lotus
#

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

exotic robin
#

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

cold lotus
#

Okay
for us the intent gets created later on

#

in the backend

exotic robin
#

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

cold lotus
#

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

exotic robin
#

exactly

cold lotus
exotic robin
#

I don't think we do have a proper documentation for this

cold lotus
#

Okay

#

in that case can you please explain it a bit
I need to give that a try

exotic robin
#

I haven't tested that tbh, but I think you can surround the elements.create with a try/catch block

wintry ravineBOT