Xamarin 表单中的 Razorpay 集成

Razorpay integration in xamarin forms

我正在尝试从我的 Xamarin 应用程序中集成 Razorpay 支付网关。为此,我在应用程序上添加了 RezaorPay Dll 并传递了所需的参数,但问题是它没有将我重定向到 webview。

我在这里分享我的代码。请仔细阅读并告诉我,需要进行哪些更改?

            Dictionary<string, object> input = new Dictionary<string, object>();
            input.Add("amount", 100); // this amount should be same as transaction amount
            input.Add("currency", "INR");
            input.Add("receipt", "12121");
            input.Add("payment_capture", 1);

            string key = "******";
            string secret = "******";

            RazorpayClient client = new RazorpayClient(key, secret);

            Razorpay.Api.Order order = client.Order.Create(input);
            orderId = order["id"].ToString();

您可以添加以下代码来显示您的视图

Activity activity = this;  
try {  
    JSONObject options = new JSONObject();  
    options.Put("description", "My Sample Payment activity");  
    options.Put("order_id", "order_EAMgUyLXrMfbmL");  
    options.Put("currency", "INR");  
    options.Put("amount", "100");  
    checkOut.Open(activity, options);  
} catch (Exception ex) {  
    Console.WriteLine("error in payment");  
}  

回调方法。

public void OnPaymentError(int p0, string p1, PaymentData p2) {  
    Console.WriteLine("error in payment");  
}  
public void OnPaymentSuccess(string p0, PaymentData p1) {  
    Console.WriteLine("success");  
}