I am implementing the RazorPay payment gateway from my Xamarin Android App. Problem is that when I make the payment callback function onPaymentSuccess and onPaymentError is not invoked. I am sharing my code, please go through it and let me know what are the changes required?
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)
{
}
}
Current Activity should derives from interface IPaymentResultWithDataListener
, then the two methods would invoke after that .
public class MainActivity : AppCompatActivity , IPaymentResultWithDataListener