Hello,
I am encountering error while trying to call open method at Razorpay.
Below is my code
The below Error I am getting :
The below Open method from Android Studio I am trying to call. The open method is running fine at Android Studio:
Please advice.
Thanks
I am encountering error while trying to call open method at Razorpay.
Below is my code
B4X:
Sub Button1_Click
Dim jo As JavaObject
Dim key As String="rzp_test_xxxxxxxx"
jo.InitializeNewInstance("com.razorpay.Checkout", Null)
jo.RunMethodJO("setKeyID",Array(key))
Dim Map1,Map2 As Map
Map1.Initialize
Map2.Initialize
Dim JSONGenerator1 As JSONGenerator
Map2.put("email", "[email protected]")
Map2.put("contact", "9876543210")
JSONGenerator1.Initialize(Map2)
Dim JSONGenerator As JSONGenerator
Map1.put("name", "Lito")
Map1.put("description", "Fare")
Map1.put("currency", "INR")
Map1.put("amount", "100")
Map1.put("prefill", JSONGenerator1.ToString)
JSONGenerator.Initialize(Map1)
Log(JSONGenerator.ToString)
jo.RunMethodJO("open",Array(act,JSONGenerator))
End Sub
The below Error I am getting :
B4X:
Error occurred on line: 86 (Main)
java.lang.RuntimeException: Method: open not matched.
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:129)
at anywheresoftware.b4j.object.JavaObject.RunMethodJO(JavaObject.java:138)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:777)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:354)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:197)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:6614)
at android.view.View.performClickInternal(View.java:6587)
at android.view.View.access$3100(View.java:787)
at android.view.View$PerformClick.run(View.java:26122)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:201)
at android.app.ActivityThread.main(ActivityThread.java:6820)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
The below Open method from Android Studio I am trying to call. The open method is running fine at Android Studio:
B4X:
public void startPayment() {
/*
You need to pass current activity in order to let Razorpay create CheckoutActivity
*/
final Activity activity = this;
final Checkout co = new Checkout();
co.setKeyID("rzp_test_xxxxxxxxxx");
try {
JSONObject options = new JSONObject();
options.put("name", "Lito");
options.put("description", "Fare");
options.put("currency", "INR");
options.put("amount", "100");
JSONObject preFill = new JSONObject();
preFill.put("email", "[email protected]");
preFill.put("contact", "9876543210");
options.put("prefill", preFill);
co.open(activity, options);
} catch (Exception e) {
Toast.makeText(activity, "Error in payment: " + e.getMessage(), Toast.LENGTH_SHORT)
.show();
e.printStackTrace();
}
}
Please advice.
Thanks