Skip to content

Error after callApi (result of buildPaymentPageUrl) #2

Closed
@bicibg

Description

@bicibg

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;
	}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions