$ npm install --save loopback-component-paypal
Define new datasourc configuration for your PayPal account (file datasources.json)
{
"paypal": {
"clientID": "CLIENT_ID",
"clientSecret": "CLIENT_SECRET",
"mode": "sandbox",
"payment": {
"intent": "sale",
"redirect_urls": {
"return_url": "return_url",
"cancel_url": "cancel_url"
},
"payer": {
"payment_method": "paypal"
}
}
}
}
Define new model in file model-config.json with datasource paypal
{
"PayPal": {
"dataSource": "paypal",
"public": false
}
}
use model PayPal
in your application:
PayPal.payment.create(create_payment_json, function (error, payment) {
if (error) {
console.log(error.response);
throw error;
} else {
console.log("Create Payment Response");
console.log(payment);
}
});
MIT © Matteo Padovano