Payrexx Select2Pay - Create a paylink - PHP Integration Curl does not work with spaces
The example in the current documentation (2022-06-15) does not work with strings with spaces.
https://developers.payrexx.com/reference/create-a-paylink
It returns the error message: "An error occurred: The API secret is not correct."
Here is a working example for PHP Curl:
$data = [
'title' => 'foo',
'description' => 'a funny description',
'referenceId' => 1234,
'purpose' => 'nopurpose',
'amount' => 666,
'currency' => 'EUR',
];
$signature = base64_encode(hash_hmac('sha256', http_build_query($data), 'xxxxxxxxxxxxxxxxx', true));
$data['ApiSignature'] = $signature;
// Now build data / query again with the api signature
$data['ApiSignature'] = $signature;
$query = http_build_query($data);
$curl = curl_init();
curl_setopt_array($curl, [ CURLOPT_URL => 'https://api.payrexx.com/v1.0/Invoice/?instance=xxx', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => $data, CURLOPT_HTTPHEADER => [ 'Accept: application/json','Content-Type: application/x-www-form-urlencoded'], ]); $response = curl_exec($curl);

