paystack/views/payment.php
2025-01-19 12:18:55 +00:00

101 lines
4.7 KiB
PHP

<?php defined('BASEPATH') or exit('No direct script access allowed'); ?>
<?php echo payment_gateway_head(_l('payment_for_invoice') . ' ' . format_invoice_number($invoice->id)); ?>
<body class="gateway-payment">
<div class="container">
<div class="col-md-8 col-md-offset-2 mtop30">
<!-- Payment Header -->
<div class="mbot30 text-center">
<h2 class="bold"><?php echo _l('payment_for_invoice'); ?></h2>
<h3 class="bold"><?php echo format_invoice_number($invoice->id); ?></h3>
</div>
<!-- Invoice Details -->
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title"><?php echo _l('invoice_details'); ?></h4>
</div>
<div class="panel-body">
<div class="row">
<div class="col-md-6">
<p><strong><?php echo _l('invoice_date'); ?>:</strong><br>
<?php echo _d($invoice->date); ?>
</p>
<p><strong><?php echo _l('due_date'); ?>:</strong><br>
<?php echo _d($invoice->duedate); ?>
</p>
</div>
<div class="col-md-6">
<p><strong><?php echo _l('invoice_total'); ?>:</strong><br>
<?php echo app_format_money($invoice->total, $invoice->currency_name); ?>
</p>
<p><strong><?php echo _l('amount_due'); ?>:</strong><br>
<?php echo app_format_money($payment_data['amount'], $payment_data['currency']); ?>
</p>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Payment Button -->
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title"><?php echo _l('payment_details'); ?></h4>
</div>
<div class="panel-body">
<div id="payment-loading" class="text-center hide">
<i class="fa fa-spinner fa-spin fa-3x"></i><br />
<?php echo _l('processing_payment'); ?>
</div>
<button type="button" id="payWithPaystack" class="btn btn-success btn-block btn-lg">
<i class="fa fa-lock pad-right-sm"></i> <?php echo _l('pay_securely'); ?>
</button>
<div class="mtop15 text-center">
<img src="<?php echo module_dir_url('paystack', 'assets/img/secured-by-paystack.png'); ?>"
alt="Secured by Paystack" style="max-height: 40px;">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="https://js.paystack.co/v1/inline.js"></script>
<script>
document.getElementById('payWithPaystack').onclick = function() {
// Show loading
document.getElementById('payment-loading').classList.remove('hide');
this.disabled = true;
let handler = PaystackPop.setup({
key: '<?php echo $this->paystack_gateway->getSetting('paystack_public_key'); ?>',
email: '<?php echo $client->email; ?>',
amount: <?php echo $payment_data['amount'] * 100; ?>,
currency: '<?php echo $payment_data['currency']; ?>',
ref: '<?php echo 'INV_' . $invoice->id . '_' . time(); ?>',
metadata: {
invoice_id: '<?php echo $invoice->id; ?>',
client_id: '<?php echo $invoice->clientid; ?>'
},
callback: function(response) {
window.location.href = '<?php echo site_url('paystack/verify_payment/'); ?>' + response.reference;
},
onClose: function() {
// Hide loading and enable button
document.getElementById('payment-loading').classList.add('hide');
document.getElementById('payWithPaystack').disabled = false;
alert('<?php echo _l('payment_cancelled'); ?>');
}
});
handler.openIframe();
}
</script>
</body>
</html>