如何解决无法在 Angular 的 razorPaySuccessHandler 中调用自定义函数/服务
我正在尝试在付款成功后调用 API。所以我在 razorPaySuccessHandler 函数中调用 Function ,但它抛出如下错误:
constructor(
private userService: UserService
) { }
paymentProcess() {
let creditDialogRef = this.dialog.open(CreditFormComponent);
creditDialogRef.afterClosed().subscribe(result => {
this.userService.createOrder(this.id).subscribe(res => {
// this.RAZORPAY_OPTIONS.amount = result.data.amount;
this.RAZORPAY_OPTIONS.amount = '100';
this.RAZORPAY_OPTIONS.order_id = '';
// binding this object to both success and dismiss handler
this.RAZORPAY_OPTIONS["handler"] = this.razorPaySuccessHandler.bind(this);
let razorpay = new Razorpay(this.RAZORPAY_OPTIONS);
razorpay.open();
});
});
}
public razorPaySuccessHandler(response) {
console.log("razorpay",response)
if (response.razorpay_payment_id) {
console.log(response,"Order Placed");
this.razorpayResponse = `Razorpay Response`;
this.userService.verifyOrder(this.orderId).subscribe(res=>{
console.log(res)
})
}
else {
console.log("Payment failed")
}
}
我收到错误:
Uncaught TypeError: Cannot read property 'verifyOrder' of undefined
at Ui.push../src/app/views/marketing/home-page/home-page.component.ts.HomePageComponent.razorPaySuccessHandler (home-page.component.ts:214)
at checkout.js:1
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:423)
at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:195)
如何在其中调用自己的函数或服务?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。