I am using the below piece of code in my Angular . 1)How do i catch the Sucess and Error message. 2)When i give credit card details paypal window closes automatically. Please do the needful. Thanks in advance. paypalConfig = { env: 'sandbox', style: { label: 'buynow', fundingicons: true, // optional branding: true, // optional size: 'medium', // small | medium | large | responsive shape: 'rect', // pill | rect color: 'gold' // gold | blue | silver | black }, client: { sandbox:'AaQ1Ni2JHAoUvp3lGfKKzTABEvI-QHCytN1Tkaq-ItTsnDusXUImDCZ4C5w63WjYsd5W2rV', production: '<your-production-key-here>' }, commit: true, payment: (data, actions) => { console.log("final amount "+this.finalAmount) this.finalAmount=1; return actions.payment.create({ payment: { transactions: [ { amount: { total: this.finalAmount, currency:'USD' } } ] }, experience: { input_fields: { no_shipping: 1 } } }).catch((error) => { console.log(error.message); }); }, onAuthorize: (data, actions) => { console.log("data"+data) console.log("data"+actions) return actions.payment.execute().then((payment) => { console.log(payment) window.alert('Payment Complete!'); }) ; } }; 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); }) } }
... View more