【问题标题】:Paypal error ppxo_no_token_passed_to_payment aka "No value passed to payment"Paypal 错误 ppxo_no_token_passed_to_payment 又名“没有传递给付款的值”
【发布时间】:2018-11-14 02:02:58
【问题描述】:

我已经在我的应用程序中实施了 paypal 快速结帐,并且一切都运行顺利,直到我今天不得不更改我的凭据。为了进行测试,我使用了自己的 paypal 帐户,但现在必须用公司的帐户进行切换,因此我创建了一个 REST 应用程序并交换了调试和生产密钥。突然,当我尝试付款时,我得到ppxo_no_token_passed_to_payment,如果我切换回旧的公钥,它仍然可以工作。我怀疑这是贝宝上的一个问题,我需要授权或启用该应用程序或其他东西,但遗憾的是我不记得了......

这是有问题的代码,但我相信它没有任何问题,正如我所说,如果我输入旧的公钥,那么它仍然可以正常工作。

  getPaypalButton(container: any, paypal: any) {

    return paypal.Button.render({

      env: __DEV__ ? "sandbox" : "production",

      style: this.style(),

      // Pass the client ids to use to create your transaction on sandbox and production environments

      client: {
        // from https://developer.paypal.com/developer/applications/
        sandbox: env.payments.paypal.sandbox, 
        production: env.payments.paypal.production
      },

      // Pass the payment details for your transaction
      // See https://developer.paypal.com/docs/api/payments/#payment_create for the expected json parameters
      payment: this.payment.bind(this),

      // Display a "Pay Now" button rather than a "Continue" button
      commit: true,

      // Pass a function to be called when the customer completes the payment
      onAuthorize: this.authorize.bind(this),

      // Pass a function to be called when the customer cancels the payment
      onCancel: this.cancel.bind(this)

    }, container)

  style() {
    return {
      label: 'paypal',
      size: 'responsive',    // small | medium | large | responsive
      shape: 'rect',     // pill | rect
      color: 'blue',     // gold | blue | silver | black
      tagline: false
    };
  }

  payment(data: any, actions: any) {

    return actions.payment.create({
      transactions: [
        {
          amount: {
            total: i18n.currencies.toHumanReadable(this.moneyControl.internalInput.value, "EUR").toFixed(2),
            currency: "EUR"
          }
        }
      ]
    }).catch((error: any) => {
      if (!this.moneyControl.internalInput.value) {
        this.moneyControl.displayError("validation.required");
      } else {
        this.moneyControl.displayError("deposit.paypalerror");
      }
    });
  }

  authorize(data: any, actions: any) {
    return web.request("/paypal", {
      method: "POST",
      data: {
        token: data.paymentToken,
        payment_id: data.paymentID,
        payer_id: data.payerID
      }
    }).then((response: any) => {
      console.log('The payment was completed!', response);

      this.completed();
    }).catch(function (error) {
      console.log(error);
    });
  }

  cancel(data: any) {
    this.moneyControl.displayError("deposit.paypalcancel");
  }

需要注意的一点是,抛出的错误是 env: "production",但 __DEV__true

country: "US"
env: "production"
host: "192.168.0.100:8080"
lang: "en"
pageID: ...
path: "/"
prev_corr_ids: ""
referer: "192.168.0.100:8080"
timestamp: 1528128652378
uid: ...
ver: "4.0.199"
windowID: ...

【问题讨论】:

    标签: javascript rest paypal


    【解决方案1】:

    the docs,传递给actions.payment.create 函数的对象应该包含一个payment 键。

    因此,您现在应该使用以下对象,而不是您传递的对象:

    return actions.payment.create({
      payment: {
        transactions: [
          {
            amount: {
              total: i18n.currencies.toHumanReadable(this.moneyControl.internalInput.value, "EUR").toFixed(2),
              currency: "EUR"
            }
          }
        ]
      }
    })
    

    【讨论】:

    • 但是为什么它和我的另一个键一起工作?奇怪的是,几天后它就自行修复了,什么都没碰过..
    • 好吧,在没有payment 键的情况下使用它在我看来是未定义的行为。如果开发人员使用该密钥提供示例,则最好遵循它 - 否则您最终可能会遇到您已经遇到的情况:奇怪的行为。无论如何,我不是贝宝交易专家,所以我可能错了
    猜你喜欢
    • 2017-12-13
    • 2017-11-14
    • 2015-08-18
    • 2015-07-15
    • 1970-01-01
    • 2014-07-15
    • 2015-06-21
    • 2017-02-03
    • 2014-01-13
    相关资源
    最近更新 更多