mollie / mollie-api-node

Official Mollie API client for Node
http://www.mollie.com
BSD 3-Clause "New" or "Revised" License
231 stars 63 forks source link

mollieClient.methods.all with params #137

Closed depsimon closed 4 years ago

depsimon commented 4 years ago

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 commented 4 years ago

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.

depsimon commented 4 years ago

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