Skip to content

Commit

Permalink
Fix os_version and enablePayPalAppSwitch (#1162)
Browse files Browse the repository at this point in the history
* Convert version sdk to string

* Fix ut

* Change SDK int to release version

* Fix validation: We need to check if the feature is enabled in settings to avoid overwriting the variable.

* Revert version Release to SDK int and cast it to string
  • Loading branch information
richherrera authored Sep 23, 2024
1 parent 2b7ff74 commit 75e34a8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "[email protected]";
PayPalVaultRequest request = new PayPalVaultRequest(true);

Expand All @@ -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\""));
}
}

0 comments on commit 75e34a8

Please sign in to comment.