<?php
  /**
   * AlertPay Form
   *
   * @package Digital Downloads Pro
   * @author wojoscripts.com
   * @copyright 2010
   * @version $Id: form.tpl.php, v2.00 2011-04-20 10:12:05 gewa Exp $
   */
  if (!defined("_VALID_PHP"))
      die('Direct access to this location is not allowed.');
	  
   $cartrow = $content->getCartContent();
   $totalrow = $content->getCartTotal();
?>
<?php $url = ($row['demo'] == '0') ? 'sandbox.alertpay.com/sandbox/checkout' : 'www.alertpay.com/PayProcess.aspx';?>
<br />
<div class="box">
  <form action="https://<?php echo $url;?>" method="post" id="ap_form" name="pp_form">
    <span class="input-out"><input type="image" src="<?php echo SITEURL.'/gateways/'.$row['dir'].'/'.$row['displayname'].'_big.png';?>" name="submit" class="tooltip" title="Pay With AlertPay" alt="" onclick="document.ap_form.submit();"/></span>
    <input type="hidden" name="ap_purchasetype" value="item"/>
    <input type="hidden" name="ap_merchant" value="<?php echo $row['extra'];?>" />
    <input type="hidden" name="ap_returnurl" value="<?php echo SITEURL;?>/account.php" />
    <input type="hidden" name="ap_currency" value="<?php echo ($row['extra2']) ? $row['extra2'] : $core->currency;?>" />
    <input type="hidden" name="apc_1" value="<?php echo $user->uid.'_'.$user->sesid;?>" />
    <?php if($totalrow['coupon'] <> 0):?>
    <input type="hidden" name="ap_discountamount" value="<?php echo $totalrow['coupon'];?>" />
    <?php endif;?>
	<?php $x = 0;?>
    <?php foreach ($cartrow as $crow):?>
    <?php $x++; ?>
    <input type="hidden" name="ap_itemname_<?php echo $x;?>" value="<?php echo $crow['title'];?>" />
    <input type="hidden" name="ap_itemcode_<?php echo $x;?>" value="<?php echo $crow['pid'];?>" />
    <input type="hidden" name="ap_quantity_<?php echo $x;?>" value="<?php echo $crow['total'];?>" />
    <input type="hidden" name="ap_amount_<?php echo $x;?>" value="<?php echo $crow['price'];?>" />
	<?php endforeach;?>
    <?php unset($crow);?>
  </form>
</div>