coronalabs / corona

Solar2D Game Engine main repository (ex Corona SDK)
https://solar2d.com/
MIT License
2.54k stars 273 forks source link

Google billing v2 no longer works with pending purchases since the update to billing library 6 #711

Closed marksolar2d closed 4 months ago

marksolar2d commented 4 months ago

Normal purchases work as expected but pending/delayed purchases fail. There is no callback to storeTransaction(event)

Tested with live SKUs using this test code

Here is the log


07-08 14:01:44.923 22496 22549 I Corona  : Transaction event    {
07-08 14:01:44.923 22496 22549 I Corona  :   "name":"init",
07-08 14:01:44.923 22496 22549 I Corona  :   "transaction":{
07-08 14:01:44.923 22496 22549 I Corona  :     "isError":false,
07-08 14:01:44.923 22496 22549 I Corona  :     "state":"initialized"
07-08 14:01:44.923 22496 22549 I Corona  :   }
07-08 14:01:44.923 22496 22549 I Corona  : }
07-08 14:01:44.923 22496 22549 I Corona  : ----------------
07-08 14:01:46.626 22496 22549 I Corona  : Product list event   {
07-08 14:01:46.626 22496 22549 I Corona  :   "invalidProducts":[],
07-08 14:01:46.626 22496 22549 I Corona  :   "name":"productList",
07-08 14:01:46.626 22496 22549 I Corona  :   "products":[{
07-08 14:01:46.626 22496 22549 I Corona  :       "priceAmountMicros":"990000",
07-08 14:01:46.626 22496 22549 I Corona  :       "originalJson":"{\"title\":\"bag of money\",\"description\":\"Purchase a bag of money\",\"productId\":\"\",\"type\":\"inapp\",\"packageName\":\"\",\"localizedPrice\":\"£0.99\",\"price_amount_micros\":990000,\"price_currency_code\":\"GBP\"}",
07-08 14:01:46.626 22496 22549 I Corona  :       "description":"bag of money",
07-08 14:01:46.626 22496 22549 I Corona  :       "priceCurrencyCode":"GBP",
07-08 14:01:46.626 22496 22549 I Corona  :       "productIdentifier":"",
07-08 14:01:46.626 22496 22549 I Corona  :       "localizedPrice":"£0.99",
07-08 14:01:46.626 22496 22549 I Corona  :       "type":"inapp",
07-08 14:01:46.626 22496 22549 I Corona  :       "title":""
07-08 14:01:46.626 22496 22549 I Corona  :     }]
07-08 14:01:46.626 22496 22549 I Corona  : }
07-08 14:01:46.626 22496 22549 I Corona  : ----------------
07-08 14:01:51.395 22496 22549 I Corona  : JavaToNativeShim.pause(runtime)
07-08 14:01:51.406 22496 22496 I Corona  : controller.getGLView().onPause()
07-08 14:02:02.327 22496 22549 I Corona  : JavaToNativeShim.resume(runtime)
07-08 14:02:02.335 22496 22549 I Corona  : controller.requestRender()
07-08 14:02:02.335 22496 22549 E Corona  : StoreTransactionRuntimeTask: dispatching Google IAP storeTransaction event
07-08 14:02:02.335 22496 22549 E Corona  : java.lang.NullPointerException: null
07-08 14:02:02.335 22496 22549 E Corona  :      at com.naef.jnlua.LuaState.lua_pushstring(Native Method)
07-08 14:02:02.335 22496 22549 E Corona  :      at com.naef.jnlua.LuaState.pushString(LuaState.java:691)
07-08 14:02:02.335 22496 22549 E Corona  :      at plugin.google.iap.billing.v2.StoreTransactionRuntimeTask.executeUsing(StoreTransactionRuntimeTask.java:86)
07-08 14:02:02.335 22496 22549 E Corona  :      at com.ansca.corona.CoronaRuntimeTaskDispatcher$TaskEvent.Send(CoronaRuntimeTaskDispatcher.java:179)
07-08 14:02:02.335 22496 22549 E Corona  :      at com.ansca.corona.events.EventManager.sendEvents(EventManager.java:100)
07-08 14:02:02.335 22496 22549 E Corona  :      at com.ansca.corona.Controller.updateRuntimeState(Controller.java:372)
07-08 14:02:02.335 22496 22549 E Corona  :      at com.ansca.corona.graphics.opengl.CoronaGLSurfaceView$CoronaRenderer.onDrawFrame(CoronaGLSurfaceView.java:434)
07-08 14:02:02.335 22496 22549 E Corona  :      at com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1625)
07-08 14:02:02.335 22496 22549 E Corona  :      at com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1380)```
Shchvova commented 4 months ago

Thank you for reporting. Fixed plugin is up

marksolar2d commented 4 months ago

Getting there... but event.transaction.identifier is an empty string then the purchase is delayed. I cache this between sessions to know if the purchase was previously made in a different session and to award the player.

07-08 19:10:31.006  4344 11045 I Corona  :   [name] => "storeTransaction"
07-08 19:10:31.006  4344 11045 I Corona  :   [transaction] => table: 0xb400006e3b157900 {
07-08 19:10:31.006  4344 11045 I Corona  :                      [identifier] => ""

This value is correctly filled when the "purchased" state is returned.

07-08 19:11:30.009  4344 11045 I Corona  :   [name] => "storeTransaction"
07-08 19:11:30.009  4344 11045 I Corona  :   [transaction] => table: 0xb400006e5c612380 {
07-08 19:11:30.009  4344 11045 I Corona  :                      [identifier] => "GPA.3323-3709-3556-17193"
Shchvova commented 4 months ago

I see... It seems that now [getOrderId](https://developer.android.com/reference/com/android/billingclient/api/Purchase#getOrderId()) which is matched to the identifier field won't be set unless state is purchased.