Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix updated Android IAP project in c# #1105

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion mono/android_iap/Android in-app purchases with C#.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<Project Sdk="Godot.NET.Sdk/4.3.0">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>AndroidIAP</RootNamespace>
<TargetFramework Condition=" '$(GodotTargetPlatform)' == 'android' ">net7.0</TargetFramework>
<TargetFramework Condition=" '$(GodotTargetPlatform)' == 'ios' ">net8.0</TargetFramework>
<EnableDynamicLoading>true</EnableDynamicLoading>
<RootNamespace>AndroidinapppurchaseswithC</RootNamespace>
</PropertyGroup>
</Project>
14 changes: 7 additions & 7 deletions mono/android_iap/Android in-app purchases with C#.sln
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Android in-app purchases with C#", "Android in-app purchases with C#.csproj", "{480953C3-B1FD-42F6-8A07-51A3F69024D7}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Android in-app purchases with C#", "Android in-app purchases with C#.csproj", "{A29FB611-2B09-4E62-B23E-A68BAF8A8A3F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -9,11 +9,11 @@ Global
ExportRelease|Any CPU = ExportRelease|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{480953C3-B1FD-42F6-8A07-51A3F69024D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{480953C3-B1FD-42F6-8A07-51A3F69024D7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{480953C3-B1FD-42F6-8A07-51A3F69024D7}.ExportDebug|Any CPU.ActiveCfg = ExportDebug|Any CPU
{480953C3-B1FD-42F6-8A07-51A3F69024D7}.ExportDebug|Any CPU.Build.0 = ExportDebug|Any CPU
{480953C3-B1FD-42F6-8A07-51A3F69024D7}.ExportRelease|Any CPU.ActiveCfg = ExportRelease|Any CPU
{480953C3-B1FD-42F6-8A07-51A3F69024D7}.ExportRelease|Any CPU.Build.0 = ExportRelease|Any CPU
{A29FB611-2B09-4E62-B23E-A68BAF8A8A3F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A29FB611-2B09-4E62-B23E-A68BAF8A8A3F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A29FB611-2B09-4E62-B23E-A68BAF8A8A3F}.ExportDebug|Any CPU.ActiveCfg = ExportDebug|Any CPU
{A29FB611-2B09-4E62-B23E-A68BAF8A8A3F}.ExportDebug|Any CPU.Build.0 = ExportDebug|Any CPU
{A29FB611-2B09-4E62-B23E-A68BAF8A8A3F}.ExportRelease|Any CPU.ActiveCfg = ExportRelease|Any CPU
{A29FB611-2B09-4E62-B23E-A68BAF8A8A3F}.ExportRelease|Any CPU.Build.0 = ExportRelease|Any CPU
EndGlobalSection
EndGlobal
44 changes: 22 additions & 22 deletions mono/android_iap/GodotGooglePlayBilling/GooglePlayBilling.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,17 @@ public override void _Ready()
_payment = Engine.GetSingleton("GodotGooglePlayBilling");
// These are all signals supported by the API
// You can drop some of these based on your needs
_payment.Connect(SignalName.Connected, Callable.From(OnGodotGooglePlayBilling_connected)); // No params
JavierStark marked this conversation as resolved.
Show resolved Hide resolved
_payment.Connect(SignalName.Disconnected, Callable.From(OnGodotGooglePlayBilling_disconnected)); // No params
_payment.Connect(SignalName.ConnectError, Callable.From<int, string>(OnGodotGooglePlayBilling_connect_error)); // Response ID (int), Debug message (string)
_payment.Connect(SignalName.SkuDetailsQueryCompleted, Callable.From<Array>(OnGodotGooglePlayBilling_sku_details_query_completed)); // SKUs (Array of Dictionary)
_payment.Connect(SignalName.SkuDetailsQueryError, Callable.From<int,string,string[]>(OnGodotGooglePlayBilling_sku_details_query_error)); // Response ID (int), Debug message (string), Queried SKUs (string[])
_payment.Connect(SignalName.PurchasesUpdated, Callable.From<Array>(OnGodotGooglePlayBilling_purchases_updated)); // Purchases (Array of Dictionary)
_payment.Connect(SignalName.PurchaseError, Callable.From<int,string>(OnGodotGooglePlayBilling_purchase_error)); // Response ID (int), Debug message (string)
_payment.Connect(SignalName.PurchaseAcknowledged, Callable.From<string>(OnGodotGooglePlayBilling_purchase_acknowledged)); // Purchase token (string)
_payment.Connect(SignalName.PurchaseAcknowledgementError, Callable.From<int,string>(OnGodotGooglePlayBilling_purchase_acknowledgement_error)); // Response ID (int), Debug message (string), Purchase token (string)
_payment.Connect(SignalName.PurchaseConsumed, Callable.From<string>(OnGodotGooglePlayBilling_purchase_consumed)); // Purchase token (string)
_payment.Connect(SignalName.PurchaseConsumptionError, Callable.From<int,string,string>(OnGodotGooglePlayBilling_purchase_consumption_error)); // Response ID (int), Debug message (string), Purchase token (string)
_payment.Connect("connected", Callable.From(OnGodotGooglePlayBilling_connected)); // No params
_payment.Connect("disconnected", Callable.From(OnGodotGooglePlayBilling_disconnected)); // No params
_payment.Connect("connect_error", Callable.From<int, string>(OnGodotGooglePlayBilling_connect_error)); // Response ID (int), Debug message (string)
_payment.Connect("sku_details_query_completed", Callable.From<Array>(OnGodotGooglePlayBilling_sku_details_query_completed)); // SKUs (Array of Dictionary)
_payment.Connect("sku_details_query_error", Callable.From<int,string,string[]>(OnGodotGooglePlayBilling_sku_details_query_error)); // Response ID (int), Debug message (string), Queried SKUs (string[])
_payment.Connect("purchases_updated", Callable.From<Array>(OnGodotGooglePlayBilling_purchases_updated)); // Purchases (Array of Dictionary)
_payment.Connect("purchase_error", Callable.From<int,string>(OnGodotGooglePlayBilling_purchase_error)); // Response ID (int), Debug message (string)
_payment.Connect("purchase_acknowledged", Callable.From<string>(OnGodotGooglePlayBilling_purchase_acknowledged)); // Purchase token (string)
_payment.Connect("purchase_acknowledgement_error", Callable.From<int,string>(OnGodotGooglePlayBilling_purchase_acknowledgement_error)); // Response ID (int), Debug message (string), Purchase token (string)
_payment.Connect("purchase_consumed", Callable.From<string>(OnGodotGooglePlayBilling_purchase_consumed)); // Purchase token (string)
_payment.Connect("purchase_consumption_error", Callable.From<int,string,string>(OnGodotGooglePlayBilling_purchase_consumption_error)); // Response ID (int), Debug message (string), Purchase token (string)
}
else
{
Expand Down Expand Up @@ -88,27 +88,27 @@ public PurchasesResult QueryPurchases(PurchaseType purchaseType)

#region GodotGooglePlayBilling Signals

private void OnGodotGooglePlayBilling_connected() => EmitSignal(nameof(Connected));
private void OnGodotGooglePlayBilling_connected() => EmitSignal(SignalName.Connected);

private void OnGodotGooglePlayBilling_disconnected() => EmitSignal(nameof(Disconnected));
private void OnGodotGooglePlayBilling_disconnected() => EmitSignal(SignalName.Disconnected);

private void OnGodotGooglePlayBilling_connect_error(int code, string message) => EmitSignal(nameof(ConnectError), code, message);
private void OnGodotGooglePlayBilling_connect_error(int code, string message) => EmitSignal(SignalName.ConnectError, code, message);

private void OnGodotGooglePlayBilling_sku_details_query_completed(Array skuDetails) => EmitSignal(nameof(SkuDetailsQueryCompleted), skuDetails);
private void OnGodotGooglePlayBilling_sku_details_query_completed(Array skuDetails) => EmitSignal(SignalName.SkuDetailsQueryCompleted, skuDetails);

private void OnGodotGooglePlayBilling_sku_details_query_error(int code, string message, string[] querySkuDetails) => EmitSignal(nameof(SkuDetailsQueryError), code, message, querySkuDetails);
private void OnGodotGooglePlayBilling_sku_details_query_error(int code, string message, string[] querySkuDetails) => EmitSignal(SignalName.SkuDetailsQueryError, code, message, querySkuDetails);

private void OnGodotGooglePlayBilling_purchases_updated(Array purchases) => EmitSignal(nameof(PurchasesUpdated), purchases);
private void OnGodotGooglePlayBilling_purchases_updated(Array purchases) => EmitSignal(SignalName.PurchasesUpdated, purchases);

private void OnGodotGooglePlayBilling_purchase_error(int code, string message) => EmitSignal(nameof(PurchaseError), code, message);
private void OnGodotGooglePlayBilling_purchase_error(int code, string message) => EmitSignal(SignalName.PurchaseError, code, message);

private void OnGodotGooglePlayBilling_purchase_acknowledged(string purchaseToken) => EmitSignal(nameof(PurchaseAcknowledged), purchaseToken);
private void OnGodotGooglePlayBilling_purchase_acknowledged(string purchaseToken) => EmitSignal(SignalName.PurchaseAcknowledged, purchaseToken);

private void OnGodotGooglePlayBilling_purchase_acknowledgement_error(int code, string message) => EmitSignal(nameof(PurchaseAcknowledgementError), code, message);
private void OnGodotGooglePlayBilling_purchase_acknowledgement_error(int code, string message) => EmitSignal(SignalName.PurchaseAcknowledgementError, code, message);

private void OnGodotGooglePlayBilling_purchase_consumed(string purchaseToken) => EmitSignal(nameof(PurchaseConsumed), purchaseToken);
private void OnGodotGooglePlayBilling_purchase_consumed(string purchaseToken) => EmitSignal(SignalName.Connected, purchaseToken);

private void OnGodotGooglePlayBilling_purchase_consumption_error(int code, string message, string purchaseToken) => EmitSignal(nameof(PurchaseConsumptionError), code, message, purchaseToken);
private void OnGodotGooglePlayBilling_purchase_consumption_error(int code, string message, string purchaseToken) => EmitSignal(SignalName.PurchaseConsumptionError, code, message, purchaseToken);

#endregion
}
Expand Down
1 change: 1 addition & 0 deletions mono/android_iap/android/.build_version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4.3.stable.mono
Binary file not shown.
8 changes: 8 additions & 0 deletions mono/android_iap/android/plugins/GodotGooglePlayBilling.gdap
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[config]

name="GodotGooglePlayBilling"
binary_type="local"
binary="GodotGooglePlayBilling.1.2.0.release.aar"

[dependencies]
remote=["com.android.billingclient:billing:5.2.1"]
10 changes: 5 additions & 5 deletions mono/android_iap/main.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=3 format=3 uid="uid://ckuhu5rgquv8h"]
[gd_scene load_steps=3 format=3 uid="uid://dx43bqbhvi3am"]

