#JacquesVivi
1 messages · Page 1 of 1 (latest)
elements = stripe.elements(getElementsOptions());
paymentElement = elements.create('payment', getElementOptions());
await paymentElement.mount('#payment-element');
hi! well it works differently on the PaymentElement. Let me look...
Thanks
the best way would be to use the Deferred flow (https://stripe.com/docs/payments/accept-a-payment-deferred?platform=web) and that way you can view the details of the PaymentMethod that was entered and inspect its brand
Hum. When I'm reading the documentation
I think I already do that
let elements: any = ''
let paymentElement: any = ""
async function setPayment() {
elements = stripe.elements(getElementsOptions());
paymentElement = elements.create('payment', getElementOptions());
await paymentElement.mount('#payment-element');
paymentElement.on('ready', () => isLoading.value = false)
}
function getElementsOptions() {
return {
appearance: {
theme: 'stripe',
fontFamily: "Roboto",
},
clientSecret: payment.keyClient
}
}
/*
-
PAYMENT
*/
const isPaymentSubmited = ref(false)
const isError = ref(false)
async function pay() {isPaymentSubmited.value = true
paymentElement.update({ readOnly: true });
if (payment.amount > 0) {
// CONFIRM PAYMENT
const { error } = await stripe.confirmPayment({
elements,
confirmParams: getConfirmParams(),
//redirect: 'if_required'
});if (error) {
const messageContainer = document.querySelector('#error-message');
if (messageContainer) {
messageContainer.textContent = error.message;
isError.value = true;
}
}} else {
// CONFIRM SETUP
const { error } = await stripe.confirmSetup({
elements,
confirmParams: getConfirmParams(),
//redirect: 'if_required'
});if (error) {
const messageContainer = document.querySelector('#error-message');
if (messageContainer) {
messageContainer.textContent = error.message;
isError.value = true;
}
}
}paymentElement.update({ readOnly: false });
isPaymentSubmited.value = false
}
Sorry its not lisible
that is not the deferred flow, since you have a PaymentIntent client secret immediately, in the deferred flow you would create the PaymentMethod first and then you can create the PaymentIntent after
you can wrap code in
backticks
so overall I'd suggest using https://stripe.com/docs/payments/build-a-two-step-confirmation here
we also have a beta for blocking the ability to enter certain card brands entirely in PaymentElement, but your account would need access to it, so without that beta this would be the best option
Ok. For the moment I don't understand. But I will sudy that
There no other easy options for me ?
I just want to block amex card, cause fees are too hight
(And I don't want to use Radar)
those are the options really : - the deferred/two-step integration ; - the beta for controlling allowed cards ; - Radar ; - not using PaymentElement and using CardElement