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

Fix order intent use-case #1258

Merged
merged 5 commits into from
Jan 22, 2025
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
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"))
}
}
Loading