(string) $DotpayId, "api_version" => "next", "amount" => "345.12", "currency" => "PLN", "description" => "Order no. 8765GfdC6", "url" => "https://www.example.com/thanks_page.php", "type" => "0", "urlc" => "https://www.example.com/urlc_receiver.php", "control" => "8765GfdC6-dsgfdg-2342235", "firstname" => "Jan", "lastname" => "Nowak", "email" => "jan.nowak@example.com" ); // ** ----------------------- SAMPLE DATA end ------------------------- **/ // if you do not know what configuration is on your account, add this parameter safely if(!(isset($ParametersArray['api_version']) && $ParametersArray['api_version'] == "next")){ $ParametersArray['api_version'] = "next"; } ## function: counts the checksum from the defined array of all parameters function GenerateChk($DotpayPin, $ParametersArray) { //sorting the parameter list ksort($ParametersArray); // Display the semicolon separated list $paramList = implode(';', array_keys($ParametersArray)); //adding the parameter 'paramList' with sorted list of parameters to the array $ParametersArray['paramsList'] = $paramList; //re-sorting the parameter list ksort($ParametersArray); //json encoding $json = json_encode($ParametersArray, JSON_UNESCAPED_SLASHES); return hash_hmac('sha256', $json, $DotpayPin, false); } ## Function: Generate simple FORM to DOTPAY function GenerateChkDotpayRedirection($DotpayPin, $Environment, $RedirectionMethod, $ParametersArray, $next_chk, $autosubmit) { if ($Environment == 'production') { $EnvironmentAddress = 'https://ssl.dotpay.pl/t2/'; } elseif ($Environment == 'test') { $EnvironmentAddress = 'https://ssl.dotpay.pl/test_payment/'; } if ($RedirectionMethod == 'POST') { $RedirectionCode = '
' . PHP_EOL; foreach ($ParametersArray as $key => $value) { $RedirectionCode .= "\t" . '' . PHP_EOL; } $RedirectionCode .= "\t" . '' . PHP_EOL; $RedirectionCode .= '
' . PHP_EOL . '' . PHP_EOL; //auto submit form if ($autosubmit == true) { $RedirectionCode .= ""; } return $RedirectionCode; } elseif ($RedirectionMethod == 'GET') { $RedirectionCode = $EnvironmentAddress . '?'; foreach ($ParametersArray as $key => $value) { $RedirectionCode .= $key . '=' . rawurlencode($value) . '&'; } $RedirectionCode .= 'chk=' . $next_chk; return 'Link to Pay'; } else { return 'configuration error'; } } #### // Calculate checksum for 'chk' parameter: $next_chk = GenerateChk($DotpayPin, $ParametersArray); /* Print the form according to the settings: get form (POST method) or payment link (GET method) ("account PIN","[test|production]","[POST|GET]","payment data","chk_value","[true|false]") */ echo GenerateChkDotpayRedirection($DotpayPin, $Environment, $RedirectionMethod, $ParametersArray, $next_chk, $autosubmit); ?>