【问题标题】:Razorpay integration in xamarin formsXamarin 表单中的 Razorpay 集成
【发布时间】:2020-09-24 05:53:50
【问题描述】:

我正在尝试从我的 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();

【问题讨论】:

    标签: xamarin xamarin.forms xamarin.android razorpay


    【解决方案1】:

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

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

    【讨论】:

    • 感谢您的回复。我尝试使用您给定的代码,但无法访问您上面提到的 checkOut 类。我检查并发现 Razorpay 没有为 Xamarin 提供任何结帐类或功能。那么,我怎样才能得到它?
    • 对于 xamarin 表单,您需要创建一个结帐 aar 文件的绑定库
    猜你喜欢
    • 2020-11-27
    • 2023-03-06
    • 2021-02-24
    • 2020-08-18
    • 2018-09-02
    • 2021-11-27
    • 2020-10-16
    • 2020-03-25
    • 2019-03-17
    相关资源
    最近更新 更多