首页 > 解决方案 > 后端响应成功后打开贝宝结帐模式

问题描述

如果用户在他的表单上输入他的详细信息并提交表单,我有一个表单,在提交表单后它将存储到数据库,并且在成功将用户数据存储在数据库中之后,我必须打开贝宝结帐模式,否则不会。

这是贝宝

paypal.Button.render({

  env: 'sandbox',
  client: {
    sandbox: ''
    // production: 'demo_production_client_id'
  },

  locale: 'en_US',
  style: {

    layout: 'horizontal',
    size: 'small',
    color:  'blue',
    shape:  'pill',
    label: 'checkout',
    height: 40,
    tagline: 'false'
  },

  commit: true,

  payment: (data, actions) => { 
      return actions.payment.create({
        transactions: [{
          amount: {
            total: '1',
            currency: 'USD'
          }
        }]
      });
  },
  
  onAuthorize: function(data, actions) {
    return actions.payment.execute()
    .then(function() {  
      window.alert('Thank you for your purchase!');
    });
  }
 }, this.paypalRef.nativeElement);

这是提交表单 api 调用

  submit(){
  const data={
   url: this.URL,
   email:this.email
 }
 this.home.websiteScratching(data)
 .subscribe(res=>{

 },err=>{
   console.log(err);
 })
}


after submit success response i want to go for paypal checkout process how to do it.. i am stuck.

标签: javascriptangularpaypalpaypal-sandbox

解决方案


简而言之,您必须创建新组件并使用 dialogRef。 https://material.angular.io/components/dialog/overview

 const dialogRef = this.dialog.open(SuccessPaymentPaypalComponent, {
    disableClose: true,
    data: { PaypaplRetunrnTrasactionId: this.params.Paypalid }
 })
 dialogRef.afterClosed().subscribe(() => {
 });


推荐阅读