I've looked through multiple post about this but can't seem to pinpoint the problem. I'm doing a donation page for an organization and need this to check if paypal is even working. It's an error between my form and app.post. Error I get is: Cannot POST /path . Can't use / because its the path for my contact form
app.get("/donate", (req, res) => res.sendFile(__dirname + "views/donate.html"));
app.post("/done", (req, res) => {
const create_payment_json = {
intent: "sale",
payer: {
payment_method: "paypal",
},
redirect_urls: {
return_url: "https://asociacioncorazondiverso.org/donate.html",
cancel_url: "https://asociacioncorazondiverso.org/donate.html",
},
transactions: [
{
item_list: {
items: [
{
name: "Donación",
sku: "001",
price: "10.00",
currency: "USD",
quantity: 1,
},
],
},
amount: {
currency: "USD",
total: "10.00",
},
description: "Donación",
},
],
};
paypal.payment.create(create_payment_json, function (error, payment) {
if (error) {
throw error;
} else {
for (let i = 0; i < payment.links.length; i++) {
if (payment.links[i].rel === "approval_url") {
res.redirect(payment.links[i].href);
}
}
}
});
});
Form:
<div class="container-contact100-form-btn">
<h2>Donación de 10 USD</h2>
<form action="/done" method="post">
<button type="submit" class="btn btn-warning" value="Buy">Donación</button>
</form>
</div>
from Cannot POST /path
No comments:
Post a Comment