From 02735926061a44752865b5ecd22ddc129c9a8ef7 Mon Sep 17 00:00:00 2001 From: Tangem Date: Mon, 17 Jul 2023 16:47:29 +0300 Subject: [PATCH] Updated on 2026-08-14 --- app/src/main/assets/tangem-app-config | 2 +- .../tap/common/shop/TangemShopService.kt | 20 ++++++++++--------- .../common/shop/googlepay/GooglePayService.kt | 9 +++------ .../datasource/config/models/ShopifyShop.kt | 4 +++- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/app/src/main/assets/tangem-app-config b/app/src/main/assets/tangem-app-config index fad890b2a0..b791bd4cf6 160000 --- a/app/src/main/assets/tangem-app-config +++ b/app/src/main/assets/tangem-app-config @@ -1 +1 @@ -Subproject commit fad890b2a0b552be60d124949ca0a3a4d672dac1 +Subproject commit b791bd4cf6c5eca9778f89e87cd62b72d24f5ce9 diff --git a/app/src/main/java/com/tangem/tap/common/shop/TangemShopService.kt b/app/src/main/java/com/tangem/tap/common/shop/TangemShopService.kt index 335228e10f..3032ef611a 100644 --- a/app/src/main/java/com/tangem/tap/common/shop/TangemShopService.kt +++ b/app/src/main/java/com/tangem/tap/common/shop/TangemShopService.kt @@ -18,7 +18,8 @@ import kotlinx.coroutines.async import kotlinx.coroutines.awaitAll import kotlinx.coroutines.coroutineScope import java.math.BigDecimal -import java.util.* +import java.util.Currency +import java.util.UUID class TangemShopService(application: Application, shopifyShop: ShopifyShop) { @@ -82,16 +83,18 @@ class TangemShopService(application: Application, shopifyShop: ShopifyShop) { suspend fun checkIfGooglePayAvailable(googlePayService: GooglePayService): Result { this.googlePayService = googlePayService - return googlePayService.checkIfGooglePayAvailable() + return googlePayService.checkIfGooglePayAvailable(shopifyService.shop.merchantID != null) } fun buyWithGooglePay(productType: ProductType) { - val totalPrice = checkouts[productType]!!.totalPriceV2.amount - googlePayService.payWithGooglePay( - totalPriceCents = totalPrice, - currencyCode = checkouts[productType]!!.currencyCode.name, - merchantID = shopifyService.shop.merchantID, - ) + shopifyService.shop.merchantID?.let { merchantId -> + val totalPrice = checkouts[productType]!!.totalPriceV2.amount + googlePayService.payWithGooglePay( + totalPriceCents = totalPrice, + currencyCode = checkouts[productType]!!.currencyCode.name, + merchantID = merchantId, + ) + } } // fun subscribeToGooglePayResult( @@ -185,7 +188,6 @@ class TangemShopService(application: Application, shopifyShop: ShopifyShop) { ), appliedDiscount = it.getAppliedDiscount(), ), - ) } return Result.failure(result.exceptionOrNull()!!) diff --git a/app/src/main/java/com/tangem/tap/common/shop/googlepay/GooglePayService.kt b/app/src/main/java/com/tangem/tap/common/shop/googlepay/GooglePayService.kt index 757b207741..7526224414 100644 --- a/app/src/main/java/com/tangem/tap/common/shop/googlepay/GooglePayService.kt +++ b/app/src/main/java/com/tangem/tap/common/shop/googlepay/GooglePayService.kt @@ -6,11 +6,7 @@ import android.app.Activity.RESULT_OK import android.content.Intent import android.util.Log import com.google.android.gms.common.api.ApiException -import com.google.android.gms.wallet.AutoResolveHelper -import com.google.android.gms.wallet.IsReadyToPayRequest -import com.google.android.gms.wallet.PaymentData -import com.google.android.gms.wallet.PaymentDataRequest -import com.google.android.gms.wallet.PaymentsClient +import com.google.android.gms.wallet.* import com.tangem.common.core.TangemSdkError import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext @@ -24,7 +20,8 @@ class GooglePayService(private val paymentsClient: PaymentsClient, private val a // var responseCallback: ((Result) -> Unit)? = null - suspend fun checkIfGooglePayAvailable(): Result { + suspend fun checkIfGooglePayAvailable(isMerchantAvailable: Boolean): Result { + if (!isMerchantAvailable) return Result.success(false) val isReadyToPayJson = GooglePayUtil.isReadyToPayRequest() ?: return Result.success(false) val request = IsReadyToPayRequest.fromJson(isReadyToPayJson.toString()) diff --git a/core/datasource/src/main/java/com/tangem/datasource/config/models/ShopifyShop.kt b/core/datasource/src/main/java/com/tangem/datasource/config/models/ShopifyShop.kt index cdda42d58c..c4a09adcfe 100644 --- a/core/datasource/src/main/java/com/tangem/datasource/config/models/ShopifyShop.kt +++ b/core/datasource/src/main/java/com/tangem/datasource/config/models/ShopifyShop.kt @@ -5,8 +5,10 @@ import com.squareup.moshi.JsonClass @JsonClass(generateAdapter = true) data class ShopifyShop( + @Json(name = "domain") val domain: String, @Json(name = "storefrontApiKeyAndroid") val storefrontApiKey: String, - val merchantID: String, + @Json(name = "merchantID") + val merchantID: String?, ) \ No newline at end of file