#ahmad-updatedPI-PE

1 messages · Page 1 of 1 (latest)

stark cargoBOT
cobalt basalt
#

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.

rich pebble
cobalt basalt
#

Yeah, that won't work. You need a full URL, like https://example.com/confirm_payment/ or similar.

cobalt basalt
#

That's just an example.

#

You need to change it to your URL.

rich pebble
#

yes i know

rich pebble
cobalt basalt
#

Sure, what's up?

rich pebble
#

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/",
  },
});
cobalt basalt
rich pebble
#

can i use it within the confirmPayment call or outside ?

cobalt basalt
#

You need to call it before you call confirmPayment.

#

You need to update the Intent, then call fetchUpdates, then call confirmPayment, in that order.

rich pebble
rich pebble
#

can you give me any example code because its seems to not working on my side

cobalt basalt
#

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?

rich pebble
#

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

cobalt basalt
#

Can you show me a screenshot of what you're seeing?

#

Like where the amount is showing up?

rich pebble
#

basically i got the problen can i check the details of Intent on console.log to get amount to intent ?

#

?

cobalt basalt
#

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?

rich pebble
#

i am asking about client side using JS

stark cargoBOT
cobalt basalt
#

Yeah, you need to fetch the Intent first, then you can log it.

rich pebble
#

okay let me check the linkthat you shared

stark cargoBOT