Skip to content

Commit

Permalink
Merge branch 'develop' into 'master'
Browse files Browse the repository at this point in the history
Develop

See merge request sdk_group/store-android-sdk!206
  • Loading branch information
DenisRakhimovXsolla committed Mar 7, 2024
2 parents 54350b1 + 2c9638a commit e1948f1
Show file tree
Hide file tree
Showing 24 changed files with 218 additions and 104 deletions.
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions app-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,5 @@ dependencies {
api 'com.github.kirich1409:viewbindingpropertydelegate:1.4.7'

implementation project(":xsolla-store-sdk")
implementation project(':xsolla-payments-sdk')
}
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -17,9 +20,11 @@ class VmPurchase(app: Application) : AndroidViewModel(app) {
val startPurchaseError = SingleLiveEvent<String>()

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<Application>().packageName}",
redirectPolicy = SettingsRedirectPolicy(
redirectConditions = "any",
Expand Down
2 changes: 1 addition & 1 deletion app-core/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,6 @@

<string name="payment_completed">Payment completed</string>
<string name="payment_cancelled">Payment cancelled</string>
<string name="payment_unknown">Payment error</string>
<string name="payment_unknown">Payment cancelled</string>

</resources>
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
package com.xsolla.android.samples.buy.adapter

import android.app.Application
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
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
Expand Down Expand Up @@ -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",
Expand Down
14 changes: 7 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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 = ""
}

This file was deleted.

21 changes: 14 additions & 7 deletions xsolla-login-sdk/src/main/java/com/xsolla/android/login/XLogin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> {
val browserIntent = Intent()
Expand Down
Original file line number Diff line number Diff line change
@@ -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 = ""
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -69,6 +70,7 @@ class RegistrationTests {
}

@Test
@Ignore("api was changed, need to rework this test")
fun resendAccountConfirmationEmail_Success() {
initSdkOauth()
initLoggedOut()
Expand All @@ -90,6 +92,7 @@ class RegistrationTests {
}

@Test
@Ignore("api was changed, need to rework this test")
fun resendAccountConfirmationEmailWithLocale_Success() {
initSdkOauth()
initLoggedOut()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
*/
Expand Down
Loading

0 comments on commit e1948f1

Please sign in to comment.