我正在C#中进行PayPal的RESTful集成
我正在尝试使用credit card
作为payment_method
创建付款。
到目前为止,我已经有了Angular配置,并且可以在我的api Create
方法中成功创建并获得状态为“ authorized”的授权响应:
createdPayment = payment.Create(apiContext);
return createdPayment;
然后:
Authorization authorization = payment.transactions[0].related_resources[0].authorization;
authorization
状态为 authorized 。
但是我在控制台中得到响应:
ppxo_no_token_passed_to_payment
Object { timestamp: 1531389390897, windowID: "8b6e6d498f", pageID: "60540ae7ab", prev_corr_ids: "", referer: "localhost:63809", host: "localhost:63809", path: "/order", env: "production", country: "US", lang: "en", … }
(如果我使用的是沙箱,还不确定它会说env: production
吗?)
和:
No value passed to payment
当我单击付款对象的确认链接(例如https://api.sandbox.paypal.com/v1/payments/payment/PAY-6RD0371739881292ULNDSPRA)时,我得到的是json:
name "AUTHENTICATION_FAILURE"
message "Authentication failed due to invalid authentication credentials or a missing Authorization header."
links
0
href "https://developer.paypal.com/docs/api/overview/#error"
rel "information_link"
因此付款实际上失败了。
我转到提供的引用链接:https://developer.paypal.com/docs/api/overview/#error,发现与访问令牌相关的问题通常会导致身份验证错误,但是我却遇到了 Bearer 成功创建付款后的令牌。
问题是我应该如何使用 Bearer 令牌?在按钮配置的payment
方法中返回什么?如何传递给配置的onAuthorize
方法(如果有)?以及如何成功授权付款?
我试图通过贝宝(Paypal)API寻找解决方案,但到目前为止没有找到任何答案。
我的角度配置:
paypalConfig = {
env: 'sandbox',
client: {
sandbox: 'my sandbox key'
},
commit: true,
payment: (data: any, actions: any) => {
// 2. Make a request to your server
var url = '/paypal/create/';
return actions.request.post(url)
.then(function (res: any) {
// What HERE?
return res.id; // if I return payment id then I get redirected to paypal.com where it obviously says the transation is invalid because I'm doing the process in sandbox not live env
});
},
onAuthorize: (data: any, actions: any) => {
// WHAT HERE??
// normally I'd do a request to paypal with paymentid and payerid (https://developer.paypal.com/docs/checkout/how-to/server-integration/#1-set-up-your-client-to-call-your-server) but in case of credit_card payment I don't get those
}
};
我的Create
方法基于此处提供的CreatePayment
-唯一的区别是我使用payment_method = "credit_card"
(而不是 paypal ),并且我返回了{ {1}}对象可以返回角度,而不是重定向到批准网址。
Btw Payment
方法。通常,使用贝宝(Paypal)资金时,我会将onAuthorize
和paymentId
发回贝宝(Paypal)以授权付款,但是如果采用信用卡方式,我会在payerId
功能内获得已授权的付款。唯一的问题是它失败了。