Compare commits

...

15 Commits

Author SHA1 Message Date
Björn Ritzl
88028fd29f Update index.md 2025-06-04 07:54:03 +02:00
Björn Ritzl
c0e35039f4
Merge pull request #66 from defold/dev-update-to-android-billing-7-0-0
Update to Google Play Billing 7 0 0
2025-02-11 22:23:42 +01:00
Björn Ritzl
2e17b2f413 Merge branch 'master' into dev-update-to-android-billing-7-0-0 2025-02-11 13:58:34 +01:00
Björn Ritzl
f398677d7b
Merge pull request #68 from defold/dev-update-to-android-billing-6-0-1
Update to android billing 6.2.1
2024-07-04 15:18:13 +02:00
Björn Ritzl
d1c4e88562 Update build.gradle 2024-07-04 15:04:32 +02:00
Björn Ritzl
6f06d7f08f Updated to 6.0.1 2024-07-04 14:52:58 +02:00
Björn Ritzl
0852e42977 Update .gitignore 2024-07-04 14:36:12 +02:00
Björn Ritzl
33174f25ea Merge branch 'master' into dev-update-to-android-billing-7-0-0 2024-07-03 19:27:05 +02:00
Björn Ritzl
ba0e1b645a
Merge pull request #65 from defold/dev-update-to-android-billing-6-0-0
Updated to Play Billing 6.0.0
2024-07-03 19:26:34 +02:00
Björn Ritzl
801179288e Include the offer token when buying 2024-07-03 19:25:36 +02:00
Björn Ritzl
1c27130eef Updated to Billing 7.0.0 2024-07-03 19:06:50 +02:00
Björn Ritzl
195ef400b5 Play Billing 6.0.0 2024-07-02 22:33:09 +02:00
Alexey Gulev
68ef7f4615
Merge pull request #63 from ekharkunov/emscripten-update
Update js code according to new Emscripten version (3.1.55).
2024-04-10 11:08:22 +02:00
Kharkunov Eugene
1a34582603 Update js code according to new Emscripten version (3.1.55).
Update assets to latest Defold version.
Remove armv7-ios from manifest as unsupported platform.
2024-04-10 11:27:41 +03:00
Björn Ritzl
09f5060d44 Update index.md 2023-10-03 14:40:19 +02:00
11 changed files with 126 additions and 21 deletions

2
.gitignore vendored
View File

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

View File

