mirror of
https://github.com/godotengine/godot-demo-projects.git
synced 2025-12-16 13:30:07 +01:00
Merge pull request #504 from ricardoalcantara/mono_android_iap
Android IAP Response Code can now return null.
This commit is contained in:
@@ -116,7 +116,7 @@ func _on_QuerySkuDetailsButton_pressed():
|
||||
func _on_PurchaseButton_pressed():
|
||||
var response = payment.purchase(TEST_ITEM_SKU)
|
||||
if response.status != OK:
|
||||
show_alert("Purchase error %d: %s" % [response.response_code, response.debug_message])
|
||||
show_alert("Purchase error %s: %s" % [response.response_code, response.debug_message])
|
||||
|
||||
|
||||
func _on_ConsumeButton_pressed():
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace Android_Iap.GodotGooglePlayBilling
|
||||
try
|
||||
{
|
||||
Status = (int)billingResult["status"];
|
||||
ResponseCode = (billingResult.Contains("response_code") ? (BillingResponseCode)billingResult["response_code"] : BillingResponseCode.Ok);
|
||||
ResponseCode = (billingResult.Contains("response_code") ? (BillingResponseCode?)billingResult["response_code"] : null);
|
||||
DebugMessage = (billingResult.Contains("debug_message") ? (string)billingResult["debug_message"] : null);
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
@@ -61,7 +61,7 @@ namespace Android_Iap.GodotGooglePlayBilling
|
||||
}
|
||||
|
||||
public int Status { get; set; }
|
||||
public BillingResponseCode ResponseCode { get; set; }
|
||||
public BillingResponseCode? ResponseCode { get; set; }
|
||||
public string DebugMessage { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,11 +99,11 @@ namespace Android_Iap
|
||||
var result = _googlePlayBilling.Purchase("android.test.purchased");
|
||||
if (result != null && result.Status == (int)Error.Ok)
|
||||
{
|
||||
GD.Print("Bought");
|
||||
GD.Print("Purchase Requested");
|
||||
}
|
||||
else
|
||||
{
|
||||
GD.Print("Failed");
|
||||
GD.Print($"Purchase Failed {result.ResponseCode} {result.DebugMessage}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,11 +112,11 @@ namespace Android_Iap
|
||||
var result = _googlePlayBilling.Purchase("android.test.canceled");
|
||||
if (result != null && result.Status == (int)Error.Ok)
|
||||
{
|
||||
GD.Print("Bought");
|
||||
GD.Print("Purchase Requested");
|
||||
}
|
||||
else
|
||||
{
|
||||
GD.Print("Failed");
|
||||
GD.Print($"Purchase Failed {result.ResponseCode} {result.DebugMessage}");
|
||||
}
|
||||
}
|
||||
private void OnButton2_pressed()
|
||||
@@ -124,11 +124,11 @@ namespace Android_Iap
|
||||
var result = _googlePlayBilling.Purchase("android.test.refunded");
|
||||
if (result != null && result.Status == (int)Error.Ok)
|
||||
{
|
||||
GD.Print("Bought");
|
||||
GD.Print("Purchase Requested");
|
||||
}
|
||||
else
|
||||
{
|
||||
GD.Print("Failed");
|
||||
GD.Print($"Purchase Failed {result.ResponseCode} {result.DebugMessage}");
|
||||
}
|
||||
}
|
||||
private void OnButton3_pressed()
|
||||
@@ -136,11 +136,11 @@ namespace Android_Iap
|
||||
var result = _googlePlayBilling.Purchase("android.test.item_unavailable");
|
||||
if (result != null && result.Status == (int)Error.Ok)
|
||||
{
|
||||
GD.Print("Bought");
|
||||
GD.Print("Purchase Requested");
|
||||
}
|
||||
else
|
||||
{
|
||||
GD.Print("Failed");
|
||||
GD.Print($"Purchase Failed {result.ResponseCode} {result.DebugMessage}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user