Viincenttt / MollieApi

This project allows you to easily add the Mollie payment provider to your application.
MIT License
150 stars 85 forks source link

GetPaymentListAsync Cannot deserialize the current JSON #388

Open baer999 opened 3 months ago

baer999 commented 3 months ago

Hello,

Using newest version (4.3.0) of the Mollie.API library. I've got an error while downloading via PaymentClient | GetPaymentListAsync:

image

Newtonsoft.Json.JsonSerializationException: "Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'Mollie.Api.Models.Payment.PaymentAddressDetails' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly. To fix this error either change the JSON to a JSON object (e.g. {"name":"value"}) or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List<T> that can be deserialized from a JSON array. JsonArrayAttribute can also be added to the type to force it to deserialize from a JSON array. Path 'shippingAddress', line 1, position 28949."

Seems to be JSON Data Type problem, is there anything I can do to fix it?

Kind Regards, Andreas

Viincenttt commented 2 months ago

Hi @baer999 ,

Could you show me the exact JSON that the Mollie API returns for this API call? Then I should be able to reproduce this issue in a unit/integration test. Feel free to redact any sensitive information

Kind regards, Vincent

baer999 commented 2 months ago

Hi Viincentt, i "fixed" it if I don't load too old data (think the API send other format in very old data units). So for me it is not a problem any more in case when loading just last few months and not any more. Think we can close the issue here from my side.

Kind regards, Andreas

thoemy commented 1 month ago

I have the same problem with a payment embedded in a refund. So far I have not yet discovered a pattern.

The problematic JSON is

{
            "shippingAddress": [],
            "billingAddress": [],
}

Full JSON response.

{
  "_embedded": {
    "refunds": [
      {
        "resource": "refund",
        "id": "re_7U3xxxx",
        "amount": {
          "value": "34.95",
          "currency": "EUR"
        },
        "status": "refunded",
        "createdAt": "2024-06-21T07:19:30+00:00",
        "description": "nYUMXiX2hCxxxxxxxxxxx",
        "metadata": {
          "shopify_refund_id": "iStyjYM9zxxxxxxx"
        },
        "paymentId": "tr_2Rxxx",
        "settlementId": "stl_xxxx",
        "settlementAmount": {
          "value": "-34.95",
          "currency": "EUR"
        },
        "_embedded": {
          "payment": {
            "resource": "payment",
            "id": "tr_2Rxxx",
            "mode": "live",
            "createdAt": "2024-06-10T11:38:31+00:00",
            "amount": {
              "value": "39.90",
              "currency": "EUR"
            },
            "description": "nYUMXiXxxxxxxxxxxx",
            "method": "creditcard",
            "metadata": {
              "origin_domain": "xxxx",
              "shopify_payment_id": "nYUMXiXxxxxxxxxxx"
            },
            "status": "paid",
            "paidAt": "2024-06-10T11:40:05+00:00",
            "amountRefunded": {
              "value": "34.95",
              "currency": "EUR"
            },
            "amountRemaining": {
              "value": "4.95",
              "currency": "EUR"
            },
            "locale": "de_DE",
            "countryCode": "DE",
            "profileId": "pfl_VKxxxx",
            "settlementId": "stl_57nxxx",
            "sequenceType": "oneoff",
            "redirectUrl": "",
            "cancelUrl": "",
            "webhookUrl": "",
            "settlementAmount": {
              "value": "39.90",
              "currency": "EUR"
            },
            "shippingAddress": [],
            "billingAddress": [],
            "details": {
              "cardToken": "tkn_xxx",
              "cardFingerprint": "xxx",
              "cardNumber": "3000",
              "cardHolder": "xxxx",
              "cardAudience": "consumer",
              "cardLabel": "American Express",
              "cardCountryCode": "DE",
              "cardSecurity": "3dsecure",
              "feeRegion": "amex-intra-eea"
            },
            "_links": {
              "self": {
                "href": "https://api.mollie.com/v2/payments/tr_2Rxxx",
                "type": "application/hal+json"
              },
              "dashboard": {
                "href": "https://my.mollie.com/dashboard/org_xxxx/payments/tr_2Rxxx",
                "type": "text/html"
              },
              "settlement": {
                "href": "https://api.mollie.com/v2/settlements/stl_57nxxx",
                "type": "application/hal+json"
              },
              "refunds": {
                "href": "https://api.mollie.com/v2/payments/tr_2Rxxx/refunds",
                "type": "application/hal+json"
              }
            }
          }
        },
        "_links": {
          "self": {
            "href": "https://api.mollie.com/v2/payments/tr_2Rxxx/refunds/re_7U3xxxx",
            "type": "application/hal+json"
          },
          "payment": {
            "href": "https://api.mollie.com/v2/payments/tr_2Rxxx",
            "type": "application/hal+json"
          },
          "settlement": {
            "href": "https://api.mollie.com/v2/settlements/stl_xxxx",
            "type": "application/hal+json"
          }
        }
      }
    ]
  },
  "count": 1,
  "_links": {
    "documentation": {
      "href": "https://docs.mollie.com/reference/v2/settlements-api/list-settlement-refunds",
      "type": "text/html"
    },
    "self": {
      "href": "https://api.mollie.com/v2/settlements/stl_xxxx/refunds?embed=payment\u0026limit=250",
      "type": "application/hal+json"
    },
    "previous": null,
    "next": null
  }
}
Viincenttt commented 1 month ago

Hi Thoemy,

Strange that the billing/shipping address properties are arrays instead of objects. I'd like to contact Mollie regarding this and it helps if I can share the Mollie payment id with them. Would you be willing to share that?

You can also send it to me on LinkedIn if you don't want to share it here. My LinkedIn profile is mentioned in the readme.md.

Kind regards, Vincent

joosttk commented 2 weeks ago

@thoemy I tried to reproduce the behaviour, but for me it does not return the billingAddress and shippingAddress if it was not provided.

Can you let me know exactly what steps you took that got to this response from our API?