Skip to content

Commit

Permalink
Fix order intent use-case (#1258)
Browse files Browse the repository at this point in the history
* Ignore case when checking equality

* Update CHANGELOG.md

Co-authored-by: Jax DesMarais-Leder <jdesmarais@paypal.com>

---------

Co-authored-by: Jax DesMarais-Leder <jdesmarais@paypal.com>
  • Loading branch information
saperi22 and jaxdesmarais authored Jan 22, 2025
1 parent f8c1635 commit 3816fe1
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
}
}
}
Original file line number Diff line number Diff line change
@@ -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"))
}
}

0 comments on commit 3816fe1

Please sign in to comment.