diff options
Diffstat (limited to 'platform/android')
4 files changed, 31 insertions, 11 deletions
diff --git a/platform/android/java/src/com/android/godot/payments/ConsumeTask.java b/platform/android/java/src/com/android/godot/payments/ConsumeTask.java index 62b33c002a..855bc0578d 100644 --- a/platform/android/java/src/com/android/godot/payments/ConsumeTask.java +++ b/platform/android/java/src/com/android/godot/payments/ConsumeTask.java @@ -56,7 +56,8 @@ abstract public class ConsumeTask { protected void onPostExecute(String param){ if(param == null){ - success(); + + success(new PaymentsCache(context).getConsumableValue("ticket", sku)); }else{ error(param); } @@ -65,7 +66,7 @@ abstract public class ConsumeTask { }.execute(); } - abstract protected void success(); + abstract protected void success(String ticket); abstract protected void error(String message); } diff --git a/platform/android/java/src/com/android/godot/payments/HandlePurchaseTask.java b/platform/android/java/src/com/android/godot/payments/HandlePurchaseTask.java index 531a786dc9..a32ecf2895 100644 --- a/platform/android/java/src/com/android/godot/payments/HandlePurchaseTask.java +++ b/platform/android/java/src/com/android/godot/payments/HandlePurchaseTask.java @@ -28,11 +28,12 @@ abstract public class HandlePurchaseTask { public void handlePurchaseRequest(int resultCode, Intent data){ -// Log.d("XXX", "Handling purchase response"); + Log.d("XXX", "Handling purchase response"); // int responseCode = data.getIntExtra("RESPONSE_CODE", 0); PaymentsCache pc = new PaymentsCache(context); String purchaseData = data.getStringExtra("INAPP_PURCHASE_DATA"); + Log.d("XXX", "Purchase data:" + purchaseData); // String dataSignature = data.getStringExtra("INAPP_DATA_SIGNATURE"); if (resultCode == Activity.RESULT_OK) { @@ -61,7 +62,7 @@ abstract public class HandlePurchaseTask { pc.setConsumableFlag("block", productId, true); pc.setConsumableValue("token", productId, purchaseToken); - success(purchaseData); + success(productId); return; } catch (JSONException e) { error(e.getMessage()); diff --git a/platform/android/java/src/com/android/godot/payments/PaymentsManager.java b/platform/android/java/src/com/android/godot/payments/PaymentsManager.java index 983f655c35..e8c487dbd8 100644 --- a/platform/android/java/src/com/android/godot/payments/PaymentsManager.java +++ b/platform/android/java/src/com/android/godot/payments/PaymentsManager.java @@ -84,8 +84,25 @@ public class PaymentsManager { new HandlePurchaseTask(activity){ @Override - protected void success(String ticket) { - godotPaymentV3.callbackSuccess(ticket); + protected void success(final String sku) { + new ConsumeTask(mService, activity) { + + @Override + protected void success(String ticket) { +// godotPaymentV3.callbackSuccess(""); + godotPaymentV3.callbackSuccess(ticket); + } + + @Override + protected void error(String message) { + godotPaymentV3.callbackFail(); + + } + }.consume(sku); + + + +// godotPaymentV3.callbackSuccess(ticket); //validatePurchase(purchaseToken, sku); } @@ -99,7 +116,8 @@ public class PaymentsManager { protected void canceled() { godotPaymentV3.callbackCancel(); - }}.handlePurchaseRequest(resultCode, data); + } + }.handlePurchaseRequest(resultCode, data); } public void validatePurchase(String purchaseToken, final String sku){ @@ -112,8 +130,8 @@ public class PaymentsManager { new ConsumeTask(mService, activity) { @Override - protected void success() { - godotPaymentV3.callbackSuccess(""); + protected void success(String ticket) { + godotPaymentV3.callbackSuccess(ticket); } diff --git a/platform/android/java/src/com/android/godot/payments/PurchaseTask.java b/platform/android/java/src/com/android/godot/payments/PurchaseTask.java index 3b2cb78d27..f5d8a0298a 100644 --- a/platform/android/java/src/com/android/godot/payments/PurchaseTask.java +++ b/platform/android/java/src/com/android/godot/payments/PurchaseTask.java @@ -32,7 +32,7 @@ abstract public class PurchaseTask { private boolean isLooping = false; public void purchase(final String sku){ -// Log.d("XXX", "Starting purchase"); + Log.d("XXX", "Starting purchase for: " + sku); PaymentsCache pc = new PaymentsCache(context); Boolean isBlocked = pc.getConsumableFlag("block", sku); // if(isBlocked){ @@ -68,7 +68,7 @@ abstract public class PurchaseTask { new ConsumeTask(mService, context) { @Override - protected void success() { + protected void success(String ticket) { // Log.d("XXX", "Product was erroniously purchased!"); if(isLooping){ // Log.d("XXX", "It is looping"); |