From 1eadb295841e1ec580cdb8365b4f2e6b542bcdcf Mon Sep 17 00:00:00 2001 From: smaskell-stripe <47332718+smaskell-stripe@users.noreply.github.com> Date: Mon, 1 Jun 2020 13:16:42 -0700 Subject: [PATCH] Remove PaymentMethodOptionsParams.Alipay (#2533) --- .../model/ConfirmPaymentIntentParams.kt | 17 +++++------- .../model/PaymentMethodOptionsParams.kt | 18 ------------- .../model/ConfirmPaymentIntentParamsTest.kt | 27 ------------------- 3 files changed, 7 insertions(+), 55 deletions(-) diff --git a/stripe/src/main/java/com/stripe/android/model/ConfirmPaymentIntentParams.kt b/stripe/src/main/java/com/stripe/android/model/ConfirmPaymentIntentParams.kt index 9f5c9c19db5..6b4da6a045d 100644 --- a/stripe/src/main/java/com/stripe/android/model/ConfirmPaymentIntentParams.kt +++ b/stripe/src/main/java/com/stripe/android/model/ConfirmPaymentIntentParams.kt @@ -1,6 +1,5 @@ package com.stripe.android.model -import android.content.Context import android.os.Parcelable import com.stripe.android.model.ConfirmPaymentIntentParams.SetupFutureUsage import com.stripe.android.model.ConfirmPaymentIntentParams.SetupFutureUsage.OffSession @@ -11,7 +10,6 @@ import com.stripe.android.model.ConfirmStripeIntentParams.Companion.PARAM_PAYMEN import com.stripe.android.model.ConfirmStripeIntentParams.Companion.PARAM_PAYMENT_METHOD_ID import com.stripe.android.model.ConfirmStripeIntentParams.Companion.PARAM_RETURN_URL import com.stripe.android.model.ConfirmStripeIntentParams.Companion.PARAM_USE_STRIPE_SDK -import com.stripe.android.utils.ContextUtils.packageInfo import kotlinx.android.parcel.Parcelize /** @@ -504,22 +502,21 @@ data class ConfirmPaymentIntentParams internal constructor( ) } + /** + * Create the parameters necessary for confirming a [PaymentIntent] with Alipay + * + * @param clientSecret client secret from the PaymentIntent that is to be confirmed + * @param returnUrl the URL the customer should be redirected to after the authorization + * process + */ @JvmStatic internal fun createAlipay( - context: Context, clientSecret: String, returnUrl: String ): ConfirmPaymentIntentParams { - val options = context.packageInfo?.let { - PaymentMethodOptionsParams.Alipay( - it.packageName, - it.versionName - ) - } return ConfirmPaymentIntentParams( clientSecret = clientSecret, paymentMethodCreateParams = PaymentMethodCreateParams.createAlipay(), - paymentMethodOptions = options, returnUrl = returnUrl ) } diff --git a/stripe/src/main/java/com/stripe/android/model/PaymentMethodOptionsParams.kt b/stripe/src/main/java/com/stripe/android/model/PaymentMethodOptionsParams.kt index 0f3a9e03358..d6b93d30600 100644 --- a/stripe/src/main/java/com/stripe/android/model/PaymentMethodOptionsParams.kt +++ b/stripe/src/main/java/com/stripe/android/model/PaymentMethodOptionsParams.kt @@ -39,22 +39,4 @@ sealed class PaymentMethodOptionsParams( private const val PARAM_NETWORK = "network" } } - - @Parcelize - internal data class Alipay( - val appBundleId: String, - val appVersionKey: String - ) : PaymentMethodOptionsParams(PaymentMethod.Type.Alipay) { - override fun createTypeParams(): List> { - return listOf( - PARAM_APP_BUNDLE_ID to appBundleId, - PARAM_APP_VERSION_KEY to appVersionKey - ) - } - - private companion object { - private const val PARAM_APP_BUNDLE_ID = "app_bundle_id" - private const val PARAM_APP_VERSION_KEY = "app_version_key" - } - } } diff --git a/stripe/src/test/java/com/stripe/android/model/ConfirmPaymentIntentParamsTest.kt b/stripe/src/test/java/com/stripe/android/model/ConfirmPaymentIntentParamsTest.kt index 7ef172919e0..a1f0e36ebe4 100644 --- a/stripe/src/test/java/com/stripe/android/model/ConfirmPaymentIntentParamsTest.kt +++ b/stripe/src/test/java/com/stripe/android/model/ConfirmPaymentIntentParamsTest.kt @@ -1,16 +1,8 @@ package com.stripe.android.model -import android.content.Context -import android.content.pm.PackageInfo -import android.content.pm.PackageManager import com.google.common.truth.Truth.assertThat -import com.nhaarman.mockitokotlin2.mock -import com.nhaarman.mockitokotlin2.whenever import kotlin.test.Test -import org.junit.runner.RunWith -import org.robolectric.RobolectricTestRunner -@RunWith(RobolectricTestRunner::class) class ConfirmPaymentIntentParamsTest { @Test @@ -385,20 +377,7 @@ class ConfirmPaymentIntentParamsTest { @Test fun toParamMap_withAlipay_shouldCreateExpectedMap() { - val packageInfo = PackageInfo().also { - it.packageName = "package_name" - it.versionName = "version_name" - } - val packageManager = mock().also { - whenever(it.getPackageInfo("package_name", 0)).thenReturn(packageInfo) - } - val context = mock().also { - whenever(it.packageName).thenReturn("package_name") - whenever(it.packageManager).thenReturn(packageManager) - } - assertThat(ConfirmPaymentIntentParams.createAlipay( - context, CLIENT_SECRET, RETURN_URL ).toParamMap()) @@ -406,12 +385,6 @@ class ConfirmPaymentIntentParamsTest { "client_secret" to CLIENT_SECRET, "use_stripe_sdk" to false, "return_url" to RETURN_URL, - "payment_method_options" to mapOf( - "alipay" to mapOf( - "app_bundle_id" to context.packageName, - "app_version_key" to "version_name" - ) - ), "payment_method_data" to mapOf( "type" to "alipay" )