无法在角度4中整合razorpay

时间:2018-04-17 06:14:50

标签: javascript angular razorpay

我正在尝试整合razorPay支付网关。



  payNow( ) { 
        
          var options = {
            "key": "rzp_test_dveDexCQKoGszl",
            "amount":((this.buyNow==1)?this.shared.totalAmountWithDisocuntBuyNow:this.shared.totalAmountWithDisocunt)*100, // 2000 paise = INR 20
            "name": " MARKET",
            "description": "Order #",
        
            "handler": function (response){
                console.log(response);
                alert(response.razorpay_payment_id);
                this.paid();
                this.shared.addOrder(this.buyNow,response.razorpay_payment_id);     
         
              
               },
            "prefill": {
                "name":  this.shared.orderDetails.billing_firstname + " " + this.shared.orderDetails.billing_lastname,
                "email": this.shared.customerData.customers_email_address,
                "contact": this.shared.customerData.customers_telephone,
           
            },
            "notes": {
                "address": this.shared.orderDetails.billing_street_address+', '+this.shared.orderDetails.billing_city+', '+this.shared.orderDetails.billing_state+' '+this.shared.orderDetails.billing_postcode+', '+this.shared.orderDetails.billing_country 
            },
            "theme": {
                "color": "blue"
            }
        };
        var rzp1 = new Razorpay(options);

       rzp1.open();
  
     // body...
   } 
   paid()
   {alert();}




我在处理程序中定义了回调函数。但问题是它是否成功记录响应并提醒它,但它没有调用 this.paid()  要么 this.shared.addOrder(this.buyNow,response.razorpay_payment_id);

没有任何控制台错误。它只是不调用任何上述甲硫氨酸功能。

1 个答案:

答案 0 :(得分:1)

您可以使用以下语法将函数绑定到函数来调用处理函数

"handler":this.shared.addOrder.bind(this,this.buyNow) ,

这对我有用。