Android Question [solved] GooglePlayBilling v7.00 - subscription error

aeric

Expert
Licensed User
Longtime User
I am testing the new GooglePlayBilling library v7.00

I get an error on line #99 when calling LaunchBillingFlow for subscriptions.
B4X:
Result = billing.LaunchBillingFlow(SkuDetails.Get(0))

SkuDetails.Get(0) has value:

ProductDetails{jsonString='{"productId":"weekly_1","type":"subs","title":"Weekly RM1.99 (In App Billing Demo)","name":"Weekly RM1.99","description":"Weekly Subscription for RM1.99 only","localizedIn":["en-US"],"skuDetailsToken":"AEuhp4JcTcV5...","subscriptionOfferDetails":[{"offerIdToken":"AZbOM32R2\/CPjBmc...==","basePlanId":"p1w","pricingPhases":[{"priceAmountMicros":1990000,"priceCurrencyCode":"MYR","formattedPrice":"RM 1.99","billingPeriod":"P1W","recurrenceMode":1}],"offerTags":[]}]}', parsedJson={"productId":"weekly_1","type":"subs","title":"Weekly RM1.99 (In App Billing Demo)","name":"Weekly RM1.99","description":"Weekly Subscription for RM1.99 only","localizedIn":["en-US"],"skuDetailsToken":"AEuhp4JcTcV5...=","subscriptionOfferDetails":[{"offerIdToken":"AZbOM32R2\/CPjBmc...==","basePlanId":"p1w","pricingPhases":[{"priceAmountMicros":1990000,"priceCurrencyCode":"MYR","formattedPrice":"RM 1.99","billingPeriod":"P1W","recurrenceMode":1}],"offerTags":[]}]}, productId='weekly_1', productType='subs', title='Weekly RM1.99 (In App Billing Demo)', productDetailsToken='AEuhp4JcTcV5...=', subscriptionOfferDetails=[com.android.billingclient.api.ProductDetails$SubscriptionOfferDetails@f93a1b]}

Error logs:
Query (subs) completed: true <-- Result.IsSuccess from Billing_PurchasesQueryCompleted
[] <-- Purchases.As(Object)
Error occurred on line: 99 (Main)
java.lang.NullPointerException: offerToken is required for constructing ProductDetailsParams for subscriptions.
at com.google.android.gms.internal.play_billing.zzaa.zzc(com.android.billingclient:billing@@7.0.0:1)
at com.android.billingclient.api.BillingFlowParams$ProductDetailsParams$Builder.build(com.android.billingclient:billing@@7.0.0:3)
at anywheresoftware.b4a.objects.BillingClientWrapper.LaunchBillingFlow(BillingClientWrapper.java:263)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
at anywheresoftware.b4a.shell.DebugResumableSub$RemoteResumableSub.resume(DebugResumableSub.java:22)
at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:275)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:150)
at anywheresoftware.b4a.BA$2.run(BA.java:395)
at android.os.Handler.handleCallback(Handler.java:794)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:6651)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:824)
 
Solution
Solved.

B4X:
'Result = LaunchBillingFlow(billing, SkuDetails.Get(0), "")
Dim offers As List = SkuDetails.Get(0).As(JavaObject).RunMethod("getSubscriptionOfferDetails", Null)
Dim offer As JavaObject = offers.Get(0)
Dim OfferToken As String = offer.RunMethod("getOfferToken", Null)
Result = LaunchBillingFlow(billing, SkuDetails.Get(0), OfferToken)

aeric

Expert
Licensed User
Longtime User
Solved.

B4X:
'Result = LaunchBillingFlow(billing, SkuDetails.Get(0), "")
Dim offers As List = SkuDetails.Get(0).As(JavaObject).RunMethod("getSubscriptionOfferDetails", Null)
Dim offer As JavaObject = offers.Get(0)
Dim OfferToken As String = offer.RunMethod("getOfferToken", Null)
Result = LaunchBillingFlow(billing, SkuDetails.Get(0), OfferToken)

 
Upvote 1
Solution

giggetto71

Active Member
Licensed User
Longtime User
HI @aeric .Where did you find the version 7 of the GooglePlayBilling library? from the ide I can see that the latest available is 5.21. as all the developers I got the notification from google to update to the 6 or newer by Aug. 31th 2024..
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
HI @aeric .Where did you find the version 7 of the GooglePlayBilling library? from the ide I can see that the latest available is 5.21. as all the developers I got the notification from google to update to the 6 or newer by Aug. 31th 2024..
Check attached library by Erel in post #3.
 
Upvote 0

Jim McDougal

Member
Licensed User
Is GooglePlayBilling v7 an internal library? I'm running B4A 12.80 but the Libraries Manager is showing GooglePlayBilling as v5. I also placed the separate jar files for v7 in my Additional Libraries folder but still nothing shows except GooglePlayBilling v5 in Libraries Manager.
 
Upvote 0

Scantech

Well-Known Member
Licensed User
Longtime User
Is GooglePlayBilling v7 an internal library? I'm running B4A 12.80 but the Libraries Manager is showing GooglePlayBilling as v5. I also placed the separate jar files for v7 in my Additional Libraries folder but still nothing shows except GooglePlayBilling v5 in Libraries Manager.
i placed mine at C:\Program Files\Anywhere Software\B4A\Libraries. Its internal library
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Is GooglePlayBilling v7 an internal library?
1717304500339.png


You can see it in the libraries tab.
 
Upvote 0

Jim McDougal

Member
Licensed User
I didn't see v7.00 in the libraries tab after upgrading to 12.80 (it was still v5.00) so I followed Scantech's advice, manually replacing v5.00 with v7.00 in the internal libraries folder and now the libraries tab shows v7.00. I was assuming that since it is an internal library it would upgrade to v7.00 with the latest B4A upgrade, but apparently not. Nevertheless, question resolved. Thank you, all.
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
I didn't see v7.00 in the libraries tab after upgrading to 12.80 (it was still v5.00) so I followed Scantech's advice, manually replacing v5.00 with v7.00 in the internal libraries folder and now the libraries tab shows v7.00. I was assuming that since it is an internal library it would upgrade to v7.00 with the latest B4A upgrade, but apparently not. Nevertheless, question resolved. Thank you, all.
All the while it works like that.
When a new internal library is released after the latest version of B4A released, we need to copy it to internal library folder. We don't reinstall B4A.
The message saying that it is an internal library denotes that the correct way is to copy the library to internal library which is inside B4A installation folder instead of additional library folder, to avoid it is not loading as you did. It also means that it will available in the next release of B4A if there is no newer version of this library released until then. Hope this answers your doubt.
 
Upvote 0

Jim McDougal

Member
Licensed User
A classic timing issue. Makes perfect sense. I did upgrade to the latest version of B4A as a result anyway, so it's all good.

Thanks!
 
Upvote 0

hatzisn

Expert
Licensed User
Longtime User
Solved.

B4X:
'Result = LaunchBillingFlow(billing, SkuDetails.Get(0), "")
Dim offers As List = SkuDetails.Get(0).As(JavaObject).RunMethod("getSubscriptionOfferDetails", Null)
Dim offer As JavaObject = offers.Get(0)
Dim OfferToken As String = offer.RunMethod("getOfferToken", Null)
Result = LaunchBillingFlow(billing, SkuDetails.Get(0), OfferToken)


Thank you very much. Great solution. It solved a lot for me.
 
Upvote 0
Top