angular - 如何在angular2中获取 Paypal 交易细节?

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

我正在为我的网站使用 paypal 交易,它是在 angular2 中构建的。这是我的 Paypal 表格的代码。组件功能。

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 时,它会返回基本详细信息,例如 URL 中的 transaction id,但我需要所有交易详细信息。下面是返回页面的代码。

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

paypal 如何提供所有交易详情?我读过有关 IPN 的内容,但我不知道如何在 angular2 中使用它。

我想知道我应该在 notify_urlreturn 中更改什么以获取所有交易详细信息。 ?

如果 paypal 在 POST 数据中发送交易细节,那么我如何在 angular2 代码中处理它?

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

最佳答案

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

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

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

关于angular - 如何在angular2中获取 Paypal 交易细节?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42993310/

相关文章:

php - IPN 验证 ipnSimulator 无效

php - 我怎么知道哪个订单是paypal付款的?

javascript - Angular JS 2 中模板元素的递归

json - Angular : ERROR SyntaxError: Unexpected token < in JSON at position 0

c# - 加密我的 paypal API 凭据的最合理解决方案?

c# - Paypal 并行支付

Angular - 如何正确测试在 Observable 订阅 block 中执行的操作?

javascript - 无法在 'complete' 函数之外获得 Papa Parse 结果

rest - 在没有网站的情况下与 PayPal 集成

php - 我是否会收到来自 Paypal 立即购买按钮的所有事件的回调?