<style>
#detail input{vertical-align:middle; margin-right:10px;}
#payment_method{display:none;background-color:#fff;border:1px solid #ccc;padding:10px 30px; position:absolute;top:200px;box-shadow: 0 8px 15px rgba(0, 0, 0, 0.5);}
#payment_method ul, #payment_method_window li{padding:0; margin:0; vertical-align:text-top; list-style:none;}
#payment_method ul{ margin-bottom:10px;}
#payment_method li {line-height:24px;}
#payment_method li input{margin-right:3px; vertical-align:middle;}
#payment_method li span{ color:blue;}
#payment_method div{margin:5px;padding-top:3px;}
#payment_method small{float:left;width:180px;font-weight:bold;}
a.close_link {background: url("https://www.beststoreitems.com/catalog/template/beststoreitems/image/close_link.gif") no-repeat scroll left top transparent;cursor: pointer;display: block;height: 13px;overflow: hidden;
position: absolute;right: 10px; top: 10px;width: 13px;}
.submit_3 {background: url("https://www.beststoreitems.com/catalog/template/beststoreitems/image/submit.gif") repeat scroll 0 0 transparent;border-style: none;border-width: 0;cursor: pointer;height: 26px;width: 80px;margin-left:110px;}
</style>
<script type="text/javascript">
   window.onload=function()
	{	
	    var payment_code=document.getElementById('payment_method_code').value; 

	   if (payment_code.search(/amopay/i)>-1) {

			var SubmitTime = $("#SubmitTime").val();
			
		    var _CompanyID='10017';

			var _NetSourceID='5589';

			var _Key='c70808029e887c78b6c056937291116c';					

			var AttachDetails=$("#MerchantOrderID").val()+'-'+$("#ApplyMoney").val()+$("#Currency").val();

			var PostSecure = _CompanyID + $("#MerchantOrderID").val() + $("#ApplyMoney").val() + $("#SubmitTime").val() + encodeURI(AttachDetails) + _NetSourceID + _Key;

			var PostSecureUsd = _CompanyID + $("#MerchantOrderID").val() + $("#ApplyUSD").val() + $("#SubmitTime").val() + encodeURI(AttachDetails) + _NetSourceID + _Key;
			
			$("#Post_AttachDetails").val(AttachDetails);

			$("#Post_PostSecure").val(PostSecure);

			$("#Post_SecureHash").val(calcMD5(PostSecure));	 			

			$("#Post_SecureHashUsd").val(calcMD5(PostSecureUsd));		
	   }
	} 
	
function check_payment_setting()
{
	<?php  if($payment_setting['status']==0){?>
		alert("<?php echo $payment_setting["description"]?>");
		return false;
	<?php }elseif ($payment_setting['status']==1){?>
	     <?php if(!empty($payment_setting['description'])){?>
	          alert("<?php echo $payment_setting["description"]?>");
	          return true;
	     <?php }else {?>
	        return true;
	     <?php }?>
	<?php }?>
}
function get_stock(){	    

	$.ajax({
		type: "post",	
	
		async: false,
	
		url: "index.php?controller=potential_order&action=checkstock&product_id=<?php echo $arr_product_id?>&product_to_option_id=<?php echo $arr_product_to_option_id?>",
	
		success: function(data)
		     {
		     	var check_data=data;
				var coupon_vaild=$("#coupon_vaild").val();
				if (!coupon_vaild)
				 {
				  alert('Sorry, your coupon has been applied on the other order, you need re-place an order to pay.');
				 } else {
					$("#potential_order").submit();
					return true;
				 }
				return coupon_vaild;
		     }
		  });
   }           
