贝宝没有重定向到贝宝网站,但墨迹正在流星中得到响应



我是Meteor和集成Paypal的新手(我从未做过(。

from Client side in meteor - 

我正在按按钮调用方法。

<MDBBtn onClick={(e) => callPaypal(e)} color="primary" type="submit">
Add and Continue to PayPal
</MDBBtn>

这个callpaypal((方法->

import { Link as ReactRouterLink } from 'react-router-dom'
const callPaypal = (e) => {
e.preventDefault();
Meteor.call('createPayalPayment', (err, res) => {
console.log(res[1].href)                                  **FIRST CONSOLE**
if (res) {
let link = res[1];
if (link.href) {
return <ReactRouterLink to={`${link.href}`} />
}
}
})
}

从服务器->调用createPayalPayment方法

import { Config } from "./paypal_config";
createPayalPayment() {
var data = {
"intent": "sale",
"payer": {
"payment_method": "paypal"
},
"redirect_urls": {
// "return_url": `${Meteor.absoluteUrl('/execute'), { "replaceLocalhost": "true" }}`,
"return_url": "http://127.0.0.1:3000/execute",
"cancel_url": "http://172.20.10.5:3000/cancel"
},
"transactions": [{
"amount": {
"currency": "USD",
"total": "1.00"
},
"description": "This is the payment description."
}]
};
paypal.configure(Config);
var ppCreate = Meteor.wrapAsync(paypal.payment.create.bind(paypal.payment));
var ppExecute = Meteor.wrapAsync(paypal.payment.execute.bind(paypal.payment));
var response = ppCreate(data);
if (response.state !== 'created') {
console.log('not created!!!!!!!!!!!!!!!!')
}
else {
console.log(response);                                             **SECOND CONSOLE**
return response.links;
}
}

这是我的Paypal配置->

export const Config = {
'mode': 'sandbox',
'client_id': 'client_Id',
'client_secret': 'secret'
};

第一控制台-->'https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-1HR12649X9688931M'

第二控制台-->

{ id: 'PAYID-L2IJO4I8GE24787GF168351L',
intent: 'sale',
state: 'created',
payer: { payment_method: 'paypal' },

transactions: 
[ { amount: [Object],
description: 'This is the payment description.',
related_resources: [] } ],
create_time: '2020-04-10T15:57:37Z',
links: 
[ { href: 'https://api.sandbox.paypal.com/v1/payments/payment/PAYID-L2IJO4I8GE24787GF168351L',
rel: 'self',
method: 'GET' },
{ href: 'https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-1HR12649X9688931M',
rel: 'approval_url',
method: 'REDIRECT' },
{ href: 'https://api.sandbox.paypal.com/v1/payments/payment/PAYID-L2IJO4I8GE24787GF168351L/execute',
rel: 'execute',
method: 'POST' } ],

httpStatusCode: 201 
}

由于链接[2]。href是URL,贝宝应该重定向到此处,用户可以登录到该帐户。但它并没有改变方向。因此,我在First console下方的callPaypal((方法中手动重定向到此链接。但是路由器仍然无法重定向到链接,可能是外域问题或其他什么问题,甚至它没有显示错误。请问有没有什么方法可以让贝宝重定向到贝宝登录?我已经在这上面浪费了我的两天时间,但仍然一无所有。谢谢

我为这个项目在我的贝宝开发者帐户中添加了重定向URL

看起来你使用的是一个旧的、基于重定向的PayPal集成,所以我的建议是尝试新的上下文体验:https://developer.paypal.com/demo/checkout/#/pattern/server

请注意对"/demo/.."的两个fetch调用占位符,需要用服务器上的实际路由替换。第一个应该返回PayID(或更新的v2/订单ID(,第二个应该执行/捕获该ID。

这种集成是优越的,因为你的网站保持在后台加载,买家可以在不"离开"的情况下结账和付款。


在服务器端,您可能正在使用旧的已弃用的v1 PayPal节点SDK,没有理由进行新的集成。相反,使用v2 Checkout NodeJS SDK

最新更新