<?php
 if(!isset($operation['vis_gateway']) && $paymentMethod!= -1) $operation['vis_gateway'] = $paymentMethod[0]['gateway_type'];
if(isset($operation['vis_gateway']) && $operation['vis_gateway'] == 2) // authorize.net
{	
	$gateway_mode = ($billing_info['gateway_mode'] == 2) ? 'secure' : 'test';
	?>
	<form method='post' action="https://<?php echo $gateway_mode?>.authorize.net/gateway/transact.dll">
	<input type='hidden' name="x_login" value="<?php echo $api_login_id?>" />
	<input type='hidden' name="x_fp_hash" value="<?php echo $fingerprint?>" />
	<input type='hidden' name="x_amount" value="<?php echo $invoice_info['total']?>" />
	<input type='hidden' name="x_fp_timestamp" value="<?php echo $fp_timestamp?>" />
	<input type='hidden' name="x_fp_sequence" value="<?php echo $fp_sequence?>" />
	<input type='hidden' name="x_version" value="3.1">
	<input type='hidden' name="x_show_form" value="payment_form">
	<input type='hidden' name="x_test_request" value="false" />
	<input type='hidden' name="x_method" value="cc">
	<input type='hidden' name="x_first_name" value="<?php echo $client['first_name']?>" />
	<input type='hidden' name="x_last_name" value="<?php echo $client['last_name']?>" />
	<input type='hidden' name="x_company" value="<?php echo $client['office_name']?>" />
	<input type='hidden' name="x_address" value="<?php echo $client['permanent_address']?>" />
	<input type='hidden' name="x_city" value="<?php echo $client['city']?>" />
	<input type='hidden' name="x_state" value="<?php echo $client['state']?>" />
	<input type='hidden' name="x_zip" value="<?php echo $client['zip_code']?>" />
	<input type='hidden' name="x_country" value="<?php echo $client['country']?>" />
	<input type='hidden' name="x_phone" value="<?php echo $client['contact_number']?>" />
	<input type='hidden' name="x_fax" value="<?php echo $client['fax']?>" />
	<input type='hidden' name="x_email" value="<?php echo $client['email']?>" />
	<input type='hidden' name="x_invoice_num" value="<? echo $invoice_info['invoice_hash']; ?>" />
	<input type='hidden' name="x_description" value="<? echo $vis_language['MSGBALFORINV'].$invoice_info['invoice_hash']?>" />
	<input type='hidden' name="x_tax" value="<?php echo $invoice_info['tax']?>" />
	<input type='hidden' name="x_cancel_url_text" value="Cancel" />
	<input type='hidden' name="x_cancel_url" value="<?php echo script_url() . '?/billing/products-list'?>" />		
	<input type='hidden' name="x_receipt_link_method" value="POST" />
	<input type='hidden' name="x_receipt_link_text" value="Back to site" />
	<input type='hidden' name="x_receipt_link_url" value="<?php echo script_url() . '?vis_module=billing&vis_operation=pay_invoice&vis_invoice_id=' . $invoice_info['invoice_id'] ?>" />
	<input type='submit' class="btn btn-sm btn-primary pull-right m-l" value="<? echo $vis_language['TXTPAYNOW']; ?>">
	</form>
<?php 
}
else if(isset($operation['vis_gateway']) && $operation['vis_gateway'] == 3){ ?>
    <script type="text/javascript" src="https://js.stripe.com/v2/"></script>
    <form action="" method="POST">
        <input type="hidden" name="vis_product_id" id="vis_product_id" value="<?= $invoice_info['product_id']; ?>"/>
        <input type="hidden" name="vis_amount" id="vis_amount" value="<?= $invoice_info['balance']; ?>"/>
        <input type="hidden" name="vis_invoice_hash" id="vis_invoice_hash" value="<?= $invoice_info['invoice_hash']; ?>"/>
      <script
        src="https://checkout.stripe.com/checkout.js" class="stripe-button"
        data-key="<?= $billing_info['field_value']; ?>"
        data-amount="<?= $invoice_info['balance']*100; ?>"
        data-email="<?= $client['email']; ?>"
        data-name=""
        data-description="<?= $vis_language['MSGBALFORINV'].$invoice_info['invoice_hash']; ?>">
      </script>

    <div id="payment-errors"></div>
    </form>
    <style>
        .stripe-button-el{
            cursor: pointer;
            margin-left: 15px;
            border-radius: 2px;            
            float: right;
            background-color:<?= VIS_THEME_COLOR; ?> !important;
            border-color:<?= VIS_THEME_COLOR; ?> !important;
            background-image:none!important;
            font-size:12px;
        }
        .stripe-button-el span{
            background-color:<?= VIS_THEME_COLOR; ?> !important;
            border-color:<?= VIS_THEME_COLOR; ?> !important;
            background-image:none!important;
            font-size:12px;
        }
    </style>
<? }
else if($gateway=='payflow') { ?>
    <a class="vis_button" href="?/billing/pay_invoice/<? echo $invoice_info['invoice_id']; ?>"><? echo $vis_language['TXTPAYNOW']; ?></a> <?
}
elseif($gateway=='paypal_email' && trim($billing_info['email'])!='' || $operation['vis_gateway'] == 1) { // paypal ?>
	<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
	<input type="hidden" name="cmd" value="_xclick">
	<input type="hidden" name="business" value="<? echo $billing_info['email']; ?>">
	<input type="hidden" name="lc" value="US">
	<input type="hidden" name="item_name" value="<? echo $vis_language['MSGBALFORINV'].$invoice_info['invoice_hash']?>">
	<input type="hidden" name="item_number" value="1">
	<input type="hidden" name="amount" value="<? echo $invoice_info['balance']; ?>">
	<input type="hidden" name="currency_code" value="<? echo VIS_DOMAIN_CURRENCY; ?>">
	<input type="hidden" name="button_subtype" value="services">
	<input type="hidden" name="no_note" value="0">
	<input type="hidden" name="return" value="<? echo script_url(); ?>?/billing/pay_invoice/<? echo $invoice_info['invoice_id']; ?>">
	<input type="hidden" name="notify_url" value="<? echo script_url(); ?>?/billing/pay_invoice/<? echo $invoice_info['invoice_id']; ?>">
	<input type="hidden" name="tax_rate" value="0">
	<input type="hidden" name="rm" value="2">
	<input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynowCC_LG.gif:NonHostedGuest">
	<input type="submit"  class="btn btn-sm btn-primary pull-right m-l"  value="<? echo $vis_language['TXTPAYNOW']; ?>" />
	<!--<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">-->
	</form> <?
}
function script_url() {
    return (@$_SERVER['HTTPS'] ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
}
?>