Skip to content

Commit

Permalink
Merge pull request #65 from defold/dev-update-to-android-billing-6-0-0
Browse files Browse the repository at this point in the history
Updated to Play Billing 6.0.0
  • Loading branch information
britzl authored Jul 3, 2024
2 parents 68ef7f4 + 8011792 commit ba0e1b6
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 3 deletions.
6 changes: 5 additions & 1 deletion extension-iap/manifests/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
repositories {
mavenCentral()
}

dependencies {
implementation 'com.android.billingclient:billing:5.0.0'
implementation 'com.android.billingclient:billing:6.0.0'
}
1 change: 1 addition & 0 deletions extension-iap/src/iap.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ enum BillingResponse
BILLING_RESPONSE_RESULT_ERROR = 6,
BILLING_RESPONSE_RESULT_ITEM_ALREADY_OWNED = 7,
BILLING_RESPONSE_RESULT_ITEM_NOT_OWNED = 8,
BILLING_RESPONSE_RESULT_NETWORK_ERROR = 9,
};

enum ProviderId
Expand Down
4 changes: 3 additions & 1 deletion extension-iap/src/java/com/defold/iap/IapGooglePlay.java
Original file line number Diff line number Diff line change
Expand Up @@ -221,14 +221,16 @@ private int billingResponseCodeToDefoldResponse(int responseCode) {
case BillingResponseCode.OK:
defoldResponse = IapJNI.BILLING_RESPONSE_RESULT_OK;
break;
case BillingResponseCode.SERVICE_TIMEOUT:
case BillingResponseCode.SERVICE_UNAVAILABLE:
case BillingResponseCode.SERVICE_DISCONNECTED:
defoldResponse = IapJNI.BILLING_RESPONSE_RESULT_SERVICE_UNAVAILABLE;
break;
case BillingResponseCode.USER_CANCELED:
defoldResponse = IapJNI.BILLING_RESPONSE_RESULT_USER_CANCELED;
break;
case BillingResponseCode.NETWORK_ERROR: // new in Play Billing Library 6.0.0
defoldResponse = IapJNI.BILLING_RESPONSE_RESULT_NETWORK_ERROR;
break;
case BillingResponseCode.FEATURE_NOT_SUPPORTED:
case BillingResponseCode.ERROR:
default:
Expand Down
1 change: 1 addition & 0 deletions extension-iap/src/java/com/defold/iap/IapJNI.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class IapJNI implements IListProductsListener, IPurchaseListener {
public static final int BILLING_RESPONSE_RESULT_ERROR = 6;
public static final int BILLING_RESPONSE_RESULT_ITEM_ALREADY_OWNED = 7;
public static final int BILLING_RESPONSE_RESULT_ITEM_NOT_OWNED = 8;
public static final int BILLING_RESPONSE_RESULT_NETWORK_ERROR = 9;

public IapJNI() {
}
Expand Down
8 changes: 7 additions & 1 deletion main/main.gui_script
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,13 @@ end

local function buy(id)
log("iap.buy() " .. id)
iap.buy(id)
local options = {}
local item = available_items[id]
if item.subscriptions then
local subscription = item.subscriptions[1]
options.token = subscription.token
end
iap.buy(id, options)
end

local function restore()
Expand Down

0 comments on commit ba0e1b6

Please sign in to comment.