Node.js Paypal sdk:visa卡不工作



我正在尝试在node.js中使用PayPal处理信用卡
使用主卡,下面的代码正在使用201状态代码的沙箱帐户
但是,不使用"visa"、"amex">
使用"visa"、"amex"卡,我正在获取500状态代码,但找不到错误详细信息。谁见过这个案子?

var paypal = require('paypal-rest-sdk');
paypal.configure({
'mode': 'sandbox',
'client_id': 'CLIENT_ID',
'client_secret': 'CLIENT_SECRET_KEY'
});
var payment = {
"intent": "authorize",
"payer": {
"payment_method": "credit_card",
"funding_instruments": [{
"credit_card": {
"type": "visa",//visa//mastercard//amex
"expire_month": 1,
"expire_year": 2022,
"cvv2": "VISA_CCV2",
"number": "VISA_NUMBER"
}
}]
},
"redirect_urls": {
"return_url": "http://127.0.0.1:3000/success",
"cancel_url": "http://127.0.0.1:3000/err"
},
"transactions": [{
"item_list": {
"items": [{
"name": "media dvd",
"sku": "001",
"price": "1.00",
"currency": "USD",
"quantity": 1
}]
},
"amount": {
"total": 1.00,
"currency": "USD"
},
"description": " a book on mean stack "
}]
}
paypal.payment.create(payment, { timeout: 10000 }, function (err, payment) {
if (err) {
console.log(err, payment);

}
else {
console.log(payment);
}
}); 

来源:https://developer.paypal.com/docs/api/payments/v1/

重要提示:使用PayPal REST/支付API接受信用卡支付受到限制。相反,您可以通过Braintree Direct接受信用卡付款。

(Braintree direct将是一个完整的网关帐户,需要帐户批准,仅适用于某些国家/地区的企业。(

由于您试图将旧的东西与旧的SDK集成在一起,并且无法在实时环境中使用,因此这里有最好的PayPal替代方案:

  • 使用新的、受支持的v2 Checkout NodeJS SDK

  • 使用带有黑色借记卡/信用卡按钮的PayPal Checkout前端:https://developer.paypal.com/demo/checkout/#/pattern/server

直接付款仅限于从信用卡到贝宝。因此,您可以使用Braintree Direct实现支付集成。

const braintree = require("braintree");
const gateway = new braintree.BraintreeGateway({
environment: braintree.Environment.Sandbox, // Sandbox or Production
merchantId: "Your_merchatn_id",
publicKey: "Your_public key",
privateKey: "Your_private_key"
});

您可以使用merchantId、publicKey、privateKey进行身份验证。

gateway.transaction.sale({
amount: `10`,
paymentMethodNonce: "fake-valid-nonce",
options: {
submitForSettlement: true,
storeInVaultOnSuccess: true
}
}, function (err, result) {
if (err) {
console.error(err);
}

if (result.success) {
console.log('Transaction ID: ' + result.transaction.id);
console.log('Customer ID: ' + result.transaction.customer.id);
var customer_id = result.transaction.customer.id;
let creditCardParams = {
customer_id,
number: `4111111111111111`,
expirationDate: `04/2022`,
cvv: `133`
};

gateway.creditCard.create(creditCardParams, (err, response) => {
if(err) {
console.log(err.message);
} else {
console.log(response);
}
});
} else {
console.error(result);
}
});

最新更新