How to Integrate Razorpay in Angular 2?

前端 未结 4 655
情歌与酒
情歌与酒 2020-12-17 01:22

I\'m using angular 2. I\'ve tried below URL\'s to integrate Razorpay [https://docs.razorpay.com/docs/checkout-form][1]

When i follow this URL, i got these errors lik

4条回答
  •  有刺的猬
    2020-12-17 02:12

    declare Razorpay inside polyfills.ts file

    // polyfills.ts file
    declare global {
        interface Window {
            Razorpay: any;
        }
     }
    

    MyComponent.ts file

    @Component({...})
    class MyComponent {
    
    constructor() {
    }
    rzp1:any;
    options = {
       "key": "rzp_test_HTQz79bVMhpN4L",
       "amount": "2000",
       "name": "Merchant Name",
       ....
       .....
    };
    
    public initPay():void {
       this.rzp1 = new window.Razorpay(this.options);
       this.rzp1.open();
    }
    }
    

提交回复
热议问题