Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mollieClient.methods.all with params #137

Closed
depsimon opened this issue Mar 30, 2020 · 2 comments
Closed

mollieClient.methods.all with params #137

depsimon opened this issue Mar 30, 2020 · 2 comments

Comments

@depsimon
Copy link

depsimon commented Mar 30, 2020

I've been trying to send params to the mollieClient.methods.all method but they don't seem to be applied and after verification it doesn't match the REST API's response.

I tried both these versions :

"@mollie/api-client": "^3.1.0"
"@mollie/api-client": "^3.0.0-beta.1"

Here's the code :

const mollieClient = createMollieClient({ apiKey: process.env.MOLLIE_API_KEY })
const methods = await mollieClient.methods.all({
  locale: 'nl_BE',
  amount: {
    value: '555555.00',
    currency: 'EUR'
  }
})

Response I get :

{
    "data": [{
        "id": "creditcard",
        "resource": "method",
        "description": "Credit card",
        "image": {
            "size1x": "https://www.mollie.com/external/icons/payment-methods/creditcard.png",
            "size2x": "https://www.mollie.com/external/icons/payment-methods/creditcard%402x.png",
            "svg": "https://www.mollie.com/external/icons/payment-methods/creditcard.svg"
        },
        "_links": {
            "self": {
                "href": "https://api.mollie.com/v2/methods/creditcard",
                "type": "application/hal+json"
            }
        },
        "minimumAmount": {
            "value": "0.01",
            "currency": "EUR"
        },
        "maximumAmount": {
            "value": "200.00",
            "currency": "EUR"
        }
    }, {
        "id": "bancontact",
        "resource": "method",
        "description": "Bancontact",
        "image": {
            "size1x": "https://www.mollie.com/external/icons/payment-methods/bancontact.png",
            "size2x": "https://www.mollie.com/external/icons/payment-methods/bancontact%402x.png",
            "svg": "https://www.mollie.com/external/icons/payment-methods/bancontact.svg"
        },
        "_links": {
            "self": {
                "href": "https://api.mollie.com/v2/methods/bancontact",
                "type": "application/hal+json"
            }
        },
        "minimumAmount": {
            "value": "0.02",
            "currency": "EUR"
        },
        "maximumAmount": {
            "value": "50000.00",
            "currency": "EUR"
        }
    }, {
        "id": "kbc",
        "resource": "method",
        "description": "KBC/CBC Payment Button",
        "image": {
            "size1x": "https://www.mollie.com/external/icons/payment-methods/kbc.png",
            "size2x": "https://www.mollie.com/external/icons/payment-methods/kbc%402x.png",
            "svg": "https://www.mollie.com/external/icons/payment-methods/kbc.svg"
        },
        "_links": {
            "self": {
                "href": "https://api.mollie.com/v2/methods/kbc",
                "type": "application/hal+json"
            }
        },
        "minimumAmount": {
            "value": "0.01",
            "currency": "EUR"
        },
        "maximumAmount": {
            "value": "50000.00",
            "currency": "EUR"
        }
    }, {
        "id": "belfius",
        "resource": "method",
        "description": "Belfius Pay Button",
        "image": {
            "size1x": "https://www.mollie.com/external/icons/payment-methods/belfius.png",
            "size2x": "https://www.mollie.com/external/icons/payment-methods/belfius%402x.png",
            "svg": "https://www.mollie.com/external/icons/payment-methods/belfius.svg"
        },
        "_links": {
            "self": {
                "href": "https://api.mollie.com/v2/methods/belfius",
                "type": "application/hal+json"
            }
        },
        "minimumAmount": {
            "value": "0.01",
            "currency": "EUR"
        },
        "maximumAmount": {
            "value": "50000.00",
            "currency": "EUR"
        }
    }, {
        "id": "inghomepay",
        "resource": "method",
        "description": "ING Home'Pay",
        "image": {
            "size1x": "https://www.mollie.com/external/icons/payment-methods/inghomepay.png",
            "size2x": "https://www.mollie.com/external/icons/payment-methods/inghomepay%402x.png",
            "svg": "https://www.mollie.com/external/icons/payment-methods/inghomepay.svg"
        },
        "_links": {
            "self": {
                "href": "https://api.mollie.com/v2/methods/inghomepay",
                "type": "application/hal+json"
            }
        },
        "minimumAmount": {
            "value": "0.01",
            "currency": "EUR"
        },
        "maximumAmount": {
            "value": "50000.00",
            "currency": "EUR"
        }
    }]
}

In comparison, here's the REST API's response with the same parameters :

{
    "_embedded": {
        "methods": [
            {
                "resource": "method",
                "id": "banktransfer",
                "description": "Overschrijving",
                "minimumAmount": {
                    "value": "0.01",
                    "currency": "EUR"
                },
                "maximumAmount": {
                    "value": "1000000.00",
                    "currency": "EUR"
                },
                "image": {
                    "size1x": "https://www.mollie.com/external/icons/payment-methods/banktransfer.png",
                    "size2x": "https://www.mollie.com/external/icons/payment-methods/banktransfer%402x.png",
                    "svg": "https://www.mollie.com/external/icons/payment-methods/banktransfer.svg"
                },
                "_links": {
                    "self": {
                        "href": "https://api.mollie.com/v2/methods/banktransfer",
                        "type": "application/hal+json"
                    }
                }
            },
            {
                "resource": "method",
                "id": "paypal",
                "description": "PayPal",
                "minimumAmount": {
                    "value": "0.01",
                    "currency": "EUR"
                },
                "maximumAmount": null,
                "image": {
                    "size1x": "https://www.mollie.com/external/icons/payment-methods/paypal.png",
                    "size2x": "https://www.mollie.com/external/icons/payment-methods/paypal%402x.png",
                    "svg": "https://www.mollie.com/external/icons/payment-methods/paypal.svg"
                },
                "_links": {
                    "self": {
                        "href": "https://api.mollie.com/v2/methods/paypal",
                        "type": "application/hal+json"
                    }
                }
            }
        ]
    },
    "count": 2,
    "_links": {
        "documentation": {
            "href": "https://docs.mollie.com/reference/v2/methods-api/list-all-methods",
            "type": "text/html"
        },
        "self": {
            "href": "https://api.mollie.com/v2/methods/all?amount%5Bvalue%5D=555555.00&amount%5Bcurrency%5D=EUR&locale=nl_BE",
            "type": "application/hal+json"
        }
    }
}

Am I missing something?

@Pimm
Copy link
Collaborator

Pimm commented Mar 30, 2020

Hi Simon,

You are not missing something. The library is currently ‒ incorrectly ‒ striping out those parameters you are passing in. There is an open PR which fixes this, and we are in the process of getting it merged.

@Pimm Pimm mentioned this issue Mar 30, 2020
@depsimon
Copy link
Author

I see :) Thanks for the reply & for the PR :) Will wait for it to be merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants