Skip to content

Commit

Permalink
Fixed multiple purchase events
Browse files Browse the repository at this point in the history
  • Loading branch information
scottrules44 committed Nov 4, 2022
1 parent 05083dc commit ca5abda
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
Binary file modified plugins/2017.3105/android/plugin.google.iap.billing.v2.jar
Binary file not shown.
6 changes: 3 additions & 3 deletions src/Corona/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ local json = require "json"
local store = require("plugin.google.iap.billing.v2")

local products = {
"com.solar2d.permanent",
"android.test.purchased",
"com.solar2d.comsumable",
"nope-product",
}
Expand Down Expand Up @@ -49,7 +49,7 @@ y=y+40

local text = display.newText( "purchase consumable", display.contentCenterX, y, native.systemFont, 25 )
text:addEventListener( "tap", function( )
store.purchase("com.solar2d.comsumable")
store.purchase("android.test.purchased")
end )
y=y+40

Expand All @@ -61,7 +61,7 @@ y=y+40

local text = display.newText( "purchase permanent", display.contentCenterX, y, native.systemFont, 25 )
text:addEventListener( "tap", function( )
store.purchase("com.solar2d.permanent")
store.purchase("android.test.purchased")
end )
y=y+40

Expand Down
1 change: 1 addition & 0 deletions src/android/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ android {
defaultConfig {
applicationId = coronaAppPackage
targetSdkVersion(29)
ndkVersion = "18.1.5063045"
minSdkVersion(coronaMinSdkVersion)
versionCode = coronaVersionCode
versionName = coronaVersionName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ private int init(LuaState L) {

CoronaActivity activity = CoronaEnvironment.getCoronaActivity();
if (activity != null) {
//if billing client exist, end/cancel it ,or we will get a multiple callbacks
if(fBillingClient != null){
fBillingClient.endConnection();
}
fBillingClient = BillingClient.newBuilder(activity).enablePendingPurchases().setListener(this).build();
fBillingClient.startConnection(new BillingClientStateListener() {
int listener;
Expand Down

0 comments on commit ca5abda

Please sign in to comment.