如何在节点中使用Paypal-Rest直接付款?
我发现一个贝宝自己为 node 编写的库,他们写的很棒图书馆如何付款.我仍然对如何收款感到困惑,现在我的时间已经用完了.
I found a library that paypal themselves have written for node, they wrote a great library on how to pay. Im still in the confused state on how to receive payment and Im running out of time right now.
用例非常简单,用户A单击将商品添加到购物车中,然后他就可以选择使用信用卡/借记卡或paypal(快速结帐)付款
The use case is very simple, User A click add an item to his cart , then he has a choice, its either to pay using Credit/debit card or paypal(express checkout)
我的目标仍然是信用卡/借记卡,用户决定使用信用卡/借记卡来接收付款,而即时消息我使用paypal-rest-api sdk来执行此操作.但是看代码示例时,我非常困惑,该从哪个示例中选择
My goal still at the credit/debit card, where user decided to use credit/debit card to receive payments, and im using paypal-rest-api sdk to do this. But looking at the code samples Im super confused on which sample to choose, from
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
中没有金额,我真的很困惑.
In the card_data
, there is no amount, and im really confused.
再次查看用例
用户可以在网站上购买该商品,然后使用信用卡/借记卡付款,它将自动将钱从他的银行帐户发送到我的Paypal商业帐户.
User could buy the item on website, and he pays using credit/debit card and it will automatically send the money from his bank account to my paypal business account.
您正在寻找的方法不正确.您需要payment.create
You're looking at not the right method. You need 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);
}
});