#rupinder_api
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/1344592637969301545
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
const fetchClientSecret = async () => {
try {
return await $.get('{{ route("stripe.client.secret") }}', {
_token: '{{ @csrf_token() }}',
stripe_payment_id: $("#stripe_payment_id").val(),
});
} catch (error) {
console.error("Error fetching client secret:", error);
}
};
const {
clientSecret,
id
} = await fetchClientSecret();
$('#pay_with_wallet').attr('data-key', id)
const appearance = {
theme: 'stripe',
variables: {
colorPrimary: '#0570de',
colorBackground: '#F0F0F0',
colorText: '#30313d',
colorDanger: '#df1b41',
spacingUnit: '5px',
fontWeightNormal: '500',
border: 'none',
accessibleColorOnColorPrimary: '#1A1B25',
logoColor: 'dark'
},
rules: {
'.Input': {
backgroundColor: '#ffffff',
border: '2px solid #4FAD54 '
}
}
};
elements = stripe.elements({
clientSecret,
appearance
});
const paymentElementOptions = {
layout: {
type: 'tabs',
defaultCollapsed: false,
},
defaultValues: {
billingDetails: {
address: {
country: '{{get_system_region()->code}}'
}
}
}
};
const paymentElement = elements.create("payment", paymentElementOptions);
paymentElement.mount("#stripe-checkout-form");
this is the code to intialize form, but issue with this is that on every page load it is creating payment intent in stripe
but I donot want that to happen
as with stripe , I am using other payment gateways too so even user pays using that an incomplete intent is created in stripe
Hello, have you tried following this guide? https://docs.stripe.com/payments/accept-a-payment-deferred - it goes through step by step how to use a deferred Intent flow which is what you're looking for
yes, this is what I followed
but what I want is not to create incomplete payment intents
these
just when user clicks on pay button these to create
I don't think you've followed the guide my colleague linked
You've followed the guide where you create the intent before mounting the Element โ you want the opposite
That's what the link outlines
okay, let me check