I'm encountering an issue where I'm getting a "RazorPayCheckout is not defined" error. I've searched on StackOverflow but couldn't find any helpful answers. Can someone please assist me with this? Thank you in advance.
app.component.html
<button (click)="payWithRazor()">Proceed to Pay</button>
app.component.ts
payWithRazor() {
var options = {
key: 'KEY', // Please insert your Razorpay key here
name: 'Bunto Couriers Pvt. Ltd.',
description: 'Delivery Fee',
amount: this.price*100, // Razorpay requires the amount in paisa
prefill: {
name: '',
email: '', // Please add your email address
},
image: 'link',
notes: {},
theme: {
color: '#00FF00'
},
modal: {
ondismiss: (() => {
this.zone.run(() => {
// Add current page routing if payment fails
})
})
}
};
var successCallback = function (payment_id) {
alert('payment_id: ' + payment_id);
};
var cancelCallback = function (error) {
alert(error.description + ' (Error ' + error.code + ')');
};
RazorpayCheckout.on('payment.success', successCallback);
RazorpayCheckout.on('payment.cancel', cancelCallback);
RazorpayCheckout.open(options);
}
declaration.d.ts
declare module '*';
declare var RazorpayCheckout: any;