Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google Play store compliance fix #252

Merged
merged 6 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@
* Add `CardAuthChallenge` type
* FraudDetection
* Fixes Google Play Store Rejection
* Bump Magnes version to 5.5.0
* Bump Magnes version to 5.5.1
* Create `PayPalDataCollectorRequest`
* Add `PayPalDataCollector#collectDeviceData(context, request)`
* Deprecate `PayPalDataCollector#collectDeviceData(context, clientMetadataId, additionalData)`
* PayPalNativePayments
* Fixes Google Play Store Rejection
* Bump Native Checkout version to 1.3.2
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: same comment as below

Suggested change
* Bump Native Checkout version to 1.3.2
* Bump Native Checkout version to 1.3.0

* Add `hasUserLocationConsent` to `PayPalNativeCheckoutRequest`
* PaymentButtons
* Update font typeface to "PayPalOpen" to meet brand guidelines

Expand Down
2 changes: 1 addition & 1 deletion FraudProtection/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ android {
}

dependencies {
implementation files('libs/android-magnessdk-5.5.0.jar')
implementation files('libs/android-magnessdk-5.5.1.jar')

api project(':CorePayments')
implementation deps.kotlinStdLib
Expand Down
Binary file removed FraudProtection/libs/android-magnessdk-5.5.0.jar
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.paypal.android.fraudprotection

import com.paypal.android.corepayments.CoreConfig
import lib.android.paypal.com.magnessdk.Environment
import lib.android.com.paypal.magnessdk.Environment

internal val CoreConfig.magnesEnvironment: Environment
get() = when (environment) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package com.paypal.android.fraudprotection
import android.content.Context
import android.util.Log
import com.paypal.android.corepayments.CoreConfig
import lib.android.paypal.com.magnessdk.InvalidInputException
import lib.android.paypal.com.magnessdk.MagnesSDK
import lib.android.paypal.com.magnessdk.MagnesSettings
import lib.android.paypal.com.magnessdk.MagnesSource
import lib.android.com.paypal.magnessdk.InvalidInputException
import lib.android.com.paypal.magnessdk.MagnesSDK
import lib.android.com.paypal.magnessdk.MagnesSettings
import lib.android.com.paypal.magnessdk.MagnesSource

/**
* Enables you to collect data about a customer's device and correlate it with a session identifier on your server.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import io.mockk.mockk
import io.mockk.mockkStatic
import io.mockk.slot
import io.mockk.verify
import lib.android.paypal.com.magnessdk.InvalidInputException
import lib.android.paypal.com.magnessdk.MagnesResult
import lib.android.paypal.com.magnessdk.MagnesSDK
import lib.android.paypal.com.magnessdk.MagnesSettings
import lib.android.paypal.com.magnessdk.MagnesSource
import lib.android.com.paypal.magnessdk.InvalidInputException
import lib.android.com.paypal.magnessdk.MagnesResult
import lib.android.com.paypal.magnessdk.MagnesSDK
import lib.android.com.paypal.magnessdk.MagnesSettings
import lib.android.com.paypal.magnessdk.MagnesSource
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
Expand Down Expand Up @@ -48,7 +48,7 @@ class PayPalDataCollectorUnitTest {
val magnesSettings = magnesSettingsSlot.captured
assertEquals(
magnesSettings.environment,
lib.android.paypal.com.magnessdk.Environment.SANDBOX
lib.android.com.paypal.magnessdk.Environment.SANDBOX
)
assertFalse(magnesSettings.isDisableBeacon)
assertEquals(magnesSettings.appGuid, appGUID)
Expand All @@ -70,7 +70,7 @@ class PayPalDataCollectorUnitTest {
verify { mockMagnesSDK.setUp(capture(magnesSettingsSlot)) }

val magnesSettings = magnesSettingsSlot.captured
assertEquals(magnesSettings.environment, lib.android.paypal.com.magnessdk.Environment.LIVE)
assertEquals(magnesSettings.environment, lib.android.com.paypal.magnessdk.Environment.LIVE)
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,12 @@ class PayPalNativeCheckoutClient internal constructor(
)
PayPalCheckout.setConfig(config)
listener?.onPayPalCheckoutStart()
PayPalCheckout.startCheckout(CreateOrder {
it.set(request.orderId)
})
PayPalCheckout.startCheckout(
createOrder = CreateOrder {
it.set(request.orderId)
},
hasUserLocationConsent = request.hasUserLocationConsent
)
} catch (e: PayPalSDKError) {
listener?.onPayPalCheckoutFailure(
APIClientError.clientIDNotFoundError(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,14 @@ data class PayPalNativeCheckoutRequest(
* Optional: User email to initiate a quicker authentication flow
* in cases where the user has a PayPal Account with the same email.
*/
val userAuthenticationEmail: String? = null
val userAuthenticationEmail: String? = null,

/**
* @property [hasUserLocationConsent] informs the SDK if your application has obtained
* consent from the user to collect location data in compliance with
* <a href="https://support.google.com/googleplay/android-developer/answer/10144311#personal-sensitive">
* Google Play Developer Program policies</a>
* This flag enables PayPal to collect necessary information required for Fraud Detection and Risk Management.
*/
val hasUserLocationConsent: Boolean = false
tdchow marked this conversation as resolved.
Show resolved Hide resolved
)
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import io.mockk.slot
import io.mockk.spyk
import io.mockk.unmockkAll
import io.mockk.verify
import java.lang.reflect.Field
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.test.StandardTestDispatcher
Expand All @@ -40,7 +41,7 @@ import org.junit.Before
import org.junit.Test
import strikt.api.expectThat
import strikt.assertions.isEqualTo
import java.lang.reflect.Field
import strikt.assertions.isTrue

@ExperimentalCoroutinesApi
class PayPalNativeCheckoutClientTest {
Expand Down Expand Up @@ -88,6 +89,27 @@ class PayPalNativeCheckoutClientTest {
}
}

@Test
fun `when user location consent is set, startCheckout is called with the user location consent set`() =
runTest {
val userLocationConsentSlot = slot<Boolean>()
every {
PayPalCheckout.startCheckout(any(), capture(userLocationConsentSlot))
} answers { userLocationConsentSlot.captured }

sut = getPayPalCheckoutClient(testScheduler = testScheduler)
sut.startCheckout(
PayPalNativeCheckoutRequest(
"order_id",
"[email protected]",
true
)
)
advanceUntilIdle()

expectThat(userLocationConsentSlot.captured).isTrue()
}

@Test
fun `when startCheckout is invoked with an invalid return_url, onPayPalCheckout failure is called`() =
runTest {
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ buildscript {
"json" : "org.json:json:20220320",

// PayPal
"nativeCheckout" : "com.paypal.checkout:android-sdk:1.2.1",
"nativeCheckout" : "com.paypal.checkout:android-sdk:1.3.2",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

qq here - should this be version 1.3.0, that's the latest release i'm seeing here

Suggested change
"nativeCheckout" : "com.paypal.checkout:android-sdk:1.3.2",
"nativeCheckout" : "com.paypal.checkout:android-sdk:1.3.0",

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm.. great catch.
I feel the latest version might not have been tagged in the releases.

@tdchow please correct me if I'm wrong, but I believe 1.3.2 is the latest that we had to consume, correct?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, it looks like the latest versions have not been tagged in the GitHub releases. The correct version to use is 1.3.2.

https://repo1.maven.org/maven2/com/paypal/checkout/android-sdk/1.3.2/


// Release modules
"cardPayments" : "com.paypal.android:card-payments:${modules.sdkVersionName}",
Expand Down
Loading