我有一个angular2应用程序 . 我已经集成了PayPal沙箱来测试在线支付,它在Safari和Chrome中运行良好,但在Firefox中运行不正常 .
这是问题 -
在我的请求获得PayPal批准后,我将页面重定向到其付款页面 .
donate-component.ts -
this.paypalService.makePaymentRequest(500, 'http://' + rootUrl + '/event/1/home').subscribe(data => {
window.location.href = data.json.links[1].href;
})
paypal-api-service.ts -
makePaymentRequest(amount: number, redirectUrl: string) {
var headers = new Headers({ 'Content-Type': 'application/json' });
headers.append('Authorization', 'Bearer ' + this.TOKEN);
var options = new RequestOptions({
headers: headers
});
var body = JSON.stringify({
"intent": "sale",
"redirect_urls": {
"return_url": redirectUrl,
"cancel_url": "http://example.com/your_cancel_url.html"
},
"payer": {
"payment_method": "paypal"
},
"transactions": [
{
"amount": {
"total": amount,
"currency": "USD"
}
}
]
});
var requestoptions = new RequestOptions({
method: RequestMethod.Post,
url: 'https://api.sandbox.paypal.com/v1/payments/payment/',
headers: headers,
body: body
})
return this.http.request(new Request(requestoptions))
.map((res: Response) => {
if (res) {
return { status: res.status, json: res.json() }
}
}).catch(this.handleError);
}
这里 data.json.links[1].href
中的URL类似于https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=XXXXX#/checkout/login .
这在Safari和Chrome中正常运行 . 但在Firefox中,它只是刷新我的页面 . 我确实在底部看到一个简短的“ waiting for sandbox.paypal.com ”栏,但在一秒钟内页面刷新 .
我也试过了 window.location.replace()
的重定向,但它不起作用 .
EDIT:
这适用于Windows上的FireFox,但不适用于Mac .