Confirm Your Order

[insert_php]
function curl_post($url, array $post = array(), array $options = array())
{

$data_string = json_encode($post);
$zsecurekey = “2SSbdIqR9gnIUX49fWQgsxqLvzfMAkVJ”;

$ciphertext = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $zsecurekey, $data_string, MCRYPT_MODE_ECB);
$ciphertext_base64 = base64_encode($ciphertext);
$crypted_data = array(
‘zcrypto’ => $ciphertext_base64
);
$crypted_data_string = json_encode($crypted_data);

$defaults = array(
CURLOPT_POST => 1,
CURLOPT_HTTPHEADER, array(
‘Content-Type: application/json’,
‘Content-Length: ‘ . strlen($crypted_data_string)
),
CURLOPT_URL => $url,
CURLOPT_FRESH_CONNECT => 1,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_FORBID_REUSE => 1,
CURLOPT_TIMEOUT => 4,
CURLOPT_POSTFIELDS => $crypted_data_string
);
$ch = curl_init();
curl_setopt_array($ch, ($options + $defaults));
if( ! $result = curl_exec($ch))
{
trigger_error(curl_error($ch));
}
curl_close($ch);
return $result;
}

function get_user_ip()
{
$client = @$_SERVER[‘HTTP_CLIENT_IP’];
$forward = @$_SERVER[‘HTTP_X_FORWARDED_FOR’];
$remote = $_SERVER[‘REMOTE_ADDR’];

if(filter_var($client, FILTER_VALIDATE_IP))
{
$ip = $client;
}
elseif(filter_var($forward, FILTER_VALIDATE_IP))
{
$ip = $forward;
}
else
{
$ip = $remote;
}

return $ip;
}

