onPaymentSuccess 和 onPaymentError 可能未在您的 activity - Xamarin Android - Razorpay 集成中实现

onPaymentSuccess and onPaymentError probably not implemented in your activity - Xamarin Android - Razorpay Integration

我正在从我的 Xamarin Android 应用程序中实施 RazorPay 支付网关。问题是,当我进行支付回调函数 onPaymentSuccess 并且 onPaymentError 没有被调用。我正在分享我的代码,请检查一下,让我知道需要进行哪些更改?

  public class MainActivity : AppCompatActivity
    {

        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.activity_main);

            Checkout checkOut = new Checkout();
            checkOut.SetKeyID("********");
            AppCompatActivity activity = this;
            try
            {
                JSONObject jsonoptions = new JSONObject();
                jsonoptions.Put("description", "My Sample Payment activity");
                jsonoptions.Put("order_id", orderId);
                jsonoptions.Put("currency", "INR");
                jsonoptions.Put("amount", _amount);
                checkOut.Open(activity, jsonoptions);
            }
            catch (ExceptionInInitializerError ex)
            {
                //Console.WriteLine("error in payment");
            }   
         }


        public void onPaymentError(int p0, string p1, PaymentData p2)
        {
            string paymentid = p2.PaymentId;
            string orderid = p2.OrderId;

        }
        public void onPaymentSuccess(string p0, PaymentData p1)
        {

        }
}



当前Activity应该派生自接口IPaymentResultWithDataListener,然后这两个方法将在之后调用。

 public class MainActivity : AppCompatActivity , IPaymentResultWithDataListener