-
async function StartRazorpay(publicKey, orderId, userId, username, email, amount) {
var options = {
key: publicKey,
amount: amount,
currency: "INR",
order_id: orderId,
name: "OnlySwipe",
description: "Payment for Order",
prefill: {
userId: userId,
username : username,
email: email,
},
handler: async function (successResponse) {
await window.HybridWebView.InvokeDotNet('PaymentSuccess',
[
successResponse.razorpay_payment_id,
successResponse.razorpay_order_id
]);
},
modal: {
escape: false,
ondismiss: async function() {
await window.HybridWebView.InvokeDotNet('PaymentCancelled');
}
},
theme: {
color: "#FF0000"
}
};
var rzp = new Razorpay(options);
rzp.on('payment.failed', async function (failedResponse){
await window.HybridWebView.InvokeDotNet('PaymentFailed',
[
failedResponse.error.metadata.payment_id,
failedResponse.error.metadata.order_id,
failedResponse.error.code,
failedResponse.error.description,
failedResponse.error.reason
]);
});
rzp.open();
await window.HybridWebView.InvokeDotNet('OnStartRazorpayExecuted');
}
async function TestMethod() {
await window.HybridWebView.InvokeDotNet('OnTestMethodExecuted');
}
```
```cs
public void OnStartRazorpayExecuted()
{
Console.WriteLine("method triggered successFully");
}
public void OnTestMethodExecuted()
{
Console.WriteLine("method triggered successFully");
}
private async void LoadRazorpayClicked(object? sender, EventArgs e)
{
if (_testCreateOrderIdResponse is null) return;
await RootWebView.EvaluateJavaScriptAsync($"StartRazorpay({_testCreateOrderIdResponse.PublicKey}, {_testCreateOrderIdResponse.OrderId}, {UserDetails.Id.ToString()}, {UserDetails.Username}, {UserDetails.Email}, {_testCreateOrderIdResponse.Amount.ToString()})");
await RootWebView.EvaluateJavaScriptAsync("TestMethod()");
}
```
if i invoke 'LoadRazorpayClicked' this method 'TestMethod' Invoke successfully but 'StartRazorpay' method was not invoking and if i trigger the 'StartRazorpay' method using HTML button it is invoking properly and Razorpay page loading properly. |
Beta Was this translation helpful? Give feedback.
Answered by
RSReswin
Apr 29, 2025
Replies: 1 comment
-
await RootWebView.EvaluateJavaScriptAsync($"StartRazorpay(\"{_testCreateOrderIdResponse.PublicKey}\", \"{_testCreateOrderIdResponse.OrderId}\", \"{UserDetails.Id}\", \"{UserDetails.Username}\", \"{UserDetails.Email}\", \"{_testCreateOrderIdResponse.Amount}\")"); I Pass all the Values to string to js method same like this code, the method was Invoked successFully. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
RSReswin
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I Pass all the Values to string to js method same like this code, the method was Invoked successFully.