Fix Stripe json body error handling.
This commit is contained in:
parent
aa9a530e59
commit
71ff31e91f
1 changed files with 6 additions and 4 deletions
|
@ -131,11 +131,12 @@ class StripeApi(
|
||||||
fun getSetupIntent(stripeIntentAccessor: StripeIntentAccessor): StripeSetupIntent {
|
fun getSetupIntent(stripeIntentAccessor: StripeIntentAccessor): StripeSetupIntent {
|
||||||
return when (stripeIntentAccessor.objectType) {
|
return when (stripeIntentAccessor.objectType) {
|
||||||
StripeIntentAccessor.ObjectType.SETUP_INTENT -> get("setup_intents/${stripeIntentAccessor.intentId}?client_secret=${stripeIntentAccessor.intentClientSecret}").use {
|
StripeIntentAccessor.ObjectType.SETUP_INTENT -> get("setup_intents/${stripeIntentAccessor.intentId}?client_secret=${stripeIntentAccessor.intentClientSecret}").use {
|
||||||
|
val body = it.body()?.string()
|
||||||
try {
|
try {
|
||||||
objectMapper.readValue(it.body()!!.string())
|
objectMapper.readValue(body!!)
|
||||||
} catch (e: InvalidDefinitionException) {
|
} catch (e: InvalidDefinitionException) {
|
||||||
Log.w(TAG, "Failed to parse JSON for StripeSetupIntent.")
|
Log.w(TAG, "Failed to parse JSON for StripeSetupIntent.")
|
||||||
ResponseFieldLogger.logFields(objectMapper, it.body()?.string())
|
ResponseFieldLogger.logFields(objectMapper, body)
|
||||||
throw StripeError.FailedToParseSetupIntentResponseError(e)
|
throw StripeError.FailedToParseSetupIntentResponseError(e)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.w(TAG, "Failed to read value from JSON.", e, true)
|
Log.w(TAG, "Failed to read value from JSON.", e, true)
|
||||||
|
@ -152,11 +153,12 @@ class StripeApi(
|
||||||
fun getPaymentIntent(stripeIntentAccessor: StripeIntentAccessor): StripePaymentIntent {
|
fun getPaymentIntent(stripeIntentAccessor: StripeIntentAccessor): StripePaymentIntent {
|
||||||
return when (stripeIntentAccessor.objectType) {
|
return when (stripeIntentAccessor.objectType) {
|
||||||
StripeIntentAccessor.ObjectType.PAYMENT_INTENT -> get("payment_intents/${stripeIntentAccessor.intentId}?client_secret=${stripeIntentAccessor.intentClientSecret}").use {
|
StripeIntentAccessor.ObjectType.PAYMENT_INTENT -> get("payment_intents/${stripeIntentAccessor.intentId}?client_secret=${stripeIntentAccessor.intentClientSecret}").use {
|
||||||
|
val body = it.body()?.string()
|
||||||
try {
|
try {
|
||||||
objectMapper.readValue(it.body()!!.string())
|
objectMapper.readValue(body!!)
|
||||||
} catch (e: InvalidDefinitionException) {
|
} catch (e: InvalidDefinitionException) {
|
||||||
Log.w(TAG, "Failed to parse JSON for StripePaymentIntent.")
|
Log.w(TAG, "Failed to parse JSON for StripePaymentIntent.")
|
||||||
ResponseFieldLogger.logFields(objectMapper, it.body()?.string())
|
ResponseFieldLogger.logFields(objectMapper, body)
|
||||||
throw StripeError.FailedToParsePaymentIntentResponseError(e)
|
throw StripeError.FailedToParsePaymentIntentResponseError(e)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.w(TAG, "Failed to read value from JSON.", e, true)
|
Log.w(TAG, "Failed to read value from JSON.", e, true)
|
||||||
|
|
Loading…
Add table
Reference in a new issue