diff --git a/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalInternalClient.kt b/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalInternalClient.kt index 07564ca467..ff1616de41 100644 --- a/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalInternalClient.kt +++ b/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalInternalClient.kt @@ -44,8 +44,8 @@ internal class PayPalInternalClient( val url = "/v1/$endpoint" val appLinkReturn = if (isBillingAgreement) appLink else null - if (isBillingAgreement) { - (payPalRequest as PayPalVaultRequest).enablePayPalAppSwitch = isPayPalInstalled(context) + if (isBillingAgreement && (payPalRequest as PayPalVaultRequest).enablePayPalAppSwitch) { + payPalRequest.enablePayPalAppSwitch = isPayPalInstalled(context) } val requestBody = payPalRequest.createRequestBody( diff --git a/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalVaultRequest.kt b/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalVaultRequest.kt index fc875a8f0e..140a31dd43 100644 --- a/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalVaultRequest.kt +++ b/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalVaultRequest.kt @@ -89,7 +89,7 @@ class PayPalVaultRequest if (enablePayPalAppSwitch && !appLink.isNullOrEmpty() && !userAuthenticationEmail.isNullOrEmpty()) { parameters.put(ENABLE_APP_SWITCH_KEY, enablePayPalAppSwitch) - parameters.put(OS_VERSION_KEY, Build.VERSION.SDK_INT) + parameters.put(OS_VERSION_KEY, Build.VERSION.SDK_INT.toString()) parameters.put(OS_TYPE_KEY, "Android") parameters.put(MERCHANT_APP_RETURN_URL_KEY, appLink) } diff --git a/PayPal/src/test/java/com/braintreepayments/api/paypal/PayPalVaultRequestUnitTest.java b/PayPal/src/test/java/com/braintreepayments/api/paypal/PayPalVaultRequestUnitTest.java index 2607c98efc..04a0cd475f 100644 --- a/PayPal/src/test/java/com/braintreepayments/api/paypal/PayPalVaultRequestUnitTest.java +++ b/PayPal/src/test/java/com/braintreepayments/api/paypal/PayPalVaultRequestUnitTest.java @@ -123,7 +123,7 @@ public void createRequestBody_sets_userAuthenticationEmail_when_not_null() throw @Test public void createRequestBody_sets_enablePayPalSwitch_and_userAuthenticationEmail_not_null() throws JSONException { - int versionSDK = Build.VERSION.SDK_INT; + String versionSDK = String.valueOf(Build.VERSION.SDK_INT); String payerEmail = "payer_email@example.com"; PayPalVaultRequest request = new PayPalVaultRequest(true); @@ -139,7 +139,7 @@ public void createRequestBody_sets_enablePayPalSwitch_and_userAuthenticationEmai assertTrue(requestBody.contains("\"launch_paypal_app\":true")); assertTrue(requestBody.contains("\"os_type\":" + "\"Android\"")); - assertTrue(requestBody.contains("\"os_version\":" + versionSDK)); + assertTrue(requestBody.contains("\"os_version\":" + "\"" + versionSDK + "\"")); assertTrue(requestBody.contains("\"merchant_app_return_url\":" + "\"universal_url\"")); } }