1

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

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

以下是razorpay 配置。

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
  }
4

2 回答 2

1

好的,我实现了类似:

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();
}
于 2018-02-20T11:54:34.640 回答
0

这对我有用

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");
}
于 2020-06-26T08:33:11.977 回答