Giter VIP home page Giter VIP logo

Comments (9)

lgoudriaan avatar lgoudriaan commented on May 26, 2024

I've just tried to reproduce this, without result. Is this issue already resolved?

from mollieapi.

jeanpaulmars avatar jeanpaulmars commented on May 26, 2024

I get the exact same error message. I've checked using fiddler to see what happens and this is what happens:

I send the following:
POST https://api.mollie.nl/v1/payments HTTP/1.1
Accept: application/json
Authorization: Bearer test_Cz8AWxeg3ywp9EAxAAAy**********
Content-Type: application/json; charset=utf-8
Host: api.mollie.nl
Content-Length: 267
Expect: 100-continue

{"amount":0.9900,"description":"Verificatie","redirectUrl":"http://localhost:57216/Boeken/VerificatiePending?OrderNummer=RB2017.011762","method":"ideal","metadata":RB2017.011762,"webhookUrl":"https://www.MYSITE.COM/","locale":"nl_NL","customerId":"cst_hbwRmfhs36"}

and I get the following response from mollie:
HTTP/1.1 415 Unsupported Media Type
Server: nginx
Date: Tue, 28 Nov 2017 10:05:42 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 126
Content-Security-Policy: frame-ancestors 'none'
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: GET, POST, HEAD, OPTIONS, DELETE
Access-Control-Max-Age: 300
Strict-Transport-Security: max-age=15552000; includeSubDomains

{"error":{"type":"request","message":"Unsupported input received","links":{"documentation":"https://www.mollie.com/en/docs"}}}

According to the documentation, error 415 usually happenes when you don't send your post in UTF-8. As you can see in the traffic, the charset is UTF-8, as it should be.

I've asked mollie for a response as well, but no response there yet.

update: I noticed the metadata was invalid json. in the past this was accepted, but if I send again, without the metadata, it get processed by mollie.
Nonetheless: some error handling needs to be done better, I think.

from mollieapi.

lgoudriaan avatar lgoudriaan commented on May 26, 2024

Hi @jeanpaulmars,

Can you try the same request without metadata?
The value of the metadata isn't valid json, so maybe that's the problem.

from mollieapi.

jeanpaulmars avatar jeanpaulmars commented on May 26, 2024

When I leave the metadata empty/null it works correctly. Is is possible to have CreatePaymentAsync throw an exception if it encounters problems a problem with the input (such as invalid json) instead of passing it on towards the api of mollie?
(An exception stating "Unable to parse metadata field" is much more helpful while debugging then the response from mollie "unsupported input received".)

from mollieapi.

lgoudriaan avatar lgoudriaan commented on May 26, 2024

Guess we have found a bug ;)
I will try to fix this tonight in a PR.

from mollieapi.

lgoudriaan avatar lgoudriaan commented on May 26, 2024

@jeanpaulmars, @NicoJuicy I found out after looking deeper into this that you can set metadata only directly with an JSON string.

If you just want to pass an extra id use the SetMetaData method. And Getmetadata() to retreive.

@Viincenttt maybe set the metadata property to private?

from mollieapi.

jeanpaulmars avatar jeanpaulmars commented on May 26, 2024

Or a string getter/setter which stores it internally in a json? I really prefer to be able to make a single call without being forced to call a separate SetMetaData() function. (So I can use it the same way as @NicoJuicy describes in his first message.

from mollieapi.

Viincenttt avatar Viincenttt commented on May 26, 2024

I'm not sure if I understand the problem. The Metadata property on a PaymentRequest is a string, so you can pass a JSON string to the mollie API. To make it easier to serialize/deserialize your own classes to a JSON format, I have added the Get/Set metadata functions.

Use the Metadata property if you want to set the JSON string manually. Use the Set/GetMetadata method if you want built-in serialization of complex objects. The Metadata property has been in this library since the beginning and has always been a string JSON value. Due to backwards compatability I can't just start serializing and deserializing values in the getter and setter of this property, since this might break people's implementation of this library.

This library doesn't validate any data you send to the Mollie API. It is up to the Mollie API to validate your data and send back any errors. If the error Mollie gives you isn't clear enough, please contact Mollie and provide them with your feedback.

from mollieapi.

jeanpaulmars avatar jeanpaulmars commented on May 26, 2024

Then I guess mollie made some changes to their code that they are now more strict with regard to the metadata field than before. Since MollieApi doesn't do any error checking, the solution lies in adding correct json as metadata.
For me: Issue resolved, but I'm not the original creator of this issue :)

from mollieapi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.