贝宝集成-ionic3中的付款无法处理错误?

时间:2019-10-16 05:47:01

标签: paypal ionic3 paypal-sandbox

我正在将Paypal集成到我的离子应用程序中,…很高兴,我可以轻松实现具有静态值的Paypal,但是当我尝试动态值时,它会显示错误。 付款无法在控制台中处理。

continueSubscription(){
    //initialize payment......
    this.payPal.init({
       PayPalEnvironmentProduction: '',
       PayPalEnvironmentSandbox: 'AemTsns-uGKFmd2nOTVx7ZHZWSV_Qi7nbiiEX7mbYcMSKIQRTkP6sf1Tep7vuagqayS'
     }).then(() => {
      var data = this.paymentAmount;

      // Environments: PayPalEnvironmentNoNetwork, PayPalEnvironmentSandbox, PayPalEnvironmentProduction  
      this.payPal.prepareToRender('PayPalEnvironmentSandbox', new PayPalConfiguration({})).then(() => {
        console.log(this.selectedValue);
        var payment = new PayPalPayment(this.selectedValue.amount, this.selectedValue.currency_type, 'Description', this.selectedValue.descryption);
        this.payPal.renderSinglePaymentUI(payment).then((res) => {
          // Successfully paid
          this.paymentResponse = res;
        }, (error) => {
            console.log(error);  
          // Error or render dialog closed without being successful
        });
      }, () => {
        // Error in configuration
      });
    }, () => {
      // Error in initialization, maybe PayPal isn't supported or something else
    });
  }

下面共享更新的ts代码,selectedValue是对象,我们在其中传递了动态数据,而我将以下对象传递给了付款:

      amount: "200"
      bnCode: "PhoneGap_SP"
      currency: "INR"
      details: undefined
      intent: "Health Record With Conditioncjn dfgh"
      shortDescription: "Description"

请团队告诉我如何解决以上错误?

1 个答案:

答案 0 :(得分:0)

您确定this.selectedValue.amount是字符串吗? PayPal希望该金额为字符串,不接受数字/整数。

如果执行console.log(this.selectedValue.amount);,控制台会怎么说?

您还可以尝试使用单引号而不是双引号。