Android Question Stripe payments test

GraemeW

Member
Licensed User
Longtime User
I'm exploring the use of Stripe to process payments by app but am failing at the first code attempt. I'm hoping that if someone can provide a clue about the initial hurdle I'll be able to figure out the rest... ?

In trying to follow the Stripe setup instructions at https://stripe.com/docs/mobile/android/basic I'm using a JavaObject to access a de-sugared version of the Stripe JAR, using the tutorial example https://www.b4x.com/android/forum/t...h-additionaljar-and-javaobject-picasso.40904/

The problem is that B4A returns java.lang.ClassNotFoundException: com$stripe$android$PaymentConfiguration - so it doesn't seem to be able to find the Stripe JAR. Have I missed another initialization?

My "simple" test code is

B4X:
#Region  Project Attributes
    #ApplicationLabel: B4A Example
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

#AdditionalJar: stripe-java-18.5.0-converted

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout( "layout_main")

    Init_stripeSDK
    
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub Init_stripeSDK As JavaObject
    Dim jo As JavaObject
    'com.squareup.picasso.Picasso.with(context)
'    Return jo.InitializeStatic("com.squareup.picasso.Picasso").RunMethod("with", Array(GetContext))

    'com.stripe.android.PaymentConfiguration
    'using own pk_test api key
    Return jo.InitializeStatic( "com.stripe.android.PaymentConfiguration" ).RunMethod( "init", Array( GetContext, "pk_test_<my number>" ) )

End Sub

Sub GetContext As JavaObject
    Return GetBA.GetField("context")
End Sub

Sub GetBA As JavaObject
    Dim jo As JavaObject
    Dim cls As String = Me
    cls = cls.SubString("class ".Length)
    jo.InitializeStatic(cls)
    Return jo.GetFieldJO("processBA")
End Sub
 

GraemeW

Member
Licensed User
Longtime User
Thanks Erel - now I know I can browse jars with 7zip.. :) - and discovered stripe-java-18.5.0-converted doesn't contain an android folder - or PaymentConfiguration class anywhere. Same with the original jar.

I'm probably missing something fundamental about Stripe so will continue to read docs...
 
Last edited:
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

GraemeW

Member
Licensed User
Longtime User
aha - thanks DonManfred :) - I'd seen that before but now it's starting to make sense.. especially the reference to stripe-android-14.1.1.aar rather than stripe-java-18.7.0.jar

I'll keep reading and playing and see what happens..
 
Upvote 0

chrisjr9

New Member
Thank you, Erel. Now I know how to use 7zip to explore jars... :) - Stripe-java-18.5.0-converted doesn't have an android folder, nor does it have a PaymentConfiguration class. The same goes for the original jar.

I'm definitely missing something basic about Stripe, so I'll keep reading the documentation...
 
Upvote 0

chrisjr9

New Member
Thank you, Erel. Now I know how to use 7zip to explore jars... :) - Stripe-java-18.5.0-converted doesn't have an android folder, nor does it have a PaymentConfiguration class. The same goes for the original jar.

I'm definitely missing something basic about Stripe, so I'll keep reading the documentation...
oh
 
Upvote 0
Top