如何实时整合贝宝账户

时间:2019-09-04 05:50:31

标签: angular6

我们目前无法使用您的PayPal帐户处理您的付款。请返回商家并尝试使用其他付款方式 如何使用angular6启用Paypal帐户,我曾尝试使用此代码,但无法正常工作,可以在沙盒中正常工作,但不适用于生产级别

**code**

import { Component,AfterViewChecked  } from '@angular/core';
declare let paypal: any;
@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent implements AfterViewChecked {
  addScript: boolean = false;
  paypalLoad: boolean = true;

  finalAmount: number = 1;

  paypalConfig = {
    env: 'production',
    client: {
     //sandbox: '';
      production:'';
    },
    commit: true,
    payment: (data, actions) => {
      return actions.payment.create({
        payment: {
          transactions: [
            { amount: { total: this.finalAmount, currency: 'USD' } }
          ]
        }
      });
    },
    onAuthorize: (data, actions) => {
      return actions.payment.execute().then((payment) => {
        alert('Transaction completed');
        //Do something when payment is successful.
      })
    }
  };

  ngAfterViewChecked(): void {
    if (!this.addScript) {
      this.addPaypalScript().then(() => {
        paypal.Button.render(this.paypalConfig, '#paypal-checkout-btn');
        this.paypalLoad = false;
      })
    }
  }

  addPaypalScript() {
    this.addScript = true;
    return new Promise((resolve, reject) => {
      let scripttagElement = document.createElement('script');    
      scripttagElement.src = 'https://www.paypalobjects.com/api/checkout.js';
      scripttagElement.onload = resolve;
      document.body.appendChild(scripttagElement);
    })
  }
}

1 个答案:

答案 0 :(得分:0)

从沙盒切换到生产模式时,一切应该正常工作-确保您传递正确的凭据。 由于各种原因,可能会出现上述错误,因此需要更多详细信息以调查问题,因此建议您向PayPal支持团队https://www.paypal-support.com/s/?language=en_US

提出查询请求