From 3c41d7de232ce92a7ecd637c24be19c0bd5f6802 Mon Sep 17 00:00:00 2001 From: uerceg Date: Thu, 23 May 2024 00:10:26 +0200 Subject: [PATCH 1/5] feat: add verify and track feature --- .../java/com/adjust/sdk/ActivityHandler.java | 79 ++++++++++++++ .../src/main/java/com/adjust/sdk/Adjust.java | 11 ++ .../java/com/adjust/sdk/AdjustInstance.java | 20 ++++ .../java/com/adjust/sdk/IActivityHandler.java | 2 + .../java/com/adjust/sdk/PackageBuilder.java | 101 ++++++++++++++++++ 5 files changed, 213 insertions(+) diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/ActivityHandler.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/ActivityHandler.java index 9b78a73fe..efa776e52 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/ActivityHandler.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/ActivityHandler.java @@ -814,6 +814,16 @@ public void run() { }); } + @Override + public void verifyAndTrack(AdjustEvent event, OnPurchaseVerificationFinishedListener callback) { + executor.submit(new Runnable() { + @Override + public void run() { + verifyAndTrackI(event, callback); + } + }); + } + @Override public void setCoppaCompliance(final boolean enabled) { executor.submit(new Runnable() { @@ -2563,6 +2573,75 @@ private void verifyPurchaseI(final AdjustPurchase purchase, final OnPurchaseVeri purchaseVerificationHandler.sendPurchaseVerificationPackage(verificationPackage); } + private void verifyAndTrackI(final AdjustEvent event, final OnPurchaseVerificationFinishedListener callback) { + if (callback == null) { + logger.warn("Purchase verification aborted because verification callback is null"); + return; + } + // from this moment on we know that we can ping client callback in case of error + if (adjustConfig.urlStrategy != null && + (adjustConfig.urlStrategy.equals(AdjustConfig.DATA_RESIDENCY_EU) || + adjustConfig.urlStrategy.equals(AdjustConfig.DATA_RESIDENCY_US) || + adjustConfig.urlStrategy.equals(AdjustConfig.DATA_RESIDENCY_TR))) { + logger.warn("Purchase verification not available for data residency users right now"); + return; + } + if (!checkActivityStateI(activityState)) { + AdjustPurchaseVerificationResult result = new AdjustPurchaseVerificationResult( + "not_verified", + 102, + "Purchase verification aborted because SDK is still not initialized"); + callback.onVerificationFinished(result); + logger.warn("Purchase verification aborted because SDK is still not initialized"); + return; + } + if (!isEnabledI()) { + AdjustPurchaseVerificationResult result = new AdjustPurchaseVerificationResult( + "not_verified", + 103, + "Purchase verification aborted because SDK is disabled"); + callback.onVerificationFinished(result); + logger.warn("Purchase verification aborted because SDK is disabled"); + return; + } + if (activityState.isGdprForgotten) { + AdjustPurchaseVerificationResult result = new AdjustPurchaseVerificationResult( + "not_verified", + 104, + "Purchase verification aborted because user is GDPR forgotten"); + callback.onVerificationFinished(result); + logger.warn("Purchase verification aborted because user is GDPR forgotten"); + return; + } + if (event == null) { + logger.warn("Purchase verification aborted because event instance is null"); + AdjustPurchaseVerificationResult verificationResult = + new AdjustPurchaseVerificationResult( + "not_verified", + 106, + "Purchase verification aborted because event instance is null"); + callback.onVerificationFinished(verificationResult); + return; + } + + long now = System.currentTimeMillis(); + PackageBuilder packageBuilder = new PackageBuilder(adjustConfig, deviceInfo, activityState, globalParameters, now); + ActivityPackage verificationPackage = packageBuilder.buildVerificationPackage(event, callback); + if (verificationPackage == null) { + logger.warn("Purchase verification aborted because verification package is null"); + AdjustPurchaseVerificationResult verificationResult = + new AdjustPurchaseVerificationResult( + "not_verified", + 107, + "Purchase verification aborted because verification package is null"); + callback.onVerificationFinished(verificationResult); + return; + } + purchaseVerificationHandler.sendPurchaseVerificationPackage(verificationPackage); + // TODO: TBD if this is the right timing + trackEventI(event); + } + private void setCoppaComplianceI(final boolean coppaEnabled) { if (activityState == null) { return; } if (!isEnabledI()) { return; } diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/Adjust.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/Adjust.java index 3ba3cc994..e0fee1cc1 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/Adjust.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/Adjust.java @@ -440,6 +440,17 @@ public static void verifyPurchase(final AdjustPurchase purchase, final OnPurchas adjustInstance.verifyPurchase(purchase, callback); } + /** + * Verify in app purchase from Google Play and track Adjust event associated with it. + * + * @param event AdjustEvent object to be tracked + * @param callback Callback to obtain verification results + */ + public static void verifyAndTrack(final AdjustEvent event, OnPurchaseVerificationFinishedListener callback) { + AdjustInstance adjustInstance = Adjust.getDefaultInstance(); + adjustInstance.verifyAndTrack(event, callback); + } + /** * Used for testing purposes only. Do NOT use this method. * diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustInstance.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustInstance.java index 989107aac..784741261 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustInstance.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustInstance.java @@ -783,6 +783,26 @@ public void verifyPurchase(final AdjustPurchase purchase, final OnPurchaseVerifi activityHandler.verifyPurchase(purchase, callback); } + /** + * Verify in app purchase from Google Play and track Adjust event associated with it. + * + * @param event AdjustEvent to be tracked + * @param callback Callback to be pinged with the verification results + */ + public void verifyAndTrack(AdjustEvent event, OnPurchaseVerificationFinishedListener callback) { + if (!checkActivityHandler("verifyAndTrack")) { + if (callback != null) { + AdjustPurchaseVerificationResult result = new AdjustPurchaseVerificationResult( + "not_verified", + 100, + "SDK needs to be initialized before making purchase verification request"); + callback.onVerificationFinished(result); + } + return; + } + activityHandler.verifyAndTrack(event, callback); + } + /** * Used for testing purposes only. Do NOT use this method. * diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/IActivityHandler.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/IActivityHandler.java index d5cc376b4..861f15beb 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/IActivityHandler.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/IActivityHandler.java @@ -76,6 +76,8 @@ public interface IActivityHandler { void verifyPurchase(AdjustPurchase purchase, OnPurchaseVerificationFinishedListener callback); + void verifyAndTrack(AdjustEvent event, OnPurchaseVerificationFinishedListener callback); + void setCoppaCompliance(boolean enabled); void gotOptOutResponse(); diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/PackageBuilder.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/PackageBuilder.java index 5074c23c2..746a1bf8c 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/PackageBuilder.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/PackageBuilder.java @@ -220,6 +220,17 @@ ActivityPackage buildVerificationPackage(AdjustPurchase purchase, OnPurchaseVeri return purchaseVerificationPackage; } + ActivityPackage buildVerificationPackage(AdjustEvent event, OnPurchaseVerificationFinishedListener callback) { + Map parameters = getVerificationParameters(event); + ActivityPackage purchaseVerificationPackage = getDefaultActivityPackage(ActivityKind.PURCHASE_VERIFICATION); + purchaseVerificationPackage.setPath("/verify"); + purchaseVerificationPackage.setSuffix(""); + purchaseVerificationPackage.setPurchaseVerificationCallback(callback); + + purchaseVerificationPackage.setParameters(parameters); + return purchaseVerificationPackage; + } + private Map getSessionParameters() { Map parameters = new HashMap(); @@ -1140,6 +1151,96 @@ private Map getVerificationParameters(AdjustPurchase purchase) { return parameters; } + private Map getVerificationParameters(AdjustEvent event) { + Map parameters = new HashMap(); + + deviceInfo.reloadOtherDeviceInfoParams(adjustConfig, coppaEnabled, logger); + + // Check if plugin is used and if yes, add read parameters. + if (deviceInfo.imeiParameters != null) { + parameters.putAll(deviceInfo.imeiParameters); + } + + // Check if oaid plugin is used and if yes, add the parameter + if (deviceInfo.oaidParameters != null) { + parameters.putAll(deviceInfo.oaidParameters); + } + + // Device identifiers. + deviceInfo.reloadPlayIds(adjustConfig, coppaEnabled, playStoreKidsAppEnabled); + PackageBuilder.addString(parameters, "android_uuid", activityStateCopy.uuid); + PackageBuilder.addString(parameters, "gps_adid", deviceInfo.playAdId); + PackageBuilder.addLong(parameters, "gps_adid_attempt", deviceInfo.playAdIdAttempt); + PackageBuilder.addString(parameters, "gps_adid_src", deviceInfo.playAdIdSource); + PackageBuilder.addBoolean(parameters, "tracking_enabled", deviceInfo.isTrackingEnabled); + PackageBuilder.addString(parameters, "fire_adid", deviceInfo.fireAdId); + PackageBuilder.addBoolean(parameters, "fire_tracking_enabled", deviceInfo.fireTrackingEnabled); + + if (!containsPlayIds(parameters) && !containsFireIds(parameters)) { + logger.warn("Google Advertising ID or Fire Advertising ID not detected, " + + "fallback to non Google Play and Fire identifiers will take place"); + deviceInfo.reloadNonPlayIds(adjustConfig, coppaEnabled, playStoreKidsAppEnabled); + PackageBuilder.addString(parameters, "android_id", deviceInfo.androidId); + } + + // Rest of the parameters. + PackageBuilder.addString(parameters, "api_level", deviceInfo.apiLevel); + PackageBuilder.addString(parameters, "app_token", adjustConfig.appToken); + PackageBuilder.addString(parameters, "app_version", deviceInfo.appVersion); + PackageBuilder.addBoolean(parameters, "attribution_deeplink", true); + PackageBuilder.addLong(parameters, "connectivity_type", deviceInfo.connectivityType); + PackageBuilder.addString(parameters, "country", deviceInfo.country); + PackageBuilder.addString(parameters, "cpu_type", deviceInfo.abi); + PackageBuilder.addDateInMilliseconds(parameters, "created_at", createdAt); + PackageBuilder.addString(parameters, "default_tracker", adjustConfig.defaultTracker); + PackageBuilder.addBoolean(parameters, "needs_cost", adjustConfig.needsCost); + PackageBuilder.addString(parameters, "device_manufacturer", deviceInfo.deviceManufacturer); + PackageBuilder.addString(parameters, "device_name", deviceInfo.deviceName); + PackageBuilder.addString(parameters, "device_type", deviceInfo.deviceType); + PackageBuilder.addLong(parameters, "ui_mode", deviceInfo.uiMode); + PackageBuilder.addString(parameters, "display_height", deviceInfo.displayHeight); + PackageBuilder.addString(parameters, "display_width", deviceInfo.displayWidth); + PackageBuilder.addString(parameters, "environment", adjustConfig.environment); + PackageBuilder.addBoolean(parameters, "event_buffering_enabled", adjustConfig.eventBufferingEnabled); + PackageBuilder.addString(parameters, "external_device_id", adjustConfig.externalDeviceId); + PackageBuilder.addString(parameters, "fb_id", deviceInfo.fbAttributionId); + PackageBuilder.addString(parameters, "hardware_name", deviceInfo.hardwareName); + PackageBuilder.addString(parameters, "installed_at", deviceInfo.appInstallTime); + PackageBuilder.addString(parameters, "language", deviceInfo.language); + PackageBuilder.addDuration(parameters, "last_interval", activityStateCopy.lastInterval); + PackageBuilder.addString(parameters, "mcc", deviceInfo.mcc); + PackageBuilder.addString(parameters, "mnc", deviceInfo.mnc); + PackageBuilder.addBoolean(parameters, "needs_response_details", true); + PackageBuilder.addString(parameters, "os_build", deviceInfo.buildName); + PackageBuilder.addString(parameters, "os_name", deviceInfo.osName); + PackageBuilder.addString(parameters, "os_version", deviceInfo.osVersion); + PackageBuilder.addString(parameters, "package_name", deviceInfo.packageName); + PackageBuilder.addString(parameters, "push_token", activityStateCopy.pushToken); + PackageBuilder.addString(parameters, "screen_density", deviceInfo.screenDensity); + PackageBuilder.addString(parameters, "screen_format", deviceInfo.screenFormat); + PackageBuilder.addString(parameters, "screen_size", deviceInfo.screenSize); + PackageBuilder.addLong(parameters, "session_count", activityStateCopy.sessionCount); + PackageBuilder.addDuration(parameters, "session_length", activityStateCopy.sessionLength); + PackageBuilder.addLong(parameters, "subsession_count", activityStateCopy.subsessionCount); + PackageBuilder.addDuration(parameters, "time_spent", activityStateCopy.timeSpent); + PackageBuilder.addString(parameters, "updated_at", deviceInfo.appUpdateTime); + + // purchase verification specific parameters + PackageBuilder.addString(parameters, "product_id", event.getProductId()); + PackageBuilder.addString(parameters, "purchase_token", event.getPurchaseToken()); + PackageBuilder.addString(parameters, "event_token", event.getEventToken()); + PackageBuilder.addString(parameters, "currency", event.getCurrency()); + PackageBuilder.addDouble(parameters, "revenue", event.getRevenue()); + + // google play games + PackageBuilder.addBoolean(parameters, "gpg_pc_enabled", deviceInfo.isGooglePlayGamesForPC ? true : null); + + injectFeatureFlagsWithParameters(parameters); + + checkDeviceIds(parameters); + return parameters; + } + private ActivityPackage getDefaultActivityPackage(ActivityKind activityKind) { ActivityPackage activityPackage = new ActivityPackage(activityKind); activityPackage.setClientSdk(deviceInfo.clientSdk); From f8545c3f672e30d22976b86b7971ac90e1b5f8ee Mon Sep 17 00:00:00 2001 From: uerceg Date: Thu, 30 May 2024 17:18:58 +0200 Subject: [PATCH 2/5] refac: rename verifyAndTrack to verifyAndTrackPlayStorePurchase --- .../main/java/com/adjust/sdk/ActivityHandler.java | 12 +++++------- .../src/main/java/com/adjust/sdk/Adjust.java | 4 ++-- .../src/main/java/com/adjust/sdk/AdjustInstance.java | 4 ++-- .../main/java/com/adjust/sdk/IActivityHandler.java | 2 +- .../src/main/java/com/adjust/sdk/PackageBuilder.java | 1 - 5 files changed, 10 insertions(+), 13 deletions(-) diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/ActivityHandler.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/ActivityHandler.java index efa776e52..c0cb7a235 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/ActivityHandler.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/ActivityHandler.java @@ -815,11 +815,11 @@ public void run() { } @Override - public void verifyAndTrack(AdjustEvent event, OnPurchaseVerificationFinishedListener callback) { + public void verifyAndTrackPlayStorePurchase(AdjustEvent event, OnPurchaseVerificationFinishedListener callback) { executor.submit(new Runnable() { @Override public void run() { - verifyAndTrackI(event, callback); + verifyAndTrackPlayStorePurchaseI(event, callback); } }); } @@ -2573,16 +2573,14 @@ private void verifyPurchaseI(final AdjustPurchase purchase, final OnPurchaseVeri purchaseVerificationHandler.sendPurchaseVerificationPackage(verificationPackage); } - private void verifyAndTrackI(final AdjustEvent event, final OnPurchaseVerificationFinishedListener callback) { + private void verifyAndTrackPlayStorePurchaseI(final AdjustEvent event, + final OnPurchaseVerificationFinishedListener callback) { if (callback == null) { logger.warn("Purchase verification aborted because verification callback is null"); return; } // from this moment on we know that we can ping client callback in case of error - if (adjustConfig.urlStrategy != null && - (adjustConfig.urlStrategy.equals(AdjustConfig.DATA_RESIDENCY_EU) || - adjustConfig.urlStrategy.equals(AdjustConfig.DATA_RESIDENCY_US) || - adjustConfig.urlStrategy.equals(AdjustConfig.DATA_RESIDENCY_TR))) { + if (adjustConfig.isDataResidency) { logger.warn("Purchase verification not available for data residency users right now"); return; } diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/Adjust.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/Adjust.java index e0fee1cc1..3a4eea7e1 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/Adjust.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/Adjust.java @@ -446,9 +446,9 @@ public static void verifyPurchase(final AdjustPurchase purchase, final OnPurchas * @param event AdjustEvent object to be tracked * @param callback Callback to obtain verification results */ - public static void verifyAndTrack(final AdjustEvent event, OnPurchaseVerificationFinishedListener callback) { + public static void verifyAndTrackPlayStorePurchase(final AdjustEvent event, OnPurchaseVerificationFinishedListener callback) { AdjustInstance adjustInstance = Adjust.getDefaultInstance(); - adjustInstance.verifyAndTrack(event, callback); + adjustInstance.verifyAndTrackPlayStorePurchase(event, callback); } /** diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustInstance.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustInstance.java index 784741261..37d212d3b 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustInstance.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustInstance.java @@ -789,7 +789,7 @@ public void verifyPurchase(final AdjustPurchase purchase, final OnPurchaseVerifi * @param event AdjustEvent to be tracked * @param callback Callback to be pinged with the verification results */ - public void verifyAndTrack(AdjustEvent event, OnPurchaseVerificationFinishedListener callback) { + public void verifyAndTrackPlayStorePurchase(AdjustEvent event, OnPurchaseVerificationFinishedListener callback) { if (!checkActivityHandler("verifyAndTrack")) { if (callback != null) { AdjustPurchaseVerificationResult result = new AdjustPurchaseVerificationResult( @@ -800,7 +800,7 @@ public void verifyAndTrack(AdjustEvent event, OnPurchaseVerificationFinishedList } return; } - activityHandler.verifyAndTrack(event, callback); + activityHandler.verifyAndTrackPlayStorePurchase(event, callback); } /** diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/IActivityHandler.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/IActivityHandler.java index 861f15beb..1fca05e26 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/IActivityHandler.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/IActivityHandler.java @@ -76,7 +76,7 @@ public interface IActivityHandler { void verifyPurchase(AdjustPurchase purchase, OnPurchaseVerificationFinishedListener callback); - void verifyAndTrack(AdjustEvent event, OnPurchaseVerificationFinishedListener callback); + void verifyAndTrackPlayStorePurchase(AdjustEvent event, OnPurchaseVerificationFinishedListener callback); void setCoppaCompliance(boolean enabled); diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/PackageBuilder.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/PackageBuilder.java index 746a1bf8c..b2291c26d 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/PackageBuilder.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/PackageBuilder.java @@ -1201,7 +1201,6 @@ private Map getVerificationParameters(AdjustEvent event) { PackageBuilder.addString(parameters, "display_height", deviceInfo.displayHeight); PackageBuilder.addString(parameters, "display_width", deviceInfo.displayWidth); PackageBuilder.addString(parameters, "environment", adjustConfig.environment); - PackageBuilder.addBoolean(parameters, "event_buffering_enabled", adjustConfig.eventBufferingEnabled); PackageBuilder.addString(parameters, "external_device_id", adjustConfig.externalDeviceId); PackageBuilder.addString(parameters, "fb_id", deviceInfo.fbAttributionId); PackageBuilder.addString(parameters, "hardware_name", deviceInfo.hardwareName); From c93925e97c49b863954d8f91f9b712ff5c7d3be7 Mon Sep 17 00:00:00 2001 From: uerceg Date: Thu, 30 May 2024 17:22:03 +0200 Subject: [PATCH 3/5] refac: rename verifyPurchase to verifyPlayStorePurchase --- .../main/java/com/adjust/sdk/ActivityHandler.java | 12 +++++++++--- .../src/main/java/com/adjust/sdk/Adjust.java | 5 +++-- .../src/main/java/com/adjust/sdk/AdjustInstance.java | 5 +++-- .../main/java/com/adjust/sdk/IActivityHandler.java | 2 +- .../com/adjust/testapp/AdjustCommandExecutor.java | 2 +- 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/ActivityHandler.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/ActivityHandler.java index c0cb7a235..933ddfdb5 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/ActivityHandler.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/ActivityHandler.java @@ -805,11 +805,11 @@ public void run() { } @Override - public void verifyPurchase(final AdjustPurchase purchase, final OnPurchaseVerificationFinishedListener callback) { + public void verifyPlayStorePurchase(final AdjustPurchase purchase, final OnPurchaseVerificationFinishedListener callback) { executor.submit(new Runnable() { @Override public void run() { - verifyPurchaseI(purchase, callback); + verifyPlayStorePurchaseI(purchase, callback); } }); } @@ -2504,7 +2504,8 @@ private void trackPlayStoreSubscriptionI(final AdjustPlayStoreSubscription subsc packageHandler.sendFirstPackage(); } - private void verifyPurchaseI(final AdjustPurchase purchase, final OnPurchaseVerificationFinishedListener callback) { + private void verifyPlayStorePurchaseI(final AdjustPurchase purchase, + final OnPurchaseVerificationFinishedListener callback) { if (callback == null) { logger.warn("Purchase verification aborted because verification callback is null"); return; @@ -2582,6 +2583,11 @@ private void verifyAndTrackPlayStorePurchaseI(final AdjustEvent event, // from this moment on we know that we can ping client callback in case of error if (adjustConfig.isDataResidency) { logger.warn("Purchase verification not available for data residency users right now"); + AdjustPurchaseVerificationResult result = new AdjustPurchaseVerificationResult( + "not_verified", + 109, + "Purchase verification not available for data residency users right now"); + callback.onVerificationFinished(result); return; } if (!checkActivityStateI(activityState)) { diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/Adjust.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/Adjust.java index 3a4eea7e1..098fbc8c2 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/Adjust.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/Adjust.java @@ -431,13 +431,14 @@ public static void getSdkVersion(final OnSdkVersionReadListener onSdkVersionRead * @param purchase AdjustPurchase object to be tracked * @param callback Callback to obtain verification results */ - public static void verifyPurchase(final AdjustPurchase purchase, final OnPurchaseVerificationFinishedListener callback) { + public static void verifyPlayStorePurchase(final AdjustPurchase purchase, + final OnPurchaseVerificationFinishedListener callback) { if (callback == null) { AdjustFactory.getLogger().error("Purchase verification aborted because verification callback is null"); return; } AdjustInstance adjustInstance = Adjust.getDefaultInstance(); - adjustInstance.verifyPurchase(purchase, callback); + adjustInstance.verifyPlayStorePurchase(purchase, callback); } /** diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustInstance.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustInstance.java index 37d212d3b..1bc8078cd 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustInstance.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustInstance.java @@ -771,7 +771,8 @@ private boolean isInstanceEnabled() { * @param purchase AdjustPurchase object to be verified * @param callback Callback to be pinged with the verification results */ - public void verifyPurchase(final AdjustPurchase purchase, final OnPurchaseVerificationFinishedListener callback) { + public void verifyPlayStorePurchase(final AdjustPurchase purchase, + final OnPurchaseVerificationFinishedListener callback) { if (!checkActivityHandler("verifyPurchase")) { AdjustPurchaseVerificationResult result = new AdjustPurchaseVerificationResult( "not_verified", @@ -780,7 +781,7 @@ public void verifyPurchase(final AdjustPurchase purchase, final OnPurchaseVerifi callback.onVerificationFinished(result); return; } - activityHandler.verifyPurchase(purchase, callback); + activityHandler.verifyPlayStorePurchase(purchase, callback); } /** diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/IActivityHandler.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/IActivityHandler.java index 1fca05e26..26d4e8ace 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/IActivityHandler.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/IActivityHandler.java @@ -74,7 +74,7 @@ public interface IActivityHandler { void trackPlayStoreSubscription(AdjustPlayStoreSubscription subscription); - void verifyPurchase(AdjustPurchase purchase, OnPurchaseVerificationFinishedListener callback); + void verifyPlayStorePurchase(AdjustPurchase purchase, OnPurchaseVerificationFinishedListener callback); void verifyAndTrackPlayStorePurchase(AdjustEvent event, OnPurchaseVerificationFinishedListener callback); diff --git a/Adjust/test-app-core/src/main/java/com/adjust/testapp/AdjustCommandExecutor.java b/Adjust/test-app-core/src/main/java/com/adjust/testapp/AdjustCommandExecutor.java index fbc8cde77..0b0e1bf42 100644 --- a/Adjust/test-app-core/src/main/java/com/adjust/testapp/AdjustCommandExecutor.java +++ b/Adjust/test-app-core/src/main/java/com/adjust/testapp/AdjustCommandExecutor.java @@ -794,7 +794,7 @@ private void verifyPurchase() { final String localBasePath = basePath; AdjustPurchase purchase = new AdjustPurchase(sku, purchaseToken); - Adjust.verifyPurchase(purchase, new OnPurchaseVerificationFinishedListener() { + Adjust.verifyPlayStorePurchase(purchase, new OnPurchaseVerificationFinishedListener() { @Override public void onVerificationFinished(AdjustPurchaseVerificationResult result) { MainActivity.testLibrary.addInfoToSend("verification_status", result.getVerificationStatus()); From 1d0730b2315cadc3c32a9661ae837f5cff186002 Mon Sep 17 00:00:00 2001 From: uerceg Date: Thu, 30 May 2024 17:23:19 +0200 Subject: [PATCH 4/5] refac: rename AdjustPurchase to AdjustPlayStorePurchase --- .../src/main/java/com/adjust/sdk/ActivityHandler.java | 4 ++-- Adjust/sdk-core/src/main/java/com/adjust/sdk/Adjust.java | 2 +- .../sdk-core/src/main/java/com/adjust/sdk/AdjustInstance.java | 2 +- .../sdk/{AdjustPurchase.java => AdjustPlayStorePurchase.java} | 4 ++-- .../src/main/java/com/adjust/sdk/IActivityHandler.java | 2 +- .../sdk-core/src/main/java/com/adjust/sdk/PackageBuilder.java | 4 ++-- .../main/java/com/adjust/testapp/AdjustCommandExecutor.java | 4 ++-- 7 files changed, 11 insertions(+), 11 deletions(-) rename Adjust/sdk-core/src/main/java/com/adjust/sdk/{AdjustPurchase.java => AdjustPlayStorePurchase.java} (71%) diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/ActivityHandler.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/ActivityHandler.java index 933ddfdb5..04c10b67e 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/ActivityHandler.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/ActivityHandler.java @@ -805,7 +805,7 @@ public void run() { } @Override - public void verifyPlayStorePurchase(final AdjustPurchase purchase, final OnPurchaseVerificationFinishedListener callback) { + public void verifyPlayStorePurchase(final AdjustPlayStorePurchase purchase, final OnPurchaseVerificationFinishedListener callback) { executor.submit(new Runnable() { @Override public void run() { @@ -2504,7 +2504,7 @@ private void trackPlayStoreSubscriptionI(final AdjustPlayStoreSubscription subsc packageHandler.sendFirstPackage(); } - private void verifyPlayStorePurchaseI(final AdjustPurchase purchase, + private void verifyPlayStorePurchaseI(final AdjustPlayStorePurchase purchase, final OnPurchaseVerificationFinishedListener callback) { if (callback == null) { logger.warn("Purchase verification aborted because verification callback is null"); diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/Adjust.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/Adjust.java index 098fbc8c2..bf454bbc6 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/Adjust.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/Adjust.java @@ -431,7 +431,7 @@ public static void getSdkVersion(final OnSdkVersionReadListener onSdkVersionRead * @param purchase AdjustPurchase object to be tracked * @param callback Callback to obtain verification results */ - public static void verifyPlayStorePurchase(final AdjustPurchase purchase, + public static void verifyPlayStorePurchase(final AdjustPlayStorePurchase purchase, final OnPurchaseVerificationFinishedListener callback) { if (callback == null) { AdjustFactory.getLogger().error("Purchase verification aborted because verification callback is null"); diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustInstance.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustInstance.java index 1bc8078cd..fb09c786e 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustInstance.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustInstance.java @@ -771,7 +771,7 @@ private boolean isInstanceEnabled() { * @param purchase AdjustPurchase object to be verified * @param callback Callback to be pinged with the verification results */ - public void verifyPlayStorePurchase(final AdjustPurchase purchase, + public void verifyPlayStorePurchase(final AdjustPlayStorePurchase purchase, final OnPurchaseVerificationFinishedListener callback) { if (!checkActivityHandler("verifyPurchase")) { AdjustPurchaseVerificationResult result = new AdjustPurchaseVerificationResult( diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustPurchase.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustPlayStorePurchase.java similarity index 71% rename from Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustPurchase.java rename to Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustPlayStorePurchase.java index 25e32ed1d..20361f446 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustPurchase.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustPlayStorePurchase.java @@ -1,10 +1,10 @@ package com.adjust.sdk; -public class AdjustPurchase { +public class AdjustPlayStorePurchase { private final String productId; private final String purchaseToken; - public AdjustPurchase(final String productId, final String purchaseToken) { + public AdjustPlayStorePurchase(final String productId, final String purchaseToken) { this.productId = productId; this.purchaseToken = purchaseToken; } diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/IActivityHandler.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/IActivityHandler.java index 26d4e8ace..f54f58bd1 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/IActivityHandler.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/IActivityHandler.java @@ -74,7 +74,7 @@ public interface IActivityHandler { void trackPlayStoreSubscription(AdjustPlayStoreSubscription subscription); - void verifyPlayStorePurchase(AdjustPurchase purchase, OnPurchaseVerificationFinishedListener callback); + void verifyPlayStorePurchase(AdjustPlayStorePurchase purchase, OnPurchaseVerificationFinishedListener callback); void verifyAndTrackPlayStorePurchase(AdjustEvent event, OnPurchaseVerificationFinishedListener callback); diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/PackageBuilder.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/PackageBuilder.java index b2291c26d..71266884e 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/PackageBuilder.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/PackageBuilder.java @@ -209,7 +209,7 @@ ActivityPackage buildSubscriptionPackage(AdjustPlayStoreSubscription subscriptio return subscriptionPackage; } - ActivityPackage buildVerificationPackage(AdjustPurchase purchase, OnPurchaseVerificationFinishedListener callback) { + ActivityPackage buildVerificationPackage(AdjustPlayStorePurchase purchase, OnPurchaseVerificationFinishedListener callback) { Map parameters = getVerificationParameters(purchase); ActivityPackage purchaseVerificationPackage = getDefaultActivityPackage(ActivityKind.PURCHASE_VERIFICATION); purchaseVerificationPackage.setPath("/verify"); @@ -1061,7 +1061,7 @@ private Map getSubscriptionParameters(AdjustPlayStoreSubscriptio return parameters; } - private Map getVerificationParameters(AdjustPurchase purchase) { + private Map getVerificationParameters(AdjustPlayStorePurchase purchase) { Map parameters = new HashMap(); deviceInfo.reloadOtherDeviceInfoParams(adjustConfig, coppaEnabled, logger); diff --git a/Adjust/test-app-core/src/main/java/com/adjust/testapp/AdjustCommandExecutor.java b/Adjust/test-app-core/src/main/java/com/adjust/testapp/AdjustCommandExecutor.java index 0b0e1bf42..3a1613ac8 100644 --- a/Adjust/test-app-core/src/main/java/com/adjust/testapp/AdjustCommandExecutor.java +++ b/Adjust/test-app-core/src/main/java/com/adjust/testapp/AdjustCommandExecutor.java @@ -18,7 +18,7 @@ import com.adjust.sdk.AdjustEventFailure; import com.adjust.sdk.AdjustEventSuccess; import com.adjust.sdk.AdjustPlayStoreSubscription; -import com.adjust.sdk.AdjustPurchase; +import com.adjust.sdk.AdjustPlayStorePurchase; import com.adjust.sdk.AdjustPurchaseVerificationResult; import com.adjust.sdk.AdjustSessionFailure; import com.adjust.sdk.AdjustSessionSuccess; @@ -793,7 +793,7 @@ private void verifyPurchase() { String purchaseToken = command.getFirstParameterValue("purchaseToken"); final String localBasePath = basePath; - AdjustPurchase purchase = new AdjustPurchase(sku, purchaseToken); + AdjustPlayStorePurchase purchase = new AdjustPlayStorePurchase(sku, purchaseToken); Adjust.verifyPlayStorePurchase(purchase, new OnPurchaseVerificationFinishedListener() { @Override public void onVerificationFinished(AdjustPurchaseVerificationResult result) { From bc5a0f3ba30b11e19d84fafad9c95d68ffd3b500 Mon Sep 17 00:00:00 2001 From: uerceg Date: Thu, 30 May 2024 17:24:09 +0200 Subject: [PATCH 5/5] chore: remove todo comment --- .../sdk-core/src/main/java/com/adjust/sdk/ActivityHandler.java | 1 - 1 file changed, 1 deletion(-) diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/ActivityHandler.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/ActivityHandler.java index 04c10b67e..8556e8a9a 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/ActivityHandler.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/ActivityHandler.java @@ -2642,7 +2642,6 @@ private void verifyAndTrackPlayStorePurchaseI(final AdjustEvent event, return; } purchaseVerificationHandler.sendPurchaseVerificationPackage(verificationPackage); - // TODO: TBD if this is the right timing trackEventI(event); }