Fix bad use of toString in StripeApi.
This commit is contained in:
parent
556dc0d1ec
commit
e58cea9a26
1 changed files with 2 additions and 7 deletions
|
@ -120,7 +120,7 @@ class StripeApi(
|
|||
if (response.isSuccessful) {
|
||||
return response
|
||||
} else {
|
||||
val body = response.body()?.toString()
|
||||
val body = response.body()?.string()
|
||||
throw StripeError.PostError(
|
||||
response.code(),
|
||||
parseErrorCode(body),
|
||||
|
@ -150,12 +150,7 @@ class StripeApi(
|
|||
}
|
||||
|
||||
return try {
|
||||
val jsonBody = JSONObject(body)
|
||||
Log.d(TAG, "parseDeclineCode: Parsed body with keys: ${jsonBody.keys().asSequence().joinToString(", ")}")
|
||||
val jsonError = jsonBody.getJSONObject("error")
|
||||
Log.d(TAG, "parseDeclineCode: Parsed error with keys: ${jsonError.keys().asSequence().joinToString(", ")}")
|
||||
|
||||
StripeDeclineCode.getFromCode(jsonError.getString("decline_code"))
|
||||
StripeDeclineCode.getFromCode(JSONObject(body).getJSONObject("error").getString("decline_code"))
|
||||
} catch (e: Exception) {
|
||||
Log.d(TAG, "parseDeclineCode: Failed to parse decline code.", e, true)
|
||||
null
|
||||
|
|
Loading…
Add table
Reference in a new issue