Pypal checkout button not loading on live website with ng build code

yogeshjakhar19
New Community Member
This work fine for me in local-host with both sandbox and production. But when I run command ng build --prod and publish
code on live website, it starts giving error. Can anyone help me in suggesting what is the issue
 
paypalConfig = {
    env: 'production',
    client:{
      //sandbox: '<sandbox-key>',
      production: '<my-key>'
    },
    commit: true,
    payment: (dataactions=>{
      return actions.payment.create({
        payment:{
          transactions: [
            {
              "item_list": {
                "items": [{
                    "name": "Car Upload " + this.firstFormGroup.value.identifier,
                    "sku": "item",
                    "price": this.final-amount,
                    "currency": "USD",
                    "quantity": this.firstFormGroup.value.quantity
                }]
            },
              amount: {total: this.final-amount*this.firstFormGroup.value.quantitycurrency: 'USD'}
            }
          ]
        }
      });
    },
    onAuthorize: (dataactions=>{
      return actions.payment.execute().then((payment)=>{
        this.payment(payment);
      });
    }
  };

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

      })
    }
  }

  addPaypalScript(){
    this.addScript = true;
    return new Promise((resolvereject)=>{
      let scripttagElement = document.createElement('script');
      scripttagElement.src = "http://www.paypalobjects.com/api/checkout.js";
      scripttagElement.onload = resolve;
      document.body.appendChild(scripttagElement);
    })
  }
 
 
Login to Me Too
0 REPLIES 0

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.