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

Updating Android Native Checkout Version to 1.2.0 #214

Merged
merged 13 commits into from
Nov 17, 2023
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# PayPal Android SDK Release Notes

## unreleased

* PayPalNativeCheckout
* Bump native-checkout version to release `1.2.0`
* Add `userAuthenticationEmail` to `PayPalNativeCheckoutRequest`

## 1.0.0 (2023-10-02)

* Breaking Changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.paypal.android.corepayments.analytics.AnalyticsService
import com.paypal.checkout.PayPalCheckout
import com.paypal.checkout.approve.OnApprove
import com.paypal.checkout.cancel.OnCancel
import com.paypal.checkout.config.AuthConfig
import com.paypal.checkout.config.CheckoutConfig
import com.paypal.checkout.config.UIConfig
import com.paypal.checkout.createorder.CreateOrder
Expand Down Expand Up @@ -44,12 +45,12 @@ class PayPalNativeCheckoutClient internal constructor(
* See Also: [Developer Portal](https://developer.paypal.com/developer/applications/)
*/
constructor(application: Application, coreConfig: CoreConfig, returnUrl: String) :
this(
application,
coreConfig,
returnUrl,
AnalyticsService(application, coreConfig),
)
this(
application,
coreConfig,
returnUrl,
AnalyticsService(application, coreConfig),
)

private val exceptionHandler = CoreCoroutineExceptionHandler {
listener?.onPayPalCheckoutFailure(it)
Expand All @@ -74,7 +75,7 @@ class PayPalNativeCheckoutClient internal constructor(
var shippingListener: PayPalNativeShippingListener? = null

/**
* Present a Paypal Payseet and start a PayPal transaction.
* Present a Paypal Paysheet and start a PayPal transaction.
*
* @param request the PayPalNativeCheckoutRequest for the transaction
*/
Expand All @@ -83,14 +84,16 @@ class PayPalNativeCheckoutClient internal constructor(
orderId = request.orderId
CoroutineScope(dispatcher).launch(exceptionHandler) {
try {
val authConfig: AuthConfig? = request.userAuthenticationEmail?.let { AuthConfig(it) }
val config = CheckoutConfig(
application = application,
clientId = coreConfig.clientId,
environment = getPayPalEnvironment(coreConfig.environment),
uiConfig = UIConfig(
showExitSurveyDialog = false
),
returnUrl = returnUrl
returnUrl = returnUrl,
authConfig = authConfig
)
PayPalCheckout.setConfig(config)
listener?.onPayPalCheckoutStart()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,11 @@ data class PayPalNativeCheckoutRequest(
/**
* The order ID associated with the request.
*/
val orderId: String
val orderId: String,

/**
* 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
)
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,15 @@ class PayPalNativeCheckoutClientTest {
} just runs

sut = getPayPalCheckoutClient(testScheduler = testScheduler)
sut.startCheckout(PayPalNativeCheckoutRequest("order_id"))
sut.startCheckout(PayPalNativeCheckoutRequest("order_id", "test@test.com"))
advanceUntilIdle()

verify {
PayPalCheckout.setConfig(any())
}
expectThat(configSlot.captured) {
get { clientId }.isEqualTo("fake-client-id")
get { authConfig?.userEmail }.isEqualTo("test@test.com")
get { application }.isEqualTo(mockApplication)
get { environment }.isEqualTo(com.paypal.checkout.config.Environment.SANDBOX)
}
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ buildscript {
"json" : "org.json:json:20220320",

// PayPal
"nativeCheckout" : "com.paypal.checkout:android-sdk:1.1.0",
"nativeCheckout" : "com.paypal.checkout:android-sdk:1.2.0",

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