This is how I create Paypal payment from my webapp :
paypal.configure(paypal_config.api);
var payment = {
"intent": "sale",
"payer": {
"payment_method": "paypal"
},
//"receiver_email": "business@place.fr",
"redirect_urls": {
"return_url": "http://yoururl.com/execute",
"cancel_url": "http://yoururl.com/cancel"
},
"transactions": [{
"item_list": {
"items": [{
"name": "item",
"sku": "item",
"price": "1.00",
"currency": "USD",
"quantity": 1
}]
},
"amount": {
"currency": "USD",
"total": "1.06",
"details": {
"subtotal": "1.00",
"tax": "0.03",
"shipping": "0.03"
}
},
"description": "This is the payment description."
}]
};
paypal.payment.create(payment, function (error, payment) {
if (error) {
console.log(error);
} else {
if(payment.payer.payment_method === 'paypal') {
req.session.paymentId = payment.id;
var redirectUrl;
for(var i=0; i < payment.links.length; i++) {
var link = payment.links[i];
if (link.method === 'REDIRECT') {
redirectUrl = link.href;
}
}
res.redirect(redirectUrl);
}
}
});
It works perfectly but I have 2 problems, I need to set the receiver email, and the request is said to be malformed when I add the key "receiver_email".
My second problem is more a question in fact, with this method I know directly if the payment is validated or not, but what happened when a payment need more time to be validated (bank transfer etc..), there's no ipn url to give ?
Thank you !