#ahmad-updatedPI-PE
1 messages · Page 1 of 1 (latest)
Hello! You're specifying /confirm_payment/ for the return_url, which is not valid. You need to specify a full URL (like what you would type into a browser), not just a path.
Hi
basically i use django URLs and in this i defiend this
const return_url = "{% url 'confirm_payment' %}"; // Corrected usage of return_url
Yeah, that won't work. You need a full URL, like https://example.com/confirm_payment/ or similar.
okay let me try with this
yes i know
problem solved but now i have new problem can i ask you ?
Sure, what's up?
basically i create an intent_id but i will update the intent after the customer apply promocode after update intent i create a checkout but the payment was dutucted fully not discounted price
fetch("http://api.virya.localhost:8000/tranzend/update-intent/", {
method: 'POST',
headers: {
'Authorization': authorizationHeader,
'Content-Type': 'application/json', // Add this line
},
body: JSON.stringify({
intent_id: intentId,
new_amount: newTotalAmount,
}),
}).then((response) => {
if (response.ok) {
return response.json();
} else {
throw new Error("Network response was not ok");
}
}).then(data => {
if (data.status === 1) {
showSuccess("Promo Code Sucessfully Applied");
} else {
// Display the error message on the page with red color
showError(data.message || 'An error occurred during Intent Creation please refresh the Page .');
// Add a click event listener to the "Place order" button
document.getElementById('place-order-button')
.addEventListener('click', handleSubmit);
async function handleSubmit(e) {
e.preventDefault();
showError('');
showSuccess('');
showLoader();
const { error } = await stripe.confirmPayment({
elements,
confirmParams: {
// Make sure to change this to your payment completion page
return_url: "https://flolo.virya.io/confirm_payment/",
},
});
You need to tell Elements to fetch the updated Intent: https://stripe.com/docs/js/elements_object/fetch_updates
can i use it within the confirmPayment call or outside ?
You need to call it before you call confirmPayment.
You need to update the Intent, then call fetchUpdates, then call confirmPayment, in that order.
can you give me any example code because its seems to not working on my side
I don't think we have example code beyond what I linked above. When you say it's not working what does that mean exactly? How is it not working?
fetch("http://api.virya.localhost:8000/tranzend/update-intent/", {
method: 'POST',
headers: {
'Authorization': authorizationHeader,
'Content-Type': 'application/json', // Add this line
},
body: JSON.stringify({
intent_id: intentId,
new_amount: newTotalAmount,
}),
}).then((response) => {
if (response.ok) {
return response.json();
} else {
throw new Error("Network response was not ok");
}
}).then(data => {
if (data.status === 1) {
showSuccess("Promo Code Sucessfully Applied");
// Fetch updates before confirming the payment
elements.fetchUpdates()
.then(function(result) {
console.log(result.error)
// Handle result.error
});
} else {
// Display the error message on the page with red color
showError(data.message || 'An error occurred during Intent Creation please refresh the Page .');
}
i am calling after the coupon applied abd data.status===1
but on checkout its decucted full amount
Can you show me a screenshot of what you're seeing?
Like where the amount is showing up?
basically i got the problen can i check the details of Intent on console.log to get amount to intent ?
?
You would need to fetch the Intent using Stripe.js before you could log it.
Wait, are you asking about client-side or server-side?
i am asking about client side using JS
Yeah, you need to fetch the Intent first, then you can log it.
okay let me check the linkthat you shared