function __construct($gateway = '') { $gateway = strtolower($gateway); if (empty($gateway)) { $gateway = 'paypal'; } $gateways = \site\payment::gateways(); if (!array_key_exists($gateway, $gateways)) { throw new \Exception('Gateway error.'); } else { if (!file_exists($gateways[$gateway]['adapter'])) { throw new \Exception('Gateway error.'); } else { $this->gateway_info = $gateways[$gateway]; require_once $this->gateway_info['adapter']; $this->gateway = new \Payment_Gateway(); $this->gateway_name = $gateway; } } }
function payment_gateways() { return \site\payment::gateways(); }
<h2>' . $LANG['payments_choosetopay'] . ':</h2> <form method="POST" action="#" class="buttons">'; if ($docc) { echo '<button name="credit_card"><img src="' . DEFAULT_IMAGES_LOC . '/cards.png" alt="" style="width: 50px; max-height: 30px; display: block; padding: 10px 0;" /></button>'; } if ($payment->do_direct()) { echo '<button name="pay_direct"><img src="' . $payment->gateway_info['image'] . '" alt="" style="width: 50px; max-height: 30px; display: block; padding: 10px 0;" /></button>'; } echo '<input type="hidden" name="token" value="' . $csrf . '" /> </form> <div class="choose-gateway"> ' . $LANG['payments_choosetopay'] . ': <select name="gateway" style="width: auto;">'; foreach (\site\payment::gateways() as $id => $gateway) { echo '<option value="payment.php?gateway=' . $id . '&plan=' . $_GET['plan'] . '"' . ($thegateway == $id ? ' selected' : '') . '>' . $gateway['name'] . '</option>'; } echo '</select> </div> </div>'; echo '</section> </div> <a href="index.php">' . $LANG['cancel'] . '</a> </div> </body>