mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-15 07:28:30 +00:00
Fix Stripe json body error handling.
This commit is contained in:
@@ -131,11 +131,12 @@ class StripeApi(
|
||||
fun getSetupIntent(stripeIntentAccessor: StripeIntentAccessor): StripeSetupIntent {
|
||||
return when (stripeIntentAccessor.objectType) {
|
||||
StripeIntentAccessor.ObjectType.SETUP_INTENT -> get("setup_intents/${stripeIntentAccessor.intentId}?client_secret=${stripeIntentAccessor.intentClientSecret}").use {
|
||||
val body = it.body()?.string()
|
||||
try {
|
||||
objectMapper.readValue(it.body()!!.string())
|
||||
objectMapper.readValue(body!!)
|
||||
} catch (e: InvalidDefinitionException) {
|
||||
Log.w(TAG, "Failed to parse JSON for StripeSetupIntent.")
|
||||
ResponseFieldLogger.logFields(objectMapper, it.body()?.string())
|
||||
ResponseFieldLogger.logFields(objectMapper, body)
|
||||
throw StripeError.FailedToParseSetupIntentResponseError(e)
|
||||
} catch (e: Exception) {
|
||||
Log.w(TAG, "Failed to read value from JSON.", e, true)
|
||||
@@ -152,11 +153,12 @@ class StripeApi(
|
||||
fun getPaymentIntent(stripeIntentAccessor: StripeIntentAccessor): StripePaymentIntent {
|
||||
return when (stripeIntentAccessor.objectType) {
|
||||
StripeIntentAccessor.ObjectType.PAYMENT_INTENT -> get("payment_intents/${stripeIntentAccessor.intentId}?client_secret=${stripeIntentAccessor.intentClientSecret}").use {
|
||||
val body = it.body()?.string()
|
||||
try {
|
||||
objectMapper.readValue(it.body()!!.string())
|
||||
objectMapper.readValue(body!!)
|
||||
} catch (e: InvalidDefinitionException) {
|
||||
Log.w(TAG, "Failed to parse JSON for StripePaymentIntent.")
|
||||
ResponseFieldLogger.logFields(objectMapper, it.body()?.string())
|
||||
ResponseFieldLogger.logFields(objectMapper, body)
|
||||
throw StripeError.FailedToParsePaymentIntentResponseError(e)
|
||||
} catch (e: Exception) {
|
||||
Log.w(TAG, "Failed to read value from JSON.", e, true)
|
||||
|
||||
Reference in New Issue
Block a user