$value) { $chk = $chk. (isset($value) ? $value : null); } } return $chk; } ## GENERATE FORM TO DOTPAY function GenerateChkDotpayRedirection($DotpayId, $DotpayPin, $Environment, $RedirectionMethod, $ParametersArray, $MultiMerchantList, $customer_base64) { $ParametersArray['id'] = $DotpayId; $ChkParametersChain = GenerateChk($DotpayId, $DotpayPin, $Environment, $RedirectionMethod, $ParametersArray, $MultiMerchantList, $customer_base64); $ChkValue = hash('sha256', $ChkParametersChain); 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; } if(isset($customer_base64)) { $RedirectionCode .= "\t".''.PHP_EOL; } foreach ($MultiMerchantList as $item) { foreach ($item as $key => $value) { $RedirectionCode .= "\t".''.PHP_EOL; } } $RedirectionCode .= "\t".''.PHP_EOL; $RedirectionCode .= '
'.PHP_EOL.''.PHP_EOL; return $RedirectionCode; } elseif ($RedirectionMethod == 'GET') { $RedirectionCode = $EnvironmentAddress.'?'; foreach ($ParametersArray as $key => $value) { $RedirectionCode .= $key.'='.rawurlencode($value).'&'; } if(isset($customer_base64)) { $RedirectionCode .= 'customer='.$customer_base64.'&'; } foreach ($MultiMerchantList as $item) { foreach ($item as $key => $value) { $RedirectionCode .= $key.'='.rawurlencode($value).'&'; } } $RedirectionCode .= 'chk='.$ChkValue; return 'Go to Pay
link:
'.$RedirectionCode; } } // ** ----------------------- SAMPLE DATA ------------------------- **/ /* ## SAMPLE PAYMENT DATA IN ## */ // Note! You can use more parameters if You need // You must give at least: 'amount', 'currency', 'description' (and of course ID and PIN in the configuration of this script) // see more: https://www.dotpay.pl/developer/doc/api_payment/en/index.html#tabela-1-podstawowe-parametry-przesylane-do-serwisu-dotpay // and: https://www.dotpay.pl/developer/doc/api_payment/en/index.html#tabela-2-dodatkowe-parametry-przesylane-do-serwisu-dotpay // ------ $ParametersArray = array( "api_version" => "dev", "amount" => "100.00", "currency" => "PLN", "description" => "Order no. 567915976", "url" => "https://www.example.com/thanks_page.php", "type" => "4", "channel" => "2", "buttontext" => "Back to the www.example.com", "urlc" => "https://www.example.com/urlc_receiver.php", "control" => "M1231MzaUdLQWR3", "firstname" => "Jan", "lastname" => "Nowak", "email" => "jan.nowak@example.com", "street" => "Warszawska", "street_n1" => "1", "city" => "Krakow", "postcode" => "12-345", "phone" => "123456789", "country" => "POL", "ignore_last_payment_channel" => "true" ); // ------ /* ### SAMPLE CUSTOMER DATA IN with delivery address (optional) ### You can remove it if You don't need it */ // ------ $customer = array( "payer" => array( "first_name" => "Jan", "last_name" => "Kowal", "email" => "mymail@example.com", ) , "order" => array( "delivery_address" => array( "city" => "Kraków", "street" => "Wielicka", "building_number" => "28B", "postcode" => "30-552", ) ) ); // ------ /* ### SAMPLE Multimerchant DATA IN (3 accounts 'child' type ) - optional ### You can remove it if You don't need it see more: https://www.dotpay.pl/developer/doc/api_payment/en/index.html#platnosc-dzielona-multimerchant-pasaz */ // ------ uncomment if you need: /* $MultiMerchantList = array( $MultiMerchant1 = array( "id1" => "123456", "amount1" => "10.00", "currency1" => "PLN", "description1" => "description1", "control1" => "control1", ) , $MultiMerchant2 = array( "id2" => "234561", "amount2" => "60.00", "currency2" => "PLN", "description2" => "description2", "control2" => "control2", ) , $MultiMerchant3 = array( "id3" => "234562", "amount3" => "30.00", "currency3" => "PLN", "description3" => "description3", "control3" => "control3", ) ); */ // ------ // ** ----------------------- SAMPLE DATA end ------------------------- **/ if (empty($customer) || !isset($customer['payer']) || !isset($customer['order']['delivery_address'])) { $customer_base64 = null; } else { $customer_base64 = base64_encode(json_encode($customer)); } ## get form (POST method) or payment link (GET method) ## ("Dotpay ID","PIN","[test|production]","[POST|GET]","payment data","Multimerchant data", "additional customer data") echo GenerateChkDotpayRedirection($DotpayId, $DotpayPin, $Environment, $RedirectionMethod , $ParametersArray, $MultiMerchantList, $customer_base64); ?>