Whenever it's time for a user to pay an amount he/she owes me, I would like to launch Paypal or GPay app with necessary information prefilled, all the user has to do is to double-check everything shown and either accept to pay or decline to refuse. The result, whether it's paid or not, would be passed back to my app.
I have little experience with Intent, and I would appreciate any help.
Below is the code describing what I'm trying to achieve:
I have little experience with Intent, and I would appreciate any help.
Below is the code describing what I'm trying to achieve:
B4X:
Dim in As Intent
in = Activity.GetStartingIntent
If in <> Null Then
'check some key to find out if the payment attempt was successful
If in.HasExtra("Result") Then 'Result is not a real key name
Dim Result As Int =in.GetExtra("Result")
Log("Result=" & Result )
Log("in.ExtrasToString=" & in.ExtrasToString)
If Result=1 Then
Log("paid successfully")
Else
Log("payment failed")
End If
Else
Dim in2 As Intent
in2.Initialize("com.paypal.android.p2pmobile.REQUEST","") 'initialized to paypal
in2.AddCategory("android.intent.category.DEFAULT")
in2.PutExtra("Callback","com.ddg.myrequestor.CALLBACK")
in2.PutExtra("MyAccountNo","123xyz") 'this will be my palpal account #. User's payment will be deposited into this account
in2.PutExtra("Amount","123.45") 'amount user owes me
StartActivity(in2)
End If
End If
relevant part of Manifest file:
'for intent
AddActivityText(Main, <intent-filter>
<action android:name="com.ddg.myrequestor.CALLBACK" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>)