</script>
<div class="my-account">
	<div class="heading clearfix">
    	<dl class="acctip"><dt><?php echo $heading_title; ?></dt></dl>
    </div>
    <?php if ($message) { ?>      
      <div class="message"><?php echo $message; ?></div>        
    <?php } ?>    
        <div id="invoice">  
          <div class="a">              
            <table> 
              <tr>                  
                <td class="order-reference"><b><?php echo $text_order; ?></b><br />
                  <?php echo $reference; ?><br /><br />
                  <b><?php echo $text_email; ?></b><br />
                  <?php echo $email; ?><br /> <br />     
                  <?php if ($shipping_method) { ?>
                  <b><?php echo $text_shipping_method; ?></b><br />
                  <?php echo $shipping_method; ?><br /> <br />
                  <?php } ?>
                  <b><?php echo $text_payment_method; ?></b><br />
                  <?php echo $payment_method; ?>
                  <form id="formDetail" method="POST" action="/index.php?controller=potential_order&action=changePaymentMethod">                      
                    <input type="hidden" name="order_reference" value="<?php echo $reference?>" />                      
                    <div id="payment_method">                        
                      <a class="close_link" id="close"></a>                        
                      <div style="color:red;text-align:center; font-size:14px; font-weight:bold;">Chooose Payment Method</div>                        
                      <ul>                          
                        <?php foreach ($methods as $method) { ?>                          
                          <li><label for="<?php echo $method['id']; ?>"> 
                            <input type="radio" name="payment" value="<?php echo $method['id']; ?>" id="<?php echo $method['id']; ?>" <?php if($method['id']== $payment_method_code) echo 'CHECKED'?>/> <?php echo $method['title']; ?></label></li>                          
                        <?php } ?> 
                      </ul>   
                      <input type="button" value="Submit" class="btn_button btn_orange" style="padding:0 18px;" onclick="postForm()">
                    </div>
                  </form>        
                  <br />    
                </td>                  
                <td class="shipping-address"><div style="padding-left:50px;"><?php if ($shipping_address) { ?>                      
                    <b><?php echo $text_shipping_address; ?></b><br />                    
                    <?php echo $shipping_address; ?><br />   
                <?php } ?></div></td>
                <td class="billing-address"><div style="padding-left:50px;"><b><?php echo $text_payment_address; ?></b><br />
                <?php echo $payment_address; ?><br /></div></td>
              </tr>
              <tr>
                <td colspan="3">
                  <div id="detail">
                  	<input type="button" style="padding:0 18px;" id="post_detail" class="btn_button btn_orange" value="Change"><span style="color:#F00; font-size:12px;">Note: you can also click on (Change) button behind the payment method to choose the other payment methods.</span>
                  </div>
                </td>
              </tr>                
            </table>
          </div>
          <table class="c highlight">
            <tr>                
              <th class="center">Image</th>
              <th class="center hidden-xs"><?php echo $text_product; ?></th>
              <th class="center item-id">Item No.</th>
              <th class="center"><?php echo $text_quantity; ?></th>
              <th class="center"><?php echo $text_price; ?></th>
              <th class="center"><?php echo $text_total; ?></th>
            </tr>
            <?php foreach ($products as $product) { ?>
            <tr>                
              <td class="center"><a href="https://www.beststoreitems.com/index.php?controller=product&product_id=<?php echo $product['id']; ?>" target="_blank"><img src="<?php echo $product['thumb']?>"></a></td>
  <td class="left hidden-xs"><a target="_blank" style="color:#0000FF; text-decoration:underline;" href="https://www.beststoreitems.com/index.php?controller=product&product_id=<?php echo $product['id']; ?>"><?php echo $product['name']; ?></a>
            <?php foreach ($product['option'] as $option) { ?>
                <br />
                <small> - <?php echo $option['name']; ?> <?php echo $option['value']; ?></small>
                <?php } ?>
              </td>
              <td class="center item-id"><?php echo $product['id']; ?></td>
              <td class="center"><?php echo $product['quantity']; ?></td>
              <td class="center"><?php if (!$product['discount']) { ?>
                <?php echo $product['price']; ?>
                <?php } else { ?>
                <span class="price_old"><?php echo $product['price']; ?></span><br />
                <span class="price_new"><?php echo $product['discount']; ?></span>
              <?php } ?></td>
              <td class="center"><?php echo $product['total']; ?></td>
            </tr>
            <?php } ?>
          </table>
          <br />
          <div class="f clearfix" style="position:relative;">    
              
            <table style="float:right;">    
                
              <?php foreach ($totals as $total) { ?>
                
              <tr>
                  
                <td class="right" colspan="4" style="padding-right:10px;"><?php echo $total['title']; ?></td>
                  
                <td class="right"><?php  echo $total['text'];?></td>
                  
              </tr>
                
              <?php } ?>     
                
              <?php if (strcasecmp($payment_method_code, "aliexpress")==0 && $Currency!='USD') { ?>  
                
              <tr>
                  
                  <td class="right" colspan="4" style="padding-right:10px;"><font color="#FF0000">(1 USD=<?php echo round($ApplyMoney/$ApplyUSD,2)?> <?php echo $Currency?>)</font>You need pay:</td>
                  
                  <td class="right" style="color:red;">US$<?php echo $ApplyUSD?></td>
                  
              </tr>   
                
              <?php }?>
                
            </table>       
              
            <span style=" position:absolute;top:32px;right:210px;"><a target="_blank" href="index.php?controller=knowledge_base&knowledge_id=6" style="font-size:14px; color:#0033FF;">What is our vip policy?</a></span>
              
          </div>
          <?php if ($comment) { ?>
          <div class="d"><b><?php echo $text_your_comments; ?></b></div>
          <div class="e"><?php echo $comment; ?></div>
          <?php } ?>
            
          <div class="e">
            <form action="index.php?controller=potential_order&apply_coupon=1" method="post" enctype="multipart/form-data">    
              <input type="hidden" id="coupon_vaild" value="<?php echo $coupon_vaild?>" />                    
              <table width="100%">                  
                <tr>
                  <td class="right" width="1"><input type="hidden" name="reference" value="<?php echo $reference; ?>" /></td>    
                  <td class="right"><font color="#0000FF">(Please input your coupon code, then click on APPLY CODE button)</font>Coupon:</td>
                  <td class="right" width="1"><input type="text" name="coupon" value="<?php echo $coupon; ?>" /></td>               
      <td class="right" width="1"><input type="image" src="https://www.beststoreitems.com/catalog/template/beststoreitems/image/applycode.gif" style="width:57px; height:20px;" value="<?php echo $button_update; ?>" /></td>
                </tr>
              </table>
            </form>
          </div>
          <div class="buttons" style="margin-top:25px;">
            <table width="100%"><tr>
                <td align="left" class="blak">    
                  <a style="margin:0;" onclick="window.history.back(-1)" class="btn_button btn_gray"><i class="icon-back"></i>Back to Account</a>                  
                </td>	                
                <td align="center" class="cancel">
                  <form action="index.php?controller=potential_order&action=<?php echo $action;?>&reference=<?php echo $reference;?>" method="post" enctype="multipart/form-data"> 
                    <div style="">
                    <input type="submit" value="<?php echo ucfirst($action); ?> This Order" class="btn_button btn_orange"></div> 
                  </form>                  
                </td>                
                <td align="right">   
                  
                  <form onsubmit="return check_payment_setting();" id="potential_order" action="<?php echo $payment_url; ?>" method="post" enctype="multipart/form-data" target="_blank">  
                    
                    <input type="hidden" id="payment_method_code" value="<?php echo $payment_method_code?>" />
                    
                    <input type="hidden" id="reference" name="reference" value="<?php echo $reference?>" />  
                    
                    <input type="hidden" id="ApplyUSD" name="ApplyUSD" value="<?php echo $ApplyUSD?>" />
                    
                    <input type="hidden" id="ApplyMoney" name="ApplyMoney" value="<?php echo $ApplyMoney?>" />  	
                    
                    <input type="hidden" id="Currency" name="Currency" value="<?php echo $Currency?>" /> 	
                    
                    <?php if ((strcasecmp($payment_method_code, "visa")==0)||(strcasecmp($payment_method_code, "master")==0)) { ?>
                    
                    <textarea id="alipay_js_return" name="alipay_js_return" style="display:none;"></textarea>  
                    
                    <?php } ?>
                    
                    <?php if (strcasecmp($payment_method_code, "amopay")==0) { ?>  
                    
                    <input type="hidden" id="MerchantOrderID" name="MerchantOrderID" value="<?php echo $MerchantOrderID?>" /> 
                    
                    <input type="hidden" id="SubmitTime" name="SubmitTime" value="<?php echo $SubmitTime?>" />                        
                    
                    <textarea id="Post_AttachDetails" name="AttachDetails" style="display:none;"></textarea>
                    
                    <textarea id="Post_PostSecure" name="PostSecure" style="display:none;"></textarea>            
                    
                    <textarea id="Post_SecureHash" name="SecureHash" style="display:none;"></textarea>  	
                    
                    <textarea id="Post_SecureHashUsd" name="SecureHashUsd" style="display:none;"></textarea>  
                    
                    <?php } ?>
                    <button class="btn_button btn_orange" name="checkout" type="submit"><i class="icon_safety"></i>Proceed to pay</button>      
                  </form>
                  
                </td>
                
                </tr>
                
            </table>
            <?php if ($payment_method_code=='aliexpress123') { ?>
              
      <div class="clearfix aliex">      
        
        <p class="heading1">How to pay on aliexpress with 4 steps.</p>
        
        <p>read direction as below, then click on <a href="/index.php?controller=go_aliexpress" target="_blank" style="text-decoration:underline;"><font size="3" color="red">Proceed to pay</font></a> button, it will take you to our store on aliexpress.</p>
        
        <div class="western_box">
          
          <!--h2>Step 1. Click on any a US $1 product in our store</h2-->
          
          <p><img src="https://www.beststoreitems.com/catalog/template/beststoreitems/image/aliexpress/step1.jpg"></p>
          
          <!--h2>Step 2. Add this item to shopping cart</h2-->
          
          <p><img src="https://www.beststoreitems.com/catalog/template/beststoreitems/image/aliexpress/step2.jpg"></p>
          
          <!--h2>Step 3. Modify the quantity to your order amount</h2-->
          
          <p><img src="https://www.beststoreitems.com/catalog/template/beststoreitems/image/aliexpress/step3.jpg"></p>
          
          <!--h2>Step 4. Fill in the same address as you put on beststoreitems</h2-->
          
          <p><img src="https://www.beststoreitems.com/catalog/template/beststoreitems/image/aliexpress/step4.jpg"></p>        
          
          </div>	
        
        <p style="margin-top:15px;">
          
          <strong>Notes:</strong>&nbsp;&nbsp;you need pay to us on aliexpress in US dollars, do nothing and just wait our process in 12 hours once paid.</p>
        
      </div>
              
     <?php } ?>   
              
      </div>       
            
      </div>
</div>
<script type="text/javascript">
	$('#post_detail').click(function() {
		$("#payment_method").css('display', 'block')
	})
	
	$('#close').click(function() {
		$("#payment_method").css('display', 'none')
	})
	
	function postForm() {
		document.getElementById('formDetail').submit();
	}
</script>

