diff --git a/CHANGELOG.md b/CHANGELOG.md index cf7d0e7937..9fac10f735 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Braintree Android SDK Release Notes +## unreleased +* PayPal + * Fix bug where `intent=order` was not being set as expected + ## 5.4.0 (2025-01-21) * PayPal diff --git a/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalPaymentIntent.kt b/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalPaymentIntent.kt index d31807afac..dc2f937819 100644 --- a/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalPaymentIntent.kt +++ b/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalPaymentIntent.kt @@ -26,7 +26,7 @@ enum class PayPalPaymentIntent(internal val stringValue: String) { @JvmStatic @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) fun fromString(string: String?): PayPalPaymentIntent? { - return PayPalPaymentIntent.values().firstOrNull { it.stringValue == string } + return entries.firstOrNull { it.stringValue.equals(string, ignoreCase = true) } } } } diff --git a/PayPal/src/test/java/com/braintreepayments/api/paypal/PayPalPaymentIntentTest.kt b/PayPal/src/test/java/com/braintreepayments/api/paypal/PayPalPaymentIntentTest.kt new file mode 100644 index 0000000000..ff0267bd4c --- /dev/null +++ b/PayPal/src/test/java/com/braintreepayments/api/paypal/PayPalPaymentIntentTest.kt @@ -0,0 +1,20 @@ +package com.braintreepayments.api.paypal + +import org.junit.Assert.assertEquals +import org.junit.Assert.assertNotEquals +import org.junit.Test + +class PayPalPaymentIntentTest { + + @Test + fun `Test PayPalPaymentIntent fromString -- accepts case insensitive strings`() { + assertEquals(PayPalPaymentIntent.ORDER, PayPalPaymentIntent.fromString("order")) + assertEquals(PayPalPaymentIntent.ORDER, PayPalPaymentIntent.fromString("Order")) + assertEquals(PayPalPaymentIntent.ORDER, PayPalPaymentIntent.fromString("ORDER")) + } + + @Test + fun `Test PayPalPaymentIntent fromString - random string fails equality`() { + assertNotEquals(PayPalPaymentIntent.ORDER, PayPalPaymentIntent.fromString("random")) + } +}