@ -1,6 +1,6 @@
---
title: Defold In-app purchase extension API documentation
brief: This manual covers how to setup and use Google Play Game Services in Defold.
brief: This manual covers how to setup and use In-App Purchases in Defold.
---
# Defold In-app purchase extension API documentation
@ -234,6 +234,3 @@ On iOS, the "price_string" field contains '~' characters
## Source code
The source code is available on [GitHub](https://github.com/defold/extension-iap)
## API reference

View File

@ -1,10 +1,6 @@
name: IAPExt
platforms:
armv7-ios:
context:
weakFrameworks: ['StoreKit', 'UIKit', 'Foundation']
arm64-ios:
context:
weakFrameworks: ['StoreKit', 'UIKit', 'Foundation']

View File

@ -71,7 +71,7 @@ var LibraryFacebookIAP = {
if(url_index == product_count-1) {
var productsJSON = JSON.stringify(products);
var res_buf = allocate(intArrayFromString(productsJSON), 'i8', ALLOC_STACK);
var res_buf = stringToUTF8OnStack(productsJSON);
{{{ makeDynCall('vii', 'callback')}}}(lua_callback, res_buf);
} else {
var xmlhttp = new XMLHttpRequest();
@ -143,7 +143,7 @@ var LibraryFacebookIAP = {
}
var productsJSON = JSON.stringify(result)
var res_buf = allocate(intArrayFromString(productsJSON), 'i8', ALLOC_STACK);
var res_buf = stringToUTF8OnStack(productsJSON);
{{{ makeDynCall('viii', 'callback')}}}(lua_callback, res_buf, 0);
} else {
@ -166,4 +166,4 @@ var LibraryFacebookIAP = {
}
autoAddDeps(LibraryFacebookIAP, '$FBinner');
mergeInto(LibraryManager.library, LibraryFacebookIAP);
addToLibrary(LibraryFacebookIAP);

View File

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

View File

@ -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

View File

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

View File

@ -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() {
}

View File

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

View File

@ -1,7 +1,7 @@
script: "/main/main.gui_script"
fonts {
name: "system_font"
font: "/builtins/fonts/system_font.font"
name: "default"
font: "/builtins/fonts/default.font"
}
background_color {
x: 0.0
@ -47,6 +47,8 @@ nodes {
alpha: 1.0
template: "/dirtylarry/button.gui"
template_node_child: false
custom_type: 0
enabled: true
}
nodes {
position {
@ -102,6 +104,10 @@ nodes {
alpha: 1.0
template_node_child: true
size_mode: SIZE_MODE_MANUAL
custom_type: 0
enabled: true
visible: true
material: ""
}
nodes {
position {
@ -166,6 +172,10 @@ nodes {
template_node_child: true
text_leading: 1.0
text_tracking: 0.0
custom_type: 0
enabled: true
visible: true
material: ""
}
nodes {
position {
@ -205,6 +215,8 @@ nodes {
alpha: 1.0
template: "/dirtylarry/button.gui"
template_node_child: false
custom_type: 0
enabled: true
}
nodes {
position {
@ -261,6 +273,10 @@ nodes {
overridden_fields: 4
template_node_child: true
size_mode: SIZE_MODE_MANUAL
custom_type: 0
enabled: true
visible: true
material: ""
}
nodes {
position {
@ -325,6 +341,10 @@ nodes {
template_node_child: true
text_leading: 1.0
text_tracking: 0.0
custom_type: 0
enabled: true
visible: true
material: ""
}
nodes {
position {
@ -360,7 +380,7 @@ nodes {
type: TYPE_TEXT
blend_mode: BLEND_MODE_ALPHA
text: "<text>"
font: "system_font"
font: "default"
id: "log"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
@ -387,6 +407,10 @@ nodes {
template_node_child: false
text_leading: 1.0
text_tracking: 0.0
custom_type: 0
enabled: true
visible: true
material: ""
}
nodes {
position {
@ -426,6 +450,8 @@ nodes {
alpha: 1.0
template: "/dirtylarry/button.gui"
template_node_child: false
custom_type: 0
enabled: true
}
nodes {
position {
@ -481,6 +507,10 @@ nodes {
alpha: 1.0
template_node_child: true
size_mode: SIZE_MODE_MANUAL
custom_type: 0
enabled: true
visible: true
material: ""
}
nodes {
position {
@ -545,6 +575,10 @@ nodes {
template_node_child: true
text_leading: 1.0
text_tracking: 0.0
custom_type: 0
enabled: true
visible: true
material: ""
}
nodes {
position {
@ -584,6 +618,8 @@ nodes {
alpha: 1.0
template: "/dirtylarry/button.gui"
template_node_child: false
custom_type: 0
enabled: true
}
nodes {
position {
@ -639,6 +675,10 @@ nodes {
alpha: 1.0
template_node_child: true
size_mode: SIZE_MODE_MANUAL
custom_type: 0
enabled: true
visible: true
material: ""
}
nodes {
position {
@ -703,6 +743,10 @@ nodes {
template_node_child: true
text_leading: 1.0
text_tracking: 0.0
custom_type: 0
enabled: true
visible: true
material: ""
}
nodes {
position {
@ -742,6 +786,8 @@ nodes {
alpha: 1.0
template: "/dirtylarry/button.gui"
template_node_child: false
custom_type: 0
enabled: true
}
nodes {
position {
@ -798,6 +844,10 @@ nodes {
overridden_fields: 4
template_node_child: true
size_mode: SIZE_MODE_MANUAL
custom_type: 0
enabled: true
visible: true
material: ""
}
nodes {
position {
@ -862,6 +912,10 @@ nodes {
template_node_child: true
text_leading: 1.0
text_tracking: 0.0
custom_type: 0
enabled: true
visible: true
material: ""
}
nodes {
position {
@ -901,6 +955,8 @@ nodes {
alpha: 1.0
template: "/dirtylarry/button.gui"
template_node_child: false
custom_type: 0
enabled: true
}
nodes {
position {
@ -956,6 +1012,10 @@ nodes {
alpha: 1.0
template_node_child: true
size_mode: SIZE_MODE_MANUAL
custom_type: 0
enabled: true
visible: true
material: ""
}
nodes {
position {
@ -1020,6 +1080,10 @@ nodes {
template_node_child: true
text_leading: 1.0
text_tracking: 0.0
custom_type: 0
enabled: true
visible: true
material: ""
}
nodes {
position {
@ -1059,6 +1123,8 @@ nodes {
alpha: 1.0
template: "/dirtylarry/button.gui"
template_node_child: false
custom_type: 0
enabled: true
}
nodes {
position {
@ -1115,6 +1181,10 @@ nodes {
overridden_fields: 4
template_node_child: true
size_mode: SIZE_MODE_MANUAL
custom_type: 0
enabled: true
visible: true
material: ""
}
nodes {
position {
@ -1179,6 +1249,10 @@ nodes {
template_node_child: true
text_leading: 1.0
text_tracking: 0.0
custom_type: 0
enabled: true
visible: true
material: ""
}
nodes {
position {
@ -1218,6 +1292,8 @@ nodes {
alpha: 1.0
template: "/dirtylarry/checkbox_label.gui"
template_node_child: false
custom_type: 0
enabled: true
}
nodes {
position {
@ -1273,6 +1349,10 @@ nodes {
alpha: 1.0
template_node_child: true
size_mode: SIZE_MODE_MANUAL
custom_type: 0
enabled: true
visible: true
material: ""
}
nodes {
position {
@ -1337,6 +1417,10 @@ nodes {
template_node_child: true
text_leading: 1.0
text_tracking: 0.0
custom_type: 0
enabled: true
visible: true
material: ""
}
nodes {
position {
@ -1376,6 +1460,8 @@ nodes {
alpha: 1.0
template: "/dirtylarry/checkbox_label.gui"
template_node_child: false
custom_type: 0
enabled: true
}
nodes {
position {
@ -1431,6 +1517,10 @@ nodes {
alpha: 1.0
template_node_child: true
size_mode: SIZE_MODE_MANUAL
custom_type: 0
enabled: true
visible: true
material: ""
}
nodes {
position {
@ -1495,6 +1585,10 @@ nodes {
template_node_child: true
text_leading: 1.0
text_tracking: 0.0
custom_type: 0
enabled: true
visible: true
material: ""
}
material: "/builtins/materials/gui.material"
adjust_reference: ADJUST_REFERENCE_PARENT

View File

@ -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()