如何使用节点中的paypal-rest进行直接支付?

我find了一个paypal自己为节点写的图书馆,他们写了一个关于如何支付的伟大图书馆。 我仍然处于如何接受付款的困惑状态,我现在正在耗尽时间。

用例很简单,用户点击添加一个项目到他的购物车,然后他有一个select,它要么使用信用卡/借记卡或PayPal(快速结帐)

我的目标仍然是在信用卡/借记卡,用户决定使用信用卡/借记卡来接收付款,并使用paypal-rest-api sdk来做到这一点。 但看着代码样本我超级困惑在哪个样本select,从

https://github.com/paypal/PayPal-node-SDK/tree/master/samples

var card_data = { "type": "visa", "number": "4417119669820331", "expire_month": "11", "expire_year": "2018", "cvv2": "123", "first_name": "Joe", "last_name": "Shopper" }; paypal.creditCard.create(card_data, function(error, credit_card){ if (error) { console.log(error); throw error; } else { console.log("Create Credit-Card Response"); console.log(credit_card); } }) 

card_data ,没有任何数额,而我真的很困惑。

再次用例

用户可以在网站上购买该项目,他使用信用卡/借记卡支付,并自动将钱从他的银行帐户发送到我的贝宝公司帐户。

你正在寻找不正确的方法。 您需要payment.create

以下是付款文档中的代码段

 var create_payment_json = { "intent": "sale", "payer": { "payment_method": "credit_card", "funding_instruments": [{ "credit_card": { "type": "visa", "number": "4417119669820331", "expire_month": "11", "expire_year": "2018", "cvv2": "874", "first_name": "Joe", "last_name": "Shopper", "billing_address": { "line1": "52 N Main ST", "city": "Johnstown", "state": "OH", "postal_code": "43210", "country_code": "US" } } }] }, "transactions": [{ "amount": { "total": "7", "currency": "USD", "details": { "subtotal": "5", "tax": "1", "shipping": "1" } }, "description": "This is the payment transaction description." }] }; paypal.payment.create(create_payment_json, function (error, payment) { if (error) { throw error; } else { console.log("Create Payment Response"); console.log(payment); } });