Skip to content

Invalid response object from API #1213

@apflieger

Description

@apflieger

Version of stripe-java: 20.50.0
Version of the API: 2020-08-27
java -version

openjdk version "15" 2020-09-15
OpenJDK Runtime Environment (build 15+36-1562)
OpenJDK 64-Bit Server VM (build 15+36-1562, mixed mode, sharing)

I experience these errors since 30th of April.

I can't figure out what is causing the error since gson doesn't say much about the error. It seems that the json schema changed somewhere and the library became incompatible.
Note that this concerns only a few payments.

(I anonymized personnal data in the json)

com.stripe.exception.ApiException: Invalid response object from API: {
  "error": {
    "charge": "ch_1Ilv0tHwOwMy49kYnq6bnax5",
    "code": "card_declined",
    "decline_code": "lost_card",
    "doc_url": "https://stripe.com/docs/error-codes/card-declined",
    "message": "Your card was declined.",
    "payment_intent": {
      "id": "pi_1Ilv0tHwOwMy49kYMD531auw",
      "object": "payment_intent",
      "amount": 3000,
      "amount_capturable": 0,
      "amount_received": 0,
      "application": null,
      "application_fee_amount": null,
      "canceled_at": null,
      "cancellation_reason": null,
      "capture_method": "automatic",
      "charges": {
        "object": "list",
        "data": [
          {
            "id": "ch_1Ilv0tHwOwMy49kYnq6bnax5",
            "object": "charge",
            "amount": 3000,
            "amount_captured": 0,
            "amount_refunded": 0,
            "application": null,
            "application_fee": null,
            "application_fee_amount": null,
            "balance_transaction": null,
            "billing_details": {
              "address": {
                "city": "trappes",
                "country": "FR",
                "line1": "55 ave paul vaillant couturier ",
                "line2": null,
                "postal_code": "78190",
                "state": null
              },
              "email": null,
              "name": "xxxxx xxxxx",
              "phone": null
            },
            "calculated_statement_descriptor": "xxxxxxx",
            "captured": false,
            "created": 1619784007,
            "currency": "eur",
            "customer": "cus_IeiwsMWdZ5xKN7",
            "description": "xxxxxxxxxxxxxx",
            "destination": "acct_1CHvTHD8dOesO2oo",
            "dispute": null,
            "disputed": false,
            "failure_code": "card_declined",
            "failure_message": "Your card was declined.",
            "fraud_details": {
            },
            "invoice": null,
            "livemode": true,
            "metadata": {
              "attendance_id": "39b41396851548cebceb8a7d07b23813"
            },
            "on_behalf_of": null,
            "order": null,
            "outcome": {
              "network_status": "declined_by_network",
              "reason": "lost_card",
              "risk_level": "normal",
              "seller_message": "The bank returned the decline code `lost_card`.",
              "type": "issuer_declined"
            },
            "paid": false,
            "payment_intent": "pi_1Ilv0tHwOwMy49kYMD531auw",
            "payment_method": "pm_1IBQitHwOwMy49kYtB3QPFYY",
            "payment_method_details": {
              "card": {
                "brand": "mastercard",
                "checks": {
                  "address_line1_check": null,
                  "address_postal_code_check": null,
                  "cvc_check": null
                },
                "country": "FR",
                "exp_month": 12,
                "exp_year": 2021,
                "fingerprint": "XNwC0UFUHvSovyvt",
                "funding": "credit",
                "installments": null,
                "last4": "2010",
                "network": "cartes_bancaires",
                "three_d_secure": null,
                "wallet": null
              },
              "type": "card"
            },
            "receipt_email": "xxxxxxxxxx",
            "receipt_number": null,
            "receipt_url": null,
            "refunded": false,
            "refunds": {
              "object": "list",
              "data": [

              ],
              "has_more": false,
              "total_count": 0,
              "url": "/v1/charges/ch_1Ilv0tHwOwMy49kYnq6bnax5/refunds"
            },
            "review": null,
            "shipping": null,
            "source": null,
            "source_transfer": null,
            "statement_descriptor": null,
            "statement_descriptor_suffix": null,
            "status": "failed",
            "transfer_data": {
              "amount": 2400,
              "destination": "acct_1CHvTHD8dOesO2oo"
            },
            "transfer_group": "group_pi_1Ilv0tHwOwMy49kYMD531auw"
          }
        ],
        "has_more": false,
        "total_count": 1,
        "url": "/v1/charges?payment_intent=pi_1Ilv0tHwOwMy49kYMD531auw"
      },
      "client_secret": "pi_1Ilv0tHwOwMy49kYMD531auw_secret_yysQFCX9tlfovmOEYtCWPRQGA",
      "confirmation_method": "automatic",
      "created": 1619784007,
      "currency": "eur",
      "customer": "cus_IeiwsMWdZ5xKN7",
      "description": "xxxxxxxxxxxxx",
      "invoice": null,
      "last_payment_error": {
        "charge": "ch_1Ilv0tHwOwMy49kYnq6bnax5",
        "code": "card_declined",
        "decline_code": "lost_card",
        "doc_url": "https://stripe.com/docs/error-codes/card-declined",
        "message": "Your card was declined.",
        "payment_method": {
          "id": "pm_1IBQitHwOwMy49kYtB3QPFYY",
          "object": "payment_method",
          "billing_details": {
            "address": {
              "city": "trappes",
              "country": "FR",
              "line1": "xxxxxxx",
              "line2": null,
              "postal_code": "xxxxxx",
              "state": null
            },
            "email": null,
            "name": "xxxxxxx",
            "phone": null
          },
          "card": {
            "brand": "mastercard",
            "checks": {
              "address_line1_check": "unavailable",
              "address_postal_code_check": "unavailable",
              "cvc_check": "pass"
            },
            "country": "FR",
            "exp_month": 12,
            "exp_year": 2021,
            "fingerprint": "XNwC0UFUHvSovyvt",
            "funding": "credit",
            "generated_from": null,
            "last4": "2010",
            "networks": {
              "available": [
                "cartes_bancaires",
                "mastercard"
              ],
              "preferred": null
            },
            "three_d_secure_usage": {
              "supported": true
            },
            "wallet": null
          },
          "created": 1611087763,
          "customer": "cus_IeiwsMWdZ5xKN7",
          "livemode": true,
          "metadata": {
          },
          "type": "card"
        },
        "type": "card_error"
      },
      "livemode": true,
      "metadata": {
        "attendance_id": "39b41396851548cebceb8a7d07b23813"
      },
      "next_action": null,
      "on_behalf_of": null,
      "payment_method": null,
      "payment_method_options": {
        "card": {
          "installments": null,
          "network": null,
          "request_three_d_secure": "automatic"
        }
      },
      "payment_method_types": [
        "card"
      ],
      "receipt_email": "xxxxxxxxxx",
      "review": null,
      "setup_future_usage": null,
      "shipping": null,
      "source": null,
      "statement_descriptor": null,
      "statement_descriptor_suffix": null,
      "status": "requires_payment_method",
      "transfer_data": {
        "amount": 2400,
        "destination": "acct_1CHvTHD8dOesO2oo"
      },
      "transfer_group": null
    },
    "payment_method": {
      "id": "pm_1IBQitHwOwMy49kYtB3QPFYY",
      "object": "payment_method",
      "billing_details": {
        "address": {
          "city": "xxxxx",
          "country": "FR",
          "line1": "xxxxxx",
          "line2": null,
          "postal_code": "xxxxxx",
          "state": null
        },
        "email": null,
        "name": "xxxxxxx",
        "phone": null
      },
      "card": {
        "brand": "mastercard",
        "checks": {
          "address_line1_check": "unavailable",
          "address_postal_code_check": "unavailable",
          "cvc_check": "pass"
        },
        "country": "FR",
        "exp_month": 12,
        "exp_year": 2021,
        "fingerprint": "XNwC0UFUHvSovyvt",
        "funding": "credit",
        "generated_from": null,
        "last4": "2010",
        "networks": {
          "available": [
            "cartes_bancaires",
            "mastercard"
          ],
          "preferred": null
        },
        "three_d_secure_usage": {
          "supported": true
        },
        "wallet": null
      },
      "created": 1611087763,
      "customer": "cus_IeiwsMWdZ5xKN7",
      "livemode": true,
      "metadata": {
      },
      "type": "card"
    },
    "type": "card_error"
  }
}
. (HTTP response code was 402). Additional details: java.lang.IllegalStateException.; request-id: req_bvq5wO20IlED4y
        at com.stripe.net.LiveStripeResponseGetter.raiseMalformedJsonError(LiveStripeResponseGetter.java:123)
        at com.stripe.net.LiveStripeResponseGetter.handleApiError(LiveStripeResponseGetter.java:136)
        at com.stripe.net.LiveStripeResponseGetter.request(LiveStripeResponseGetter.java:61)
        at com.stripe.net.ApiResource.request(ApiResource.java:179)
        at com.stripe.net.ApiResource.request(ApiResource.java:169)
        at com.stripe.model.PaymentIntent.create(PaymentIntent.java:497)
        at com.stripe.model.PaymentIntent.create(PaymentIntent.java:478)
        at com.meetinclass.services.StripeService.customerDestinationCharge(StripeService.java:189)
        at com.meetinclass.services.BillingService.lambda$perform$11(BillingService.java:173)
        at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1800)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
        at java.base/java.lang.Thread.run(Thread.java:832)
Caused by: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:226)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:131)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:222)
        at com.google.gson.Gson.fromJson(Gson.java:932)
        at com.google.gson.Gson.fromJson(Gson.java:1003)
        at com.google.gson.Gson.fromJson(Gson.java:975)
        at com.stripe.net.LiveStripeResponseGetter.handleApiError(LiveStripeResponseGetter.java:134)
        ... 11 common frames omitted
Caused by: java.lang.IllegalStateException: null
        at com.google.gson.Gson$FutureTypeAdapter.read(Gson.java:1018)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:131)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:222)
        ... 17 common frames omitted

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions