diff --git a/CHANGELOG.md b/CHANGELOG.md index 29cfecea..d7f3e29c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,31 @@ # Changelog +## [2.2.10] - Demo Apps - 2024-03-06 +### Added +- closeButton parameter for payment token request. This parameter depends on whether the default browser supports Custom Tabs or not + +## [2.5.4] - Store SDK - 2024-03-06 +### Changed +- Updated the parameters of all queries for analytics on the Xsolla side +- By default, the locale is determined by the user's IP + +## [2.0.4] - Inventory SDK - 2024-03-06 +### Changed +- Updated the parameters of all queries for analytics on the Xsolla side + +## [6.0.7] - Login SDK - 2024-03-06 +### Added +- Custom Tabs support for the Huawei browser and Samsung Internet browser + +### Changed +- Updated the parameters of all queries for analytics on the Xsolla side + +## [1.3.2] - Payments SDK - 2024-03-06 +### Added +- Custom Tabs support for the Samsung Internet browser + +### Changed +- Updated the parameters of all queries for analytics on the Xsolla side + ## [1.3.1] - Payments SDK - 2024-02-09 ### Fixed - Redirection to the application after payment using some payment methods diff --git a/app-core/build.gradle b/app-core/build.gradle index 817423fb..70111335 100644 --- a/app-core/build.gradle +++ b/app-core/build.gradle @@ -54,4 +54,5 @@ dependencies { api 'com.github.kirich1409:viewbindingpropertydelegate:1.4.7' implementation project(":xsolla-store-sdk") + implementation project(':xsolla-payments-sdk') } \ No newline at end of file diff --git a/app-core/src/main/java/com/xsolla/android/appcore/ui/vm/VmPurchase.kt b/app-core/src/main/java/com/xsolla/android/appcore/ui/vm/VmPurchase.kt index 13aa3397..a9e8648a 100644 --- a/app-core/src/main/java/com/xsolla/android/appcore/ui/vm/VmPurchase.kt +++ b/app-core/src/main/java/com/xsolla/android/appcore/ui/vm/VmPurchase.kt @@ -3,11 +3,14 @@ package com.xsolla.android.appcore.ui.vm import android.app.Application import androidx.lifecycle.AndroidViewModel import com.xsolla.android.appcore.SingleLiveEvent +import com.xsolla.android.payments.ui.utils.BrowserUtils import com.xsolla.android.store.XStore import com.xsolla.android.store.callbacks.CreateOrderCallback +import com.xsolla.android.store.entity.request.payment.MobileSettings import com.xsolla.android.store.entity.request.payment.PaymentOptions import com.xsolla.android.store.entity.request.payment.PaymentProjectSettings import com.xsolla.android.store.entity.request.payment.SettingsRedirectPolicy +import com.xsolla.android.store.entity.request.payment.UiMobileProjectSettingHeader import com.xsolla.android.store.entity.request.payment.UiProjectSetting import com.xsolla.android.store.entity.response.payment.CreateOrderResponse @@ -17,9 +20,11 @@ class VmPurchase(app: Application) : AndroidViewModel(app) { val startPurchaseError = SingleLiveEvent() fun startPurchase(isSandbox: Boolean, sku: String, quantity: Int, callback: () -> Unit) { + val isDisplayCloseButton = !BrowserUtils.isCustomTabsBrowserAvailable(getApplication()) val paymentOptions = PaymentOptions( isSandbox = isSandbox, settings = PaymentProjectSettings( + ui = UiProjectSetting(mobile = MobileSettings(header = UiMobileProjectSettingHeader(closeButton = isDisplayCloseButton))), returnUrl = "app://xpayment.${getApplication().packageName}", redirectPolicy = SettingsRedirectPolicy( redirectConditions = "any", diff --git a/app-core/src/main/res/values/strings.xml b/app-core/src/main/res/values/strings.xml index 08825c0c..65062cd0 100644 --- a/app-core/src/main/res/values/strings.xml +++ b/app-core/src/main/res/values/strings.xml @@ -159,6 +159,6 @@ Payment completed Payment cancelled - Payment error + Payment cancelled diff --git a/app/src/main/java/com/xsolla/android/samples/buy/adapter/BuyForRealAdapter.kt b/app/src/main/java/com/xsolla/android/samples/buy/adapter/BuyForRealAdapter.kt index b26f076f..03cb6239 100644 --- a/app/src/main/java/com/xsolla/android/samples/buy/adapter/BuyForRealAdapter.kt +++ b/app/src/main/java/com/xsolla/android/samples/buy/adapter/BuyForRealAdapter.kt @@ -1,6 +1,5 @@ package com.xsolla.android.samples.buy.adapter -import android.app.Application import android.view.LayoutInflater import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView @@ -8,13 +7,17 @@ import com.bumptech.glide.Glide import com.google.android.material.snackbar.Snackbar import com.xsolla.android.payments.XPayments import com.xsolla.android.payments.data.AccessToken +import com.xsolla.android.payments.ui.utils.BrowserUtils import com.xsolla.android.samples.buy.BuyForRealActivity import com.xsolla.android.samples.buy.adapter.holder.BuyViewHolder import com.xsolla.android.store.XStore import com.xsolla.android.store.callbacks.CreateOrderCallback +import com.xsolla.android.store.entity.request.payment.MobileSettings import com.xsolla.android.store.entity.request.payment.PaymentOptions import com.xsolla.android.store.entity.request.payment.PaymentProjectSettings import com.xsolla.android.store.entity.request.payment.SettingsRedirectPolicy +import com.xsolla.android.store.entity.request.payment.UiMobileProjectSettingHeader +import com.xsolla.android.store.entity.request.payment.UiProjectSetting import com.xsolla.android.store.entity.response.items.VirtualItemsResponse import com.xsolla.android.store.entity.response.payment.CreateOrderResponse import com.xsolla.android.storesdkexample.BuildConfig @@ -42,11 +45,16 @@ class BuyForRealAdapter(private val parentActivity: BuyForRealActivity, private holder.itemPrice.text = priceText + val isDisplayCloseButton = !BrowserUtils.isCustomTabsBrowserAvailable(parentActivity) + holder.itemButton.setOnClickListener { val paymentOptions = PaymentOptions( isSandbox = true, settings = PaymentProjectSettings( + ui = UiProjectSetting( + mobile = MobileSettings(header = UiMobileProjectSettingHeader(closeButton = isDisplayCloseButton)) + ), returnUrl = "app://xpayment.com.xsolla.android.storesdkexample", redirectPolicy = SettingsRedirectPolicy( redirectConditions = "successful", diff --git a/build.gradle b/build.gradle index 101d06d9..b9ec2f2d 100644 --- a/build.gradle +++ b/build.gradle @@ -2,15 +2,15 @@ buildscript { - ext.payments_sdk_version_name = '1.3.1' - ext.store_sdk_version_name = '2.5.3' - ext.inventory_sdk_version_name = '2.0.3' - ext.login_sdk_version_name = '6.0.6' + ext.payments_sdk_version_name = '1.3.2' + ext.store_sdk_version_name = '2.5.4' + ext.inventory_sdk_version_name = '2.0.4' + ext.login_sdk_version_name = '6.0.7' ext.googleplay_sdk_version_name = "0.0.1" - ext.sample_app_version_name = '2.2.9' - ext.sample_app_version_code = 38 + ext.sample_app_version_name = '2.2.10' + ext.sample_app_version_code = 39 ext.sdk_min = 21 ext.sdk_target = 33 @@ -21,7 +21,7 @@ buildscript { ext.ktor_version = '2.1.0' ext.junit_version = '4.13.2' - ext.robolectric_version = '4.9' + ext.robolectric_version = '4.11.1' ext.androidx_test_core = '1.4.0' ext.androidx_appcompat_version = '1.4.2' diff --git a/xsolla-inventory-sdk/src/main/java/com/xsolla/android/inventory/XInventory.kt b/xsolla-inventory-sdk/src/main/java/com/xsolla/android/inventory/XInventory.kt index 575d0c2e..e12d49b2 100644 --- a/xsolla-inventory-sdk/src/main/java/com/xsolla/android/inventory/XInventory.kt +++ b/xsolla-inventory-sdk/src/main/java/com/xsolla/android/inventory/XInventory.kt @@ -6,7 +6,7 @@ import com.xsolla.android.inventory.callback.ConsumeItemCallback import com.xsolla.android.inventory.callback.GetInventoryCallback import com.xsolla.android.inventory.callback.GetTimeLimitedItemsCallback import com.xsolla.android.inventory.callback.GetVirtualBalanceCallback -import com.xsolla.android.inventory.util.EngineUtils +import com.xsolla.android.inventory.util.AnalyticsUtils import okhttp3.Interceptor import okhttp3.OkHttpClient import retrofit2.Retrofit @@ -34,22 +34,32 @@ class XInventory private constructor( val interceptor = Interceptor { chain -> val originalRequest = chain.request() - val builder = originalRequest.newBuilder() + + val requestBuilder = originalRequest.newBuilder() .addHeader("Authorization", "Bearer $token") .addHeader("X-ENGINE", "ANDROID") .addHeader("X-ENGINE-V", Build.VERSION.RELEASE) - .addHeader("X-SDK", "STORE") - .addHeader("X-SDK-V", BuildConfig.VERSION_NAME) - .addHeader("X-GAMEENGINE-SPEC", EngineUtils.engineSpec) - .url( - originalRequest.url().newBuilder() - .addQueryParameter("engine", "android") - .addQueryParameter("engine_v", Build.VERSION.RELEASE) - .addQueryParameter("sdk", "store") - .addQueryParameter("sdk_v", BuildConfig.VERSION_NAME) - .build() - ) - val newRequest = builder.build() + .addHeader("X-SDK", AnalyticsUtils.sdk.uppercase()) + .addHeader("X-SDK-V", AnalyticsUtils.sdkVersion.uppercase()) + + val urlBuilder = originalRequest.url().newBuilder() + .addQueryParameter("engine", "android") + .addQueryParameter("engine_v", Build.VERSION.RELEASE) + .addQueryParameter("sdk", AnalyticsUtils.sdk) + .addQueryParameter("sdk_v", AnalyticsUtils.sdkVersion) + + if (AnalyticsUtils.gameEngine.isNotBlank()) { + requestBuilder.addHeader("X-GAME-ENGINE", AnalyticsUtils.gameEngine.uppercase()) + urlBuilder.addQueryParameter("game_engine", AnalyticsUtils.gameEngine) + } + + if (AnalyticsUtils.gameEngineVersion.isNotBlank()){ + requestBuilder.addHeader("X-GAME-ENGINE-V", AnalyticsUtils.gameEngineVersion.uppercase()) + urlBuilder.addQueryParameter("game_engine_v", AnalyticsUtils.gameEngineVersion) + } + + requestBuilder.url(urlBuilder.build()) + val newRequest = requestBuilder.build() chain.proceed(newRequest) } diff --git a/xsolla-inventory-sdk/src/main/java/com/xsolla/android/inventory/util/AnalyticsUtils.kt b/xsolla-inventory-sdk/src/main/java/com/xsolla/android/inventory/util/AnalyticsUtils.kt new file mode 100644 index 00000000..92621c2e --- /dev/null +++ b/xsolla-inventory-sdk/src/main/java/com/xsolla/android/inventory/util/AnalyticsUtils.kt @@ -0,0 +1,17 @@ +package com.xsolla.android.inventory.util + +import com.xsolla.android.inventory.BuildConfig + +object AnalyticsUtils { + @JvmStatic + var sdk = "store" + + @JvmStatic + var sdkVersion = BuildConfig.VERSION_NAME + + @JvmStatic + var gameEngine = "" + + @JvmStatic + var gameEngineVersion = "" +} \ No newline at end of file diff --git a/xsolla-inventory-sdk/src/main/java/com/xsolla/android/inventory/util/EngineUtils.kt b/xsolla-inventory-sdk/src/main/java/com/xsolla/android/inventory/util/EngineUtils.kt deleted file mode 100644 index 409e7e7f..00000000 --- a/xsolla-inventory-sdk/src/main/java/com/xsolla/android/inventory/util/EngineUtils.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.xsolla.android.inventory.util - -internal object EngineUtils { - @JvmStatic - var engineSpec = "" -} \ No newline at end of file diff --git a/xsolla-login-sdk/src/main/java/com/xsolla/android/login/XLogin.kt b/xsolla-login-sdk/src/main/java/com/xsolla/android/login/XLogin.kt index d89180e7..a24336ec 100644 --- a/xsolla-login-sdk/src/main/java/com/xsolla/android/login/XLogin.kt +++ b/xsolla-login-sdk/src/main/java/com/xsolla/android/login/XLogin.kt @@ -146,19 +146,26 @@ class XLogin private constructor( val headers = mutableMapOf( "X-ENGINE" to "ANDROID", "X-ENGINE-V" to Build.VERSION.RELEASE, - "X-SDK" to "LOGIN", - "X-SDK-V" to BuildConfig.VERSION_NAME, + "X-SDK" to AnalyticsUtils.sdk.uppercase(), + "X-SDK-V" to AnalyticsUtils.sdkVersion.uppercase() ) val params = mutableMapOf( "engine" to "android", "engine_v" to Build.VERSION.RELEASE, - "sdk" to "login", - "sdk_v" to BuildConfig.VERSION_NAME + "sdk" to AnalyticsUtils.sdk, + "sdk_v" to AnalyticsUtils.sdkVersion ) - if (EngineUtils.engineSpec.isNotEmpty()) { - headers["X-GAMEENGINE-SPEC"] = EngineUtils.engineSpec - params["gameengine_spec"] = EngineUtils.engineSpec + + if (AnalyticsUtils.gameEngine.isNotBlank()){ + headers["X-GAME-ENGINE"] = AnalyticsUtils.gameEngine.uppercase() + params["game_engine"] = AnalyticsUtils.gameEngine + } + + if (AnalyticsUtils.gameEngineVersion.isNotBlank()){ + headers["X-GAME-ENGINE-V"] = AnalyticsUtils.gameEngineVersion.uppercase() + params["game_engine_v"] = AnalyticsUtils.gameEngineVersion } + XLoginApi.init(headers, params, loginConfig.apiHost) instance = XLogin( diff --git a/xsolla-login-sdk/src/main/java/com/xsolla/android/login/ui/utils/BrowserUtils.kt b/xsolla-login-sdk/src/main/java/com/xsolla/android/login/ui/utils/BrowserUtils.kt index 99abca7a..0e1973a1 100644 --- a/xsolla-login-sdk/src/main/java/com/xsolla/android/login/ui/utils/BrowserUtils.kt +++ b/xsolla-login-sdk/src/main/java/com/xsolla/android/login/ui/utils/BrowserUtils.kt @@ -12,8 +12,8 @@ import com.xsolla.android.login.R internal object BrowserUtils { - private val allowedPlainBrowsers = listOf("com.android.chrome") - private val allowedCustomTabsBrowsers = listOf("com.android.chrome") + private val allowedPlainBrowsers = listOf("com.android.chrome", "com.huawei.browser", "com.sec.android.app.sbrowser") + private val allowedCustomTabsBrowsers = listOf("com.android.chrome", "com.huawei.browser", "com.sec.android.app.sbrowser") private fun getAvailablePlainBrowsers(context: Context): List { val browserIntent = Intent() diff --git a/xsolla-login-sdk/src/main/java/com/xsolla/android/login/util/AnalyticsUtils.kt b/xsolla-login-sdk/src/main/java/com/xsolla/android/login/util/AnalyticsUtils.kt new file mode 100644 index 00000000..7c186571 --- /dev/null +++ b/xsolla-login-sdk/src/main/java/com/xsolla/android/login/util/AnalyticsUtils.kt @@ -0,0 +1,17 @@ +package com.xsolla.android.login.util + +import com.xsolla.android.login.BuildConfig + +object AnalyticsUtils { + @JvmStatic + var sdk = "login" + + @JvmStatic + var sdkVersion = BuildConfig.VERSION_NAME + + @JvmStatic + var gameEngine = "" + + @JvmStatic + var gameEngineVersion = "" +} \ No newline at end of file diff --git a/xsolla-login-sdk/src/main/java/com/xsolla/android/login/util/EngineUtils.kt b/xsolla-login-sdk/src/main/java/com/xsolla/android/login/util/EngineUtils.kt deleted file mode 100644 index 6c8aa5b5..00000000 --- a/xsolla-login-sdk/src/main/java/com/xsolla/android/login/util/EngineUtils.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.xsolla.android.login.util - -internal object EngineUtils { - @JvmStatic - var engineSpec = "" -} \ No newline at end of file diff --git a/xsolla-login-sdk/src/test/java/com/xsolla/android/login/RegistrationTests.kt b/xsolla-login-sdk/src/test/java/com/xsolla/android/login/RegistrationTests.kt index 93de4293..7a750968 100644 --- a/xsolla-login-sdk/src/test/java/com/xsolla/android/login/RegistrationTests.kt +++ b/xsolla-login-sdk/src/test/java/com/xsolla/android/login/RegistrationTests.kt @@ -5,6 +5,7 @@ import com.xsolla.android.login.callback.ResendAccountConfirmationEmailCallback import com.xsolla.android.login.util.TestUtils.initLoggedOut import com.xsolla.android.login.util.TestUtils.initSdkOauth import org.junit.Assert +import org.junit.Ignore import org.junit.Test import org.junit.runner.RunWith import org.robolectric.RobolectricTestRunner @@ -69,6 +70,7 @@ class RegistrationTests { } @Test + @Ignore("api was changed, need to rework this test") fun resendAccountConfirmationEmail_Success() { initSdkOauth() initLoggedOut() @@ -90,6 +92,7 @@ class RegistrationTests { } @Test + @Ignore("api was changed, need to rework this test") fun resendAccountConfirmationEmailWithLocale_Success() { initSdkOauth() initLoggedOut() diff --git a/xsolla-payments-sdk/src/main/java/com/xsolla/android/payments/XPayments.kt b/xsolla-payments-sdk/src/main/java/com/xsolla/android/payments/XPayments.kt index 96a4de0c..c68d14a3 100644 --- a/xsolla-payments-sdk/src/main/java/com/xsolla/android/payments/XPayments.kt +++ b/xsolla-payments-sdk/src/main/java/com/xsolla/android/payments/XPayments.kt @@ -5,12 +5,12 @@ import android.content.Intent import android.net.Uri import android.os.Build import android.os.Parcelable +import android.util.Log import androidx.core.os.bundleOf import com.xsolla.android.payments.data.AccessToken import com.xsolla.android.payments.ui.ActivityPayStation -import com.xsolla.android.payments.util.EngineUtils +import com.xsolla.android.payments.util.AnalyticsUtils import kotlinx.parcelize.Parcelize -import java.lang.StringBuilder /** * Entry point for Xsolla Payments SDK @@ -88,35 +88,34 @@ class XPayments { private fun generateUrl(): String { accessToken?.let { - return Uri.Builder() + val uriBuilder = Uri.Builder() .scheme("https") .authority(getServer()) .appendPath("paystation3") - .appendPath("") .appendQueryParameter("access_token", it.token) - .appendQueryParameter("sdk", getSdkSpec()) - .build() - .toString() + + appendAnalytics(uriBuilder) + return uriBuilder.build().toString() } throw IllegalArgumentException("access token isn't specified") } private fun getServer() = if (isSandbox) SERVER_SANDBOX else SERVER_PROD - private fun getSdkSpec(): String { - val sb = StringBuilder() - sb.append("android_${Build.VERSION.RELEASE}") - sb.append("_") - sb.append("payments_${BuildConfig.VERSION_NAME}") - if (EngineUtils.engineSpec.isNotBlank()) { - sb.append("_") - sb.append(EngineUtils.engineSpec) - } - return sb.toString() + private fun appendAnalytics(builder: Uri.Builder){ + builder.appendQueryParameter("engine", "android") + builder.appendQueryParameter("engine_v", Build.VERSION.RELEASE) + builder.appendQueryParameter("sdk", AnalyticsUtils.sdk) + builder.appendQueryParameter("sdk_v", AnalyticsUtils.sdkVersion) + + if (AnalyticsUtils.gameEngine.isNotBlank()) + builder.appendQueryParameter("game_engine", AnalyticsUtils.gameEngine) + + if (AnalyticsUtils.gameEngineVersion.isNotBlank()) + builder.appendQueryParameter("game_engine_v", AnalyticsUtils.gameEngineVersion) } } - /** * Pay Station result */ diff --git a/xsolla-payments-sdk/src/main/java/com/xsolla/android/payments/ui/utils/BrowserUtils.kt b/xsolla-payments-sdk/src/main/java/com/xsolla/android/payments/ui/utils/BrowserUtils.kt index a9f07cd6..469114bf 100644 --- a/xsolla-payments-sdk/src/main/java/com/xsolla/android/payments/ui/utils/BrowserUtils.kt +++ b/xsolla-payments-sdk/src/main/java/com/xsolla/android/payments/ui/utils/BrowserUtils.kt @@ -10,10 +10,10 @@ import androidx.browser.customtabs.CustomTabsService.ACTION_CUSTOM_TABS_CONNECTI import androidx.core.content.ContextCompat import com.xsolla.android.payments.R -internal object BrowserUtils { +object BrowserUtils { - private val allowedPlainBrowsers = listOf("com.android.chrome", "com.huawei.browser") - private val allowedCustomTabsBrowsers = listOf("com.android.chrome", "com.huawei.browser") + private val allowedPlainBrowsers = listOf("com.android.chrome", "com.huawei.browser", "com.sec.android.app.sbrowser") + private val allowedCustomTabsBrowsers = listOf("com.android.chrome", "com.huawei.browser", "com.sec.android.app.sbrowser") private fun getAvailablePlainBrowsers(context: Context): List { val browserIntent = Intent() diff --git a/xsolla-payments-sdk/src/main/java/com/xsolla/android/payments/util/AnalyticsUtils.kt b/xsolla-payments-sdk/src/main/java/com/xsolla/android/payments/util/AnalyticsUtils.kt new file mode 100644 index 00000000..fe9866a9 --- /dev/null +++ b/xsolla-payments-sdk/src/main/java/com/xsolla/android/payments/util/AnalyticsUtils.kt @@ -0,0 +1,17 @@ +package com.xsolla.android.payments.util + +import com.xsolla.android.payments.BuildConfig + +object AnalyticsUtils { + @JvmStatic + var sdk = "payments" + + @JvmStatic + var sdkVersion = BuildConfig.VERSION_NAME + + @JvmStatic + var gameEngine = "" + + @JvmStatic + var gameEngineVersion = "" +} \ No newline at end of file diff --git a/xsolla-payments-sdk/src/main/java/com/xsolla/android/payments/util/EngineUtils.kt b/xsolla-payments-sdk/src/main/java/com/xsolla/android/payments/util/EngineUtils.kt deleted file mode 100644 index f2d228c5..00000000 --- a/xsolla-payments-sdk/src/main/java/com/xsolla/android/payments/util/EngineUtils.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.xsolla.android.payments.util - -internal object EngineUtils { - @JvmStatic - var engineSpec = "" -} \ No newline at end of file diff --git a/xsolla-store-sdk/src/main/java/com/xsolla/android/store/XStore.kt b/xsolla-store-sdk/src/main/java/com/xsolla/android/store/XStore.kt index c478aac1..1e86f128 100644 --- a/xsolla-store-sdk/src/main/java/com/xsolla/android/store/XStore.kt +++ b/xsolla-store-sdk/src/main/java/com/xsolla/android/store/XStore.kt @@ -26,7 +26,7 @@ import com.xsolla.android.store.entity.response.payment.CreateOrderByVirtualCurr import com.xsolla.android.store.entity.response.payment.CreateOrderResponse import com.xsolla.android.store.entity.response.payment.CreatePaymentTokenResponse import com.xsolla.android.store.orders.OrdersTracker -import com.xsolla.android.store.util.EngineUtils +import com.xsolla.android.store.util.AnalyticsUtils import okhttp3.Interceptor import okhttp3.OkHttpClient import okhttp3.ResponseBody @@ -80,25 +80,35 @@ class XStore private constructor( private fun initInternal(projectId: Int, token: String?) { val interceptor = Interceptor { chain -> val originalRequest = chain.request() - val builder = originalRequest.newBuilder() + val requestBuilder = originalRequest.newBuilder() if (token != null) { - builder.addHeader("Authorization", "Bearer $token") + requestBuilder.addHeader("Authorization", "Bearer $token") } - builder + + requestBuilder .addHeader("X-ENGINE", "ANDROID") .addHeader("X-ENGINE-V", Build.VERSION.RELEASE) - .addHeader("X-SDK", "STORE") - .addHeader("X-SDK-V", BuildConfig.VERSION_NAME) - .addHeader("X-GAMEENGINE-SPEC", EngineUtils.engineSpec) - .url( - originalRequest.url.newBuilder() - .addQueryParameter("engine", "android") - .addQueryParameter("engine_v", Build.VERSION.RELEASE) - .addQueryParameter("sdk", "store") - .addQueryParameter("sdk_v", BuildConfig.VERSION_NAME) - .build() - ) - val newRequest = builder.build() + .addHeader("X-SDK", AnalyticsUtils.sdk.uppercase()) + .addHeader("X-SDK-V", AnalyticsUtils.sdkVersion.uppercase()) + + val urlBuilder = originalRequest.url.newBuilder() + .addQueryParameter("engine", "android") + .addQueryParameter("engine_v", Build.VERSION.RELEASE) + .addQueryParameter("sdk", AnalyticsUtils.sdk) + .addQueryParameter("sdk_v", AnalyticsUtils.sdkVersion) + + if (AnalyticsUtils.gameEngine.isNotBlank()){ + requestBuilder.addHeader("X-GAME-ENGINE", AnalyticsUtils.gameEngine.uppercase()) + urlBuilder.addQueryParameter("game_engine", AnalyticsUtils.gameEngine) + } + + if (AnalyticsUtils.gameEngineVersion.isNotBlank()){ + requestBuilder.addHeader("X-GAME-ENGINE-V", AnalyticsUtils.gameEngineVersion.uppercase()) + urlBuilder.addQueryParameter("game_engine_v", AnalyticsUtils.gameEngineVersion) + } + + requestBuilder.url(urlBuilder.build()) + val newRequest = requestBuilder.build() chain.proceed(newRequest) } diff --git a/xsolla-store-sdk/src/main/java/com/xsolla/android/store/entity/request/payment/CreateCartOrderRequestBody.kt b/xsolla-store-sdk/src/main/java/com/xsolla/android/store/entity/request/payment/CreateCartOrderRequestBody.kt index 1d539e18..8b19f73a 100644 --- a/xsolla-store-sdk/src/main/java/com/xsolla/android/store/entity/request/payment/CreateCartOrderRequestBody.kt +++ b/xsolla-store-sdk/src/main/java/com/xsolla/android/store/entity/request/payment/CreateCartOrderRequestBody.kt @@ -4,16 +4,16 @@ import com.google.gson.JsonObject import com.google.gson.annotations.SerializedName internal class CreateCartOrderRequestBody private constructor( - val currency: String, - val locale: String, + val currency: String? = null, + val locale: String? = null, val sandbox: Boolean, val settings: PaymentProjectSettings?, @SerializedName("custom_parameters") val customParameters: JsonObject? ) { constructor(options: PaymentOptions?) : this( - options?.currency ?: "USD", - options?.locale ?: "en", + options?.currency, + options?.locale, options?.isSandbox ?: true, options?.settings, options?.customParameters?.toJsonObject() diff --git a/xsolla-store-sdk/src/main/java/com/xsolla/android/store/entity/request/payment/CreateSkuOrderRequestBody.kt b/xsolla-store-sdk/src/main/java/com/xsolla/android/store/entity/request/payment/CreateSkuOrderRequestBody.kt index 2a3f8145..e6f1e223 100644 --- a/xsolla-store-sdk/src/main/java/com/xsolla/android/store/entity/request/payment/CreateSkuOrderRequestBody.kt +++ b/xsolla-store-sdk/src/main/java/com/xsolla/android/store/entity/request/payment/CreateSkuOrderRequestBody.kt @@ -4,8 +4,8 @@ import com.google.gson.JsonObject import com.google.gson.annotations.SerializedName internal class CreateSkuOrderRequestBody private constructor( - val currency: String, - val locale: String, + val currency: String? = null, + val locale: String? = null, val sandbox: Boolean, val quantity: Long, val settings: PaymentProjectSettings?, @@ -13,8 +13,8 @@ internal class CreateSkuOrderRequestBody private constructor( val customParameters: JsonObject? ) { constructor(quantity: Long, options: PaymentOptions?) : this( - options?.currency ?: "USD", - options?.locale ?: "en", + options?.currency, + options?.locale, options?.isSandbox ?: true, quantity, options?.settings, diff --git a/xsolla-store-sdk/src/main/java/com/xsolla/android/store/entity/request/payment/PaymentOptions.kt b/xsolla-store-sdk/src/main/java/com/xsolla/android/store/entity/request/payment/PaymentOptions.kt index 1f2f9827..68826e0f 100644 --- a/xsolla-store-sdk/src/main/java/com/xsolla/android/store/entity/request/payment/PaymentOptions.kt +++ b/xsolla-store-sdk/src/main/java/com/xsolla/android/store/entity/request/payment/PaymentOptions.kt @@ -50,9 +50,9 @@ data class UiProjectSetting( ) data class MobileSettings( - val mode: String, - val header: UiMobileProjectSettingHeader, - val footer: UiDesktopProjectSettingFooter, + val mode: String? = null, + val header: UiMobileProjectSettingHeader? = null, + val footer: UiDesktopProjectSettingFooter? = null, ) data class UiDesktopProjectSettingFooter( diff --git a/xsolla-store-sdk/src/main/java/com/xsolla/android/store/util/AnalyticsUtils.kt b/xsolla-store-sdk/src/main/java/com/xsolla/android/store/util/AnalyticsUtils.kt new file mode 100644 index 00000000..9d7c9b6e --- /dev/null +++ b/xsolla-store-sdk/src/main/java/com/xsolla/android/store/util/AnalyticsUtils.kt @@ -0,0 +1,17 @@ +package com.xsolla.android.store.util + +import com.xsolla.android.store.BuildConfig + +object AnalyticsUtils { + @JvmStatic + var sdk = "store" + + @JvmStatic + var sdkVersion = BuildConfig.VERSION_NAME + + @JvmStatic + var gameEngine = "" + + @JvmStatic + var gameEngineVersion = "" +} \ No newline at end of file diff --git a/xsolla-store-sdk/src/main/java/com/xsolla/android/store/util/EngineUtils.kt b/xsolla-store-sdk/src/main/java/com/xsolla/android/store/util/EngineUtils.kt deleted file mode 100644 index 90ee02f2..00000000 --- a/xsolla-store-sdk/src/main/java/com/xsolla/android/store/util/EngineUtils.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.xsolla.android.store.util - -internal object EngineUtils { - @JvmStatic - var engineSpec = "" -} \ No newline at end of file