[ext_resource type="Script" path="res://Main.cs" id="1"]
[ext_resource type="Script" path="res://GodotGooglePlayBilling/GooglePlayBilling.cs" id="2"]
Expand All @@ -25,10 +25,10 @@ dialog_autowrap = true

[node name="Label" type="Label" parent="."]
layout_mode = 0
offset_left = 300.0
offset_top = 40.0
offset_right = 996.0
offset_bottom = 156.0
offset_left = 242.711
offset_top = 39.0
offset_right = 1083.71
offset_bottom = 297.0
size_flags_horizontal = 2
size_flags_vertical = 0
text = "To test in-app purchase on android device,
Expand Down
5 changes: 3 additions & 2 deletions mono/android_iap/project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ config/description="This demo shows how to make in-app payments in Android in C#
Note: Running the demo requires exporting and uploading the game to Google Play."
config/tags=PackedStringArray("demo", "mobile", "official", "porting")
run/main_scene="res://main.tscn"
config/features=PackedStringArray("4.3", "C#")
config/icon="res://icon.webp"
config/features=PackedStringArray("4.3", "C#", "Mobile")
config/icon="res://icon.svg"

[display]

Expand All @@ -32,3 +32,4 @@ project/assembly_name="Android in-app purchases with C#"

renderer/rendering_method="gl_compatibility"
renderer/rendering_method.mobile="gl_compatibility"
textures/vram_compression/import_etc2_astc=true