贝宝未重定向到贝宝网站,但墨水正在流星中响应

问题描述 投票:0回答:1

我是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 
}

因为links [2] .href

是URL,贝宝应在此处重定向,用户可以登录该帐户。但这不是重定向。因此,我正在First console下方的callPaypal()方法中手动重定向到此链接。但是,路由器仍然无法重定向到该链接,可能是“外部域问题”,甚至是没有显示错误的东西。请问贝宝有什么办法将自己重定向到贝宝登录?我已经在这上面浪费了我的2天时间,却一无所获。谢谢。

我已在我的Paypal开发人员帐户中为此项目添加了重定向URL。

我是Meteor的新手,正在整合Paypal(我从未做过)。从流星的客户端-我在单击按钮时调用方法。 callPaypal(e)} color =“ primary” ...

meteor paypal
1个回答
0
投票

似乎您使用的是基于重定向的旧PayPal集成,所以我的建议是尝试新的关联体验:https://developer.paypal.com/demo/checkout/#/pattern/server

© www.soinside.com 2019 - 2024. All rights reserved.