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

Error after callApi (result of buildPaymentPageUrl) #2

Closed
bicibg opened this issue Aug 6, 2019 · 1 comment
Closed

Error after callApi (result of buildPaymentPageUrl) #2

bicibg opened this issue Aug 6, 2019 · 1 comment

Comments

@bicibg
Copy link

bicibg commented Aug 6, 2019

Pull request: #3

The sent request does either not contain the request parameter 'id' or it is invalid (e.g. wrong format).

The call from API returns this error. Upon further inspection, I found that this is caused by the buildRequestUrl method which uses http_build_query function which by default uses '&' as a separator. Normally if posting to another php5.3 machine this will not be a problem.

But if you post to a server with a newer PHP version or tomcat java server or something else the & might not be handled properly.

To overcome this specify:

http_build_query($array, '', '&');

and NOT

http_build_query($array);

in buildRequestUrl method. More specifically, change buildRequestUrl method in ApiClient.php to the following:

        /**
	 * Returns the request url.
	 *
	 * @param string $path the request path
	 * @param array $queryParams an array of query parameters
	 * @return string
	 */
	private function buildRequestUrl($path, $queryParams) {
		$url = $this->getBasePath() . $path;
		if (!empty($queryParams)) {
			$url = ($url . '?' . http_build_query($queryParams, '', '&'));
		}
		return $url;
	}
@thomashunziker
Copy link

I have created a new release which fixes the issue. However the underlying problem is actually that you can override the arg-separator.output via the PHP ini. So the solution remains the same but it is not happening randomly and it has actually not that much to do with the remote server.

See also http://docs.php.net/manual/da/ini.core.php#ini.arg-separator.output

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