Skip to content

Commit

Permalink
Merge branch 'main' into contact-information-feature
Browse files Browse the repository at this point in the history
  • Loading branch information
richherrera committed Jan 22, 2025
2 parents 5c20a33 + 3816fe1 commit 5155b50
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* PayPal
* Add `PayPalContactInformation` request object
* Add `PayPalCheckoutRequest.contactInformation` optional property
* Fix bug where `intent=order` was not being set as expected

## 5.4.0 (2025-01-21)

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 5155b50

Please sign in to comment.