我已将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
}
答案 0 :(得分: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();
}
答案 1 :(得分: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");
}