Mangopay / mangopay2-php-sdk

PHP SDK for MANGOPAY
https://packagist.org/packages/mangopay/php-sdk-v2
MIT License
123 stars 133 forks source link

PayIn->BrowserInfo->Language: validation regex blocks some values like "en-GB-oxendict" #623

Open kapposds opened 10 months ago

kapposds commented 10 months ago

Attempting to create a MangoPay\PayIn object with type "card", I encounter an error when I assign a \MangoPay\BrowserInfo on the property "BrowserInfo". This happens when I assign "en-GB-oxendict" value to the "Language" property of the browser info object.

That is because the API's validation logic does not accept this language value. The error I get is the following:

Response JSON : {"Message":"One or several required parameters are missing or incorrect. An incorrect resource ID also raises this kind of error.","Type":"param_error","Id":"feca8b2f-542c-434b-aa57-abaeaaaed92f","Date":1705938605.0,"errors":{"BrowserInfo.Language":"The field Language must match the regular expression '^.{0,6}$'."}}

The implementation that I do to collect the language values is the following:

    if (window && window.navigator) {
        language = window.navigator.language
            ? window.navigator.language
            : window.navigator.browserLanguage; // Else is for IE <+ 10
    }

So I think that Mangopay's should allow value of length more than 6 characters