Compare commits

..

No commits in common. "master" and "5.1.1" have entirely different histories.

8 changed files with 9 additions and 24 deletions

2
.gitignore vendored
View File

@ -9,5 +9,3 @@ Thumbs.db
.cproject .cproject
builtins builtins
_site _site
manifest.private.der
manifest.public.der

View File

@ -234,3 +234,6 @@ On iOS, the "price_string" field contains '~' characters
## Source code ## Source code
The source code is available on [GitHub](https://github.com/defold/extension-iap) The source code is available on [GitHub](https://github.com/defold/extension-iap)
## API reference

View File

@ -1,7 +1,3 @@
repositories {
mavenCentral()
}
dependencies { dependencies {
implementation 'com.android.billingclient:billing:7.0.0' implementation 'com.android.billingclient:billing:5.0.0'
} }

View File

@ -31,7 +31,6 @@ enum BillingResponse
BILLING_RESPONSE_RESULT_ERROR = 6, BILLING_RESPONSE_RESULT_ERROR = 6,
BILLING_RESPONSE_RESULT_ITEM_ALREADY_OWNED = 7, BILLING_RESPONSE_RESULT_ITEM_ALREADY_OWNED = 7,
BILLING_RESPONSE_RESULT_ITEM_NOT_OWNED = 8, BILLING_RESPONSE_RESULT_ITEM_NOT_OWNED = 8,
BILLING_RESPONSE_RESULT_NETWORK_ERROR = 9,
}; };
enum ProviderId enum ProviderId

View File

@ -21,7 +21,6 @@ import com.android.billingclient.api.BillingClient;
import com.android.billingclient.api.BillingClient.BillingResponseCode; import com.android.billingclient.api.BillingClient.BillingResponseCode;
import com.android.billingclient.api.BillingClient.ProductType; import com.android.billingclient.api.BillingClient.ProductType;
import com.android.billingclient.api.BillingResult; import com.android.billingclient.api.BillingResult;
import com.android.billingclient.api.PendingPurchasesParams;
import com.android.billingclient.api.Purchase; import com.android.billingclient.api.Purchase;
import com.android.billingclient.api.Purchase.PurchaseState; import com.android.billingclient.api.Purchase.PurchaseState;
import com.android.billingclient.api.ProductDetails; import com.android.billingclient.api.ProductDetails;
@ -57,8 +56,7 @@ public class IapGooglePlay implements PurchasesUpdatedListener {
this.activity = activity; this.activity = activity;
this.autoFinishTransactions = autoFinishTransactions; this.autoFinishTransactions = autoFinishTransactions;
PendingPurchasesParams pendingPurchasesParams = PendingPurchasesParams.newBuilder().enableOneTimeProducts().build(); billingClient = BillingClient.newBuilder(activity).setListener(this).enablePendingPurchases().build();
billingClient = BillingClient.newBuilder(activity).setListener(this).enablePendingPurchases(pendingPurchasesParams).build();
billingClient.startConnection(new BillingClientStateListener() { billingClient.startConnection(new BillingClientStateListener() {
@Override @Override
public void onBillingSetupFinished(BillingResult billingResult) { public void onBillingSetupFinished(BillingResult billingResult) {
@ -223,6 +221,7 @@ public class IapGooglePlay implements PurchasesUpdatedListener {
case BillingResponseCode.OK: case BillingResponseCode.OK:
defoldResponse = IapJNI.BILLING_RESPONSE_RESULT_OK; defoldResponse = IapJNI.BILLING_RESPONSE_RESULT_OK;
break; break;
case BillingResponseCode.SERVICE_TIMEOUT:
case BillingResponseCode.SERVICE_UNAVAILABLE: case BillingResponseCode.SERVICE_UNAVAILABLE:
case BillingResponseCode.SERVICE_DISCONNECTED: case BillingResponseCode.SERVICE_DISCONNECTED:
defoldResponse = IapJNI.BILLING_RESPONSE_RESULT_SERVICE_UNAVAILABLE; defoldResponse = IapJNI.BILLING_RESPONSE_RESULT_SERVICE_UNAVAILABLE;
@ -230,9 +229,6 @@ public class IapGooglePlay implements PurchasesUpdatedListener {
case BillingResponseCode.USER_CANCELED: case BillingResponseCode.USER_CANCELED:
defoldResponse = IapJNI.BILLING_RESPONSE_RESULT_USER_CANCELED; defoldResponse = IapJNI.BILLING_RESPONSE_RESULT_USER_CANCELED;
break; 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.FEATURE_NOT_SUPPORTED:
case BillingResponseCode.ERROR: case BillingResponseCode.ERROR:
default: default:

View File

@ -18,7 +18,6 @@ public class IapJNI implements IListProductsListener, IPurchaseListener {
public static final int BILLING_RESPONSE_RESULT_ERROR = 6; 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_ALREADY_OWNED = 7;
public static final int BILLING_RESPONSE_RESULT_ITEM_NOT_OWNED = 8; public static final int BILLING_RESPONSE_RESULT_ITEM_NOT_OWNED = 8;
public static final int BILLING_RESPONSE_RESULT_NETWORK_ERROR = 9;
public IapJNI() { public IapJNI() {
} }

View File

@ -11,8 +11,8 @@ height = 1136
[android] [android]
input_method = HiddenInputField input_method = HiddenInputField
package = com.defold.extension.iap package = com.defold.extension.iap
version_code = 9 version_code = 7
minimum_sdk_version = 21 target_sdk_version = 29
[project] [project]
title = extension-iap title = extension-iap

View File

@ -44,13 +44,7 @@ end
local function buy(id) local function buy(id)
log("iap.buy() " .. id) log("iap.buy() " .. id)
local options = {} iap.buy(id)
local item = available_items[id]
if item.subscriptions then
local subscription = item.subscriptions[1]
options.token = subscription.token
end
iap.buy(id, options)
end end
local function restore() local function restore()