贝宝集成中的ExpressionChangedAfterItHasBeenCheckedError

时间:2020-03-10 10:19:51

标签: angular sharepoint paypal

我正在将paypal与angular集成在一起,但出现此错误 ExpressionChangedAfterItHaHasBeenCheckedError ExpressionChangedAfterItHasBeenCheckedError:表达式在检查后已更改。上一个值:'config:undefined'。当前值:“ config:[object Object]”。

一切正常,但Google控制台显示了此消息,我已经找到了,但没有找到解决此错误的任何方法。

这是我组件的代码

/// component code

export class PaymentsComponent implements OnInit   {
    public spHostUrl;
    @Input() finalAmount: number;
    @Output() saveRenewSubscription: EventEmitter<any> = new EventEmitter<any>();
     @Output() hidePopup: EventEmitter<any> = new EventEmitter<any>();
    @Input() licenseQuantity: number;
    @Input() newExpiryDate: any;
    @Input() subDuration: any;
    @Input() subPrice: any;
    paymentCheck=false;
    @Input() showModel: boolean;
  public payPalConfig?: IPayPalConfig;
  // showModel: boolean;

  ngOnInit(): void {
    this.spHostUrl = GetUrlKeyValue('SPHostUrl');
  }

  ngAfterViewInit():void{
    this.initConfig();
  }


  // openModal(){
  //   this.showModel = true;
  //   this.showDialog = false;
  // }


  private initConfig(): void {
    debugger
    this.payPalConfig = {
    currency: 'USD',
    clientId: 'AWGP2L-qZe_-kZJBEJi_uoUs29NtvzuZZPFzYXxiZfBUdDEYegS_XoCAqsqVr2ra02TbKd9pvLkrT4tB',
    createOrderOnClient: (data) => <ICreateOrderRequest>{
      intent: 'CAPTURE',
      purchase_units: [
        {
          amount: {
            currency_code: 'USD',
            value: this.finalAmount.toString(),
            breakdown: {
              item_total: {
                currency_code: 'USD',
                value: this.finalAmount.toString(),
              }
            }
          },
          items: [
            {
              name: 'Renew - OneDocx for Law Practice (Standard)',
              quantity: this.licenseQuantity.toString(),
              sku: "MyApppStandard" + this.subDuration.toString(),
              description: "Paid "+this.subDuration + " expiring on " + this.newExpiryDate+".",
              unit_amount: {
                currency_code: 'USD',
                value: this.subPrice.toString(),
              },
            }
          ],
          custom_id: this.spHostUrl,
          
        }
      ]
    },
    advanced: {
      commit: 'true'
     
    },
    style: {
      layout:  'vertical',
      label:   'pay',
      size:    'medium',
      
    },
  
    onApprove: (data, actions) => {
      actions.order.get().then(details => {
      });
    },
    

    // On Authorization

    onClientAuthorization: (data) => {
      this.paymentCheck=true
      this.saveRenewSubscription.emit(this.paymentCheck)
      alert("You have renewed subscription successfully")
    },

    // On cancel if user cancel transaction or close the popup

    onCancel: (data, actions) => {
      this.paymentCheck=false
      this.saveRenewSubscription.emit(this.paymentCheck)
    },

    // On error in getting payment through paypal

    onError: err => {
      this.paymentCheck=false
      this.saveRenewSubscription.emit(this.paymentCheck)

    },

    // On paypal button's click

    onClick: (data, actions) => {
      let value;
      this.paymentCheck=false
      // this.hidePopup.emit(value = false)
    },
  };
  }
}
/// Paypal button


<ngx-paypal [config]="payPalConfig" class="text-center" style="width: 20%; float: left;"></ngx-paypal>

0 个答案:

没有答案