diff --git a/donations/lib/src/main/java/org/signal/donations/StripeApi.kt b/donations/lib/src/main/java/org/signal/donations/StripeApi.kt index 8abf56870..8194ac612 100644 --- a/donations/lib/src/main/java/org/signal/donations/StripeApi.kt +++ b/donations/lib/src/main/java/org/signal/donations/StripeApi.kt @@ -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)