if ($_POST[‘zcustomer’] == “” || $_POST[‘zname’] == “” || $_POST[‘zsurname’] == “” || $_POST[‘zbill’] == “” || $_POST[‘zmail’] == “” || $_POST[‘zaddress’] == “” || $_POST[‘zcountry’] == “” || $_POST[‘zcode’] == “” || $_POST[‘zcity’] == “” || $_POST[‘zrtos’] == “” || $_POST[‘zlicense’] == “” || $_POST[‘zvm’] == “” || $_POST[‘zprice’] == “” || $_POST[‘zppu’] == “” ){
$res = “”;
$message = “Missing Required Data!”;
}
elseif ($_POST[‘zcustomer’] == “B2B” && $_POST[‘zcompany’] == “”){
$res = “”;
$message = “Missing Business Name for Business Type selected: Company!”;
}
else{
$zvm = $_POST[‘zvm’];
$zrtos = $_POST[‘zrtos’];
$zamount = $_POST[‘zprice’];
$zppu = $_POST[‘zppu’];
$zlicense = $_POST[‘zlicense’];
$zstore = “Zerynth Licenses”;
$zdescription = $zvm.’ VMs – ‘.$zlicense.’ ‘.$zrtos;
$zproduct = ‘VMs’;
$zproduct_description = $zstore.’ – ‘.$zdescription;
$ip = get_user_ip();
if ($_POST[‘zskin’]) {
$zskin = $_POST[‘zskin’];
}
else {
$zskin = “zerynth”;
}
if ($_POST[“zcustomer”] == “B2B”){
$invoice_name = $_POST[‘zcompany’];
}
else {
$invoice_name = $_POST[“zname”] .’ ‘. $_POST[“zsurname”];
$_POST[“zvat”] = “”;
}

$zdata = array(
‘zmail’ => $_POST[“zmail”],
‘zcustomer’ => $_POST[‘zcustomer’],
‘zcountry’ => $_POST[‘zcountry’],
‘zproduct’ => $zproduct,
‘zvm’ => $zvm,
‘zrtos’ => $zrtos,
‘zlicense’ => $zlicense,
‘ip’ => $ip,
‘zcode’ => $_POST[‘zcode’],
‘zstate’ => $_POST[‘zstate’],
‘zvat’ => $_POST[‘zvat’],
‘zamount’ => $zamount,
‘zppu’ => $zppu,
‘zts’ => time(),
‘znumber’ => rand()
);
$zresponse = curl_post(“https://test.zerynth.com/v1/store/auth”, $zdata);
$array_zresponse = (array)json_decode($zresponse);
$res = ( isset( $array_zresponse[‘code’] ) ? $array_zresponse[‘code’] : ” );
$message = ( isset( $array_zresponse[‘data’]->{‘message’} ) ? $array_zresponse[‘data’]->{‘message’} : ” );
}
if ($res == 200){
$tax_rate = number_format(( isset( $array_zresponse[‘data’]->{‘tax_rate’} ) ? $array_zresponse[‘data’]->{‘tax_rate’} : 0.0 ), 1, ‘.’, ‘,’);
$tax_amount = number_format(($zamount*$tax_rate/100), 2, ‘.’, ‘,’);
$total_amount = number_format(($zamount + $zamount*$tax_rate/100), 2, ‘.’, ‘,’);
$sub_amount = number_format(($zamount), 2, ‘.’, ‘,’);
echo ‘

Revise your Order!

‘;
echo ‘

‘;
if (isset($_POST[‘zcompany’]) && $_POST[‘zcompany’] != “” && $_POST[‘zcustomer’] == “B2B”){
echo ‘

‘;
}
else{
echo ‘

‘;
}
echo ‘

‘;
if (isset($_POST[‘zstate’]) && $_POST[‘zstate’] != “”){
echo ‘

‘;
}
else {
echo ‘

‘;
}
echo ‘

‘;
if (isset($_POST[‘zvat’]) && $_POST[‘zvat’] != “”){
echo ‘

‘;
}
else{
echo ‘

‘;
}
echo ‘

‘;
echo ‘

Product ‘.$zproduct_description.’
Zerynth Account Email Address ‘.$_POST[‘zmail’].’
Company ‘.$_POST[‘zcompany’].’
Name ‘.$_POST[‘zname’].’ ‘.$_POST[‘zsurname’].’
First Name ‘.$_POST[‘zname’].’
Last Name ‘.$_POST[‘zsurname’].’
Billing Address ‘.$_POST[‘zaddress’].’
City/Town – State/Provence ‘.$_POST[‘zcity’].’ – ‘.$_POST[‘zstate’].’
City/Town ‘.$_POST[‘zcity’].’
Country ‘.$_POST[‘zcountry’].’
Zip/Postal Code ‘.$_POST[‘zcode’].’
Tax ID or VAT ‘.$_POST[‘zvat’].’
Tax ID or VAT
Sub Total $ ‘.$sub_amount.’
Tax (‘.$tax_rate.’%) $ ‘.$tax_amount.’
TOTAL $ ‘.$total_amount.’

 
‘;

if ($message != “”){
echo ‘‘.$message.’

‘;
}

echo ‘Cards Accepted           ‘;

$zsub_total = number_format(($zamount*100), 0, ”, ”);
echo ‘

‘;

$GLOBALS[‘zamount’] = $zamount;
$GLOBALS[‘zsub_total’] = $zsub_total;
function simpay_custom_form_280_amount() {
return $GLOBALS[‘zamount’];
}
add_filter( ‘simpay_form_280_amount’, ‘simpay_custom_form_280_amount’ );
$GLOBALS[‘zstore’] = $zstore;
function simpay_custom_form_280_company_name() {
return $GLOBALS[‘zstore’];
}
add_filter( ‘simpay_form_280_company_name’, ‘simpay_custom_form_280_company_name’ );
$GLOBALS[‘zdescription’] = $zdescription;
function simpay_custom_form_280_item_description() {
return $GLOBALS[‘zdescription’];
}
add_filter( ‘simpay_form_280_item_description’, ‘simpay_custom_form_280_item_description’ );
$GLOBALS[‘button_label’] = “Pay $”.$zamount.” + $”.$tax_amount.” Tax”;
function simpay_custom_form_280_checkout_button_text() {
return $GLOBALS[‘button_label’];
}
add_filter( ‘simpay_form_280_checkout_button_text’, ‘simpay_custom_form_280_checkout_button_text’ );
$GLOBALS[‘tax_rate’] = $tax_rate;
function simpay_custom_form_280_tax_percent() {
return $GLOBALS[‘tax_rate’];
}
add_filter( ‘simpay_form_280_tax_percent’, ‘simpay_custom_form_280_tax_percent’ );
$GLOBALS[‘zuser’] = $_POST[‘zmail’];
$GLOBALS[‘customer_name’] = $_POST[‘zname’].’ ‘.$_POST[‘zsurname’];
$GLOBALS[‘invoice_name’] = $invoice_name;
$GLOBALS[‘address_line1’] = $_POST[‘zaddress’];
$GLOBALS[‘address_city’] = $_POST[‘zcity’];
$GLOBALS[‘address_country’] = $_POST[‘zcountry’];
$GLOBALS[‘address_zip’] = $_POST[‘zcode’];
$GLOBALS[‘tax_number’] = $_POST[‘zvat’];
$GLOBALS[‘business_type’] = $_POST[‘zcustomer’];
$GLOBALS[‘product_type’] = “eservice”;
$GLOBALS[‘address_state’] = $_POST[‘zstate’];
$GLOBALS[‘ip_address’] = $ip;
$GLOBALS[‘zskin’] = $zskin;
$GLOBALS[‘notes’] = ‘Order Registered for the Zerynth Account: ‘.$_POST[‘zmail’].’. For any issue please contact us at sales@zerynth.com’;
$GLOBALS[‘tax_rate’] = $tax_rate;
$GLOBALS[‘company’] = $_POST[‘zcompany’];
function simpay_custom_before_form_close() {
echo ‘‘;
echo ‘‘;
echo ‘‘;
echo ‘‘;
echo ‘‘;
echo ‘‘;
echo ‘‘;
echo ‘‘;
echo ‘‘;
echo ‘‘;
echo ‘‘;
echo ‘‘;
echo ‘‘;
echo ‘‘;
echo ‘‘;
echo ‘‘;
echo ‘‘;
echo ‘‘;
echo ‘‘;
}
add_action( ‘simpay_before_form_close’, ‘simpay_custom_before_form_close’ );

echo do_shortcode(‘

Have a coupon?

Test Mode
‘);

}
else{
$error = ( isset( $array_zresponse[‘data’]->{‘error’} ) ? $array_zresponse[‘data’]->{‘error’} : “” );
echo ‘


Sorry, but there has been an error processing your order
‘;
if ($message != “”){
echo ‘
‘.$message.’
‘;
}
if ($error != “”){
echo ‘
‘.$error.’
‘;
}
echo ‘
If the problem persists, contact us at sales@zerynth.com

‘;
}
echo ‘

 
‘;

[/insert_php]