【问题标题】:Razorpay Dynamically get totalamount in Angular 2 not working in checkout pageRazorpay 动态获取 Angular 2 中的总金额在结帐页面中不起作用
【发布时间】:2018-02-20 07:24:45
【问题描述】:

我已将 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
  }

【问题讨论】:

    标签: angular2-template razorpay


    【解决方案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();
    }
    

    【讨论】:

      【解决方案2】:

      这对我有用

      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");
      }
      

      【讨论】:

        猜你喜欢
        • 2019-02-02
        • 2017-04-24
        • 2021-01-30
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-07-01
        • 2023-03-30
        • 2022-09-29
        相关资源
        最近更新 更多