RazorPay在Angular 2中动态获取AttrotAmount,在结帐页面中不起作用



我已将razorpay集成到我的结帐页面中。

我需要从下达的订单中获取金额,我该如何动态获取。

下面是Razorpay config。

public totalAmount:number;
rzp1: any;
options = {
    key: "rzp_test_m8sE9eaFkPEUHRasfm",
    amount: this.totalAmount, // Doesnt work here
    name: "Test Pvt Ltd",
    description: "Purchase Description",
    image: "../../../assets/static/hmicon.png",
    handler: function(response) {
      this.paymentId=response.razorpay_payment_id;
      this.orderanything(this.paymentId);
    },
    modal: {
    ondismiss: function() {}
    },
    prefill: {
      name: "Test",
      email: "test123@gmail.com"
    },
    notes: {
      address: "Hello World"
    },
    theme: {
      color: "#F37254"
    }
  };
 public initPay(): void {
    this.rzp1 = new this.winRef.nativeWindow.Razorpay(this.options);
    this.rzp1.open();
    this.totalAmount=this.getTotal();
    console.log(this.totalAmount)   //here i get the total
  }

好吧,我取得了类似的成就:

public totalAmount: number;
options = {
  key: "rzp_test_asasdsd...",
  amount: this.totalAmount,
  ...
}
public initPay(): void {
    console.log(this.totalAmount);
    this.options.amount = this.getTotal() * 100; 
    this.rzp1 = new this.winRef.nativeWindow.Razorpay(this.options);
    this.rzp1.open();
}

这对我有用

public totalAmount: number;
options = {
     "key": 'rzp_test_wVhWYAQR2....', 
      "amount": '',
}
public numbersum: number;
public razorsum :number;
public initPay(): void {
     
console.log(this.sum);
      this.numbersum  = this.sum*100;
      this.razorsum = this.numbersum
      this.options.amount = this.razorsum;
      var rzp1 = new Razorpay(this.options);
      rzp1.open();
      console.log("works");
}

最新更新