Confirmation 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[‘zproduct’] == “” ){
$res = “”;
$message = “Missing Required Data!”;
}
elseif ($_POST[‘zcustomer’] == “B2B” && $_POST[‘zcompany’] == “”){
$res = “”;
$message = “Missing Business Name for Business Type selected: Company!”;
}
else{
$data_array = explode(“_”,$_POST[‘zproduct’]);
if ($data_array[0] != “sub”){
$zvm = $data_array[0];
$zrtos = $data_array[1];
$zamount = $data_array[2];
$zstore = “Zerynth Virtual Machines”;
$zdescription = ‘Pack – ‘.$zvm.’ VMs – ‘.$zrtos;
$zproduct = ‘Pack’;
$zproduct_description = $zstore.’ ‘.$zdescription;
}
else{
$zsub = $data_array[1];
$zamount = $data_array[2];
$zstore = “Zerynth Studio PRO”;
$zdescription = $zsub.’ly Subscription Plan’;
$zproduct = $data_array[1];
$zrtos = “”;
$zvm = “”;
$zproduct_description = $zstore.’ – ‘.$zdescription;
}
$ip = get_user_ip();

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,
‘ip’ => $ip,
‘zcode’ => $_POST[‘zcode’],
‘zstate’ => $_POST[‘zstate’],
‘zvat’ => $_POST[‘zvat’],
‘zamount’ => $zamount,
‘zts’ => time(),
‘znumber’ => rand()
);

$zuser = curl_post(“https://test.zerynth.com/v1/store/auth”, $zdata);
$array_zuser = (array)json_decode($zuser);
$res = ( isset( $array_zuser[‘code’] ) ? $array_zuser[‘code’] : ” );
$message = ( isset( $array_zuser[‘data’]->{‘message’} ) ? $array_zuser[‘data’]->{‘message’} : ” );
$trial_period = ( isset( $array_zuser[‘data’]->{‘trial_period’} ) ? $array_zuser[‘data’]->{‘trial_period’} : ” );
print_r($array_zuser);
print_r($res);
echo $message;
$res = 200;
$message = ”;
$trial_period = “+1 month”;
}
if ($res == 200){
$tax_rate = number_format(( isset( $array_zuser[‘data’]->{‘tax_rate’} ) ? $array_zuser[‘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           ‘;

if (isset($zsub) && ($zsub == “Month” || $zsub == “Year”)){
echo do_shortcode(‘[stripe name=”‘.$zstore.'” description=”‘.$zdescription.'” currency=”USD” image_url=”https://store.zerynth.com/wp-content/uploads/2016/11/Logo512.png” zuser=”‘.$_POST[‘zmail’].'” customer_name=”‘.$_POST[‘zname’].’ ‘.$_POST[‘zsurname’].'” invoice_name=”‘.$invoice_name.'” address_line1=”‘.$_POST[‘zaddress’].'” address_city=”‘.$_POST[‘zcity’].'” address_country=”‘.$_POST[‘zcountry’].'” address_zip=”‘.$_POST[‘zcode’].'” tax_number=”‘.$_POST[‘zvat’].'” business_type=”‘.$_POST[‘zcustomer’].'” product_type=”eservice” address_state=”‘.$_POST[‘zstate’].'” ip_address=”‘.$ip.'” tax_rate=”‘.$tax_rate.'” notes=”Order Registered for the Zerynth Account: ‘.$_POST[‘zmail’].’. For any issue please contact us at sales@zerynth.com” company=”‘.$_POST[‘zcompany’].'” checkout_button_label=”Pay {{amount}} + $’.$tax_amount.’ Tax” simpay_payment_button_icon_html=”https://store.zerynth.com/wp-content/uploads/2016/11/Logo512.png” trial_period=”‘.$trial_period.'”]
[stripe_checkbox label=”I understand this is for a recurring payment plan” required=”true”]
[stripe_subscription id=”pro’.$zsub.'”]
[/stripe_subscription]
[stripe_coupon label=”Have a coupon?”]
[/stripe]’);
}
else{

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

echo do_shortcode(‘[stripe name=”‘.$zstore.'” description=”‘.$zdescription.'” currency=”USD” amount=”‘.$zamount.'” start_price=”‘.$zamount.'” image_url=”https://store.zerynth.com/wp-content/uploads/2016/11/Logo512.png” zuser=”‘.$_POST[‘zmail’].'” customer_name=”‘.$_POST[‘zname’].’ ‘.$_POST[‘zsurname’].'” invoice_name=”‘.$invoice_name.'” address_line1=”‘.$_POST[‘zaddress’].'” address_city=”‘.$_POST[‘zcity’].'” address_country=”‘.$_POST[‘zcountry’].'” address_zip=”‘.$_POST[‘zcode’].'” tax_number=”‘.$_POST[‘zvat’].'” business_type=”‘.$_POST[‘zcustomer’].'” product_type=”eservice” address_state=”‘.$_POST[‘zstate’].'” ip_address=”‘.$ip.'” tax_rate=”‘.$tax_rate.'” notes=”Order Registered for the Zerynth Account: ‘.$_POST[‘zmail’].’. For any issue please contact us at sales@zerynth.com” checkout_button_label=”Pay {{amount}} + $’.$tax_amount.’ Tax” simpay_payment_button_icon_html=”https://store.zerynth.com/wp-content/uploads/2016/11/Logo512.png” company=”‘.$_POST[‘zcompany’].'”]
[stripe_coupon label=”Have a coupon?”]
[/stripe]’);
}
echo ‘

‘;
}
else{
$error = ( isset( $array_zuser[‘data’]->{‘error’} ) ? $array_zuser[‘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]