【问题标题】:How get paypal transaction detail in angular2?如何在 angular2 中获取贝宝交易详情?
【发布时间】:2017-03-24 07:00:38
【问题描述】:

我正在为我的网站使用 angular2 内置的贝宝交易。这是我的贝宝表格的代码。组件函数。

paypalPayment(cartArr) {
    var form = document.createElement("form");
    form.method = "POST";
    form.action = "https://www.sandbox.paypal.com/cgi-bin/webscr";
    this.createElement(form, 'charset', 'utf-8');
    this.createElement(form, 'cmd', '_xclick');
    //this.createElement(form, 'cmd', '_cart');
    this.createElement(form, 'upload', '1');
    this.createElement(form, 'currency_code', 'USD');
    this.createElement(form, 'business', "my_business@mail.com");
    this.createElement(form, 'email',"user_email@test.com");
    this.createElement(form, 'custom', '{ "order_id": ' + this.order_id + ' }');
    this.createElement(form, 'item_name', "Item");
    this.createElement(form, 'amount', "10");
    this.createElement(form, 'quantity', 1);
    this.createElement(form, 'return', 'sitename.com/purchase/close_verified_order/' + this.order_id);
    this.createElement(form, 'cancel_return', 'sitename.com/purchase/cancel/' + this.order_id);
    this.createElement(form, 'notify_url', 'sitename.com/purchase/close_invalid_order/' + this.order_id);

    document.body.appendChild(form);
    form.submit();
  }  

在上面的表格中,当我使用_xclick 时,它会返回transaction id 中的transaction id 等基本详细信息URL,但我需要所有交易详细信息。下面是返回页面的代码。

ngOnInit() {
    let transactionId = this.route.snapshot.queryParams['tx'];
    this.order_id = this.route.snapshot.params['id'];
  }

paypal 如何提供所有交易细节?我已经阅读了IPN,但我不知道如何在angular2 中使用它。

我想知道我应该在notify_urlreturn 中进行哪些更改才能获得所有交易详情。 ?

如果贝宝在POST 数据中发送交易详情,那么我该如何在angular2 代码中处理呢?

如果我需要使用 IPN,那么如何从 paypal 获取 auth_token,然后如何从 angular2 调用它的 api

【问题讨论】:

    标签: angular paypal paypal-ipn paypal-sandbox angular2-forms


    【解决方案1】:

    不要使用 Angular,但一般来说,您需要设置一个“侦听器”来响应 IPN 结果。该“侦听器”应包含使用 $_POST 数据(返回给“侦听器”)的代码来处理您需要的信息。

    IPN 文档从这里开始 https://developer.paypal.com/docs/classic/products/instant-payment-notification/ 。设置一个沙盒帐户,并将其用于测试。

    还有一个 IPN“测试器”,您可以使用它来针对各种类型的 IPN 响应测试您的代码。

    【讨论】:

      猜你喜欢
      • 2013-02-03
      • 2013-04-26
      • 2020-09-26
      • 1970-01-01
      • 2015-05-27
      • 2017-12-08
      • 2013-12-26
      • 2012-08-31
      • 2015-10-07
      相关资源
      最近更新 更多