Skip to content

Commit

Permalink
updating G2A for V2 API
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-wm committed Jan 11, 2016
1 parent 3fa4f10 commit 8131e2f
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 14 deletions.
7 changes: 7 additions & 0 deletions upload/admin/controller/payment/g2apay.php
Expand Up @@ -37,6 +37,7 @@ public function index() {
$data['entry_complete_status'] = $this->language->get('entry_complete_status');
$data['entry_rejected_status'] = $this->language->get('entry_rejected_status');
$data['entry_cancelled_status'] = $this->language->get('entry_cancelled_status');
$data['entry_pending_status'] = $this->language->get('entry_pending_status');
$data['entry_refunded_status'] = $this->language->get('entry_refunded_status');
$data['entry_partially_refunded_status'] = $this->language->get('entry_partially_refunded_status');

Expand Down Expand Up @@ -108,6 +109,12 @@ public function index() {
$data['g2apay_cancelled_status_id'] = $this->config->get('g2apay_cancelled_status_id');
}

if (isset($this->request->post['g2apay_pending_status_id'])) {
$data['g2apay_pending_status_id'] = $this->request->post['g2apay_pending_status_id'];
} else {
$data['g2apay_pending_status_id'] = $this->config->get('g2apay_pending_status_id');
}

if (isset($this->request->post['g2apay_refunded_status_id'])) {
$data['g2apay_refunded_status_id'] = $this->request->post['g2apay_refunded_status_id'];
} else {
Expand Down
1 change: 1 addition & 0 deletions upload/admin/language/en-gb/payment/g2apay.php
Expand Up @@ -25,6 +25,7 @@
$_['entry_complete_status'] = 'Complete Status:';
$_['entry_rejected_status'] = 'Rejected Status:';
$_['entry_cancelled_status'] = 'Canceled Status:';
$_['entry_pending_status'] = 'Pending Status:';
$_['entry_refunded_status'] = 'Refunded Status:';
$_['entry_partially_refunded_status'] = 'Partially Refunded Status:';

Expand Down
14 changes: 14 additions & 0 deletions upload/admin/view/template/payment/g2apay.tpl
Expand Up @@ -201,6 +201,20 @@
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label"><?php echo $entry_pending_status; ?></label>
<div class="col-sm-10">
<select name="g2apay_pending_status_id" class="form-control">
<?php foreach ($order_statuses as $order_status) { ?>
<?php if ($order_status['order_status_id'] == $g2apay_pending_status_id) { ?>
<option value="<?php echo $order_status['order_status_id']; ?>" selected="selected"><?php echo $order_status['name']; ?></option>
<?php } else { ?>
<option value="<?php echo $order_status['order_status_id']; ?>"><?php echo $order_status['name']; ?></option>
<?php } ?>
<?php } ?>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label"><?php echo $entry_refunded_status; ?></label>
<div class="col-sm-10">
Expand Down
12 changes: 6 additions & 6 deletions upload/admin/view/template/payment/g2apay_order.tpl
Expand Up @@ -55,17 +55,17 @@
</table>
<script type="text/javascript"><!--
$("#btn_refund").click(function () {
// if (confirm('<?php echo $text_confirm_refund ?>')) {
if (confirm('<?php echo $text_confirm_refund ?>')) {
$.ajax({
type: 'POST',
dataType: 'json',
data: {'order_id': <?php echo $order_id; ?>, 'amount': $('#refund_amount').val()},
url: 'index.php?route=payment/g2apay/refund&token=<?php echo $token; ?>',
beforeSend: function () {
// $('#btn_refund').hide();
// $('#refund_amount').hide();
// $('#img_loading_refund').show();
// $('#g2apay_transaction_msg').hide();
$('#btn_refund').hide();
$('#refund_amount').hide();
$('#img_loading_refund').show();
$('#g2apay_transaction_msg').hide();
},
success: function (data) {
if (data.error == false) {
Expand Down Expand Up @@ -98,6 +98,6 @@
$('#img_loading_refund').hide();
}
});
// }
}
});
//--></script>
22 changes: 14 additions & 8 deletions upload/catalog/controller/payment/g2apay.php
Expand Up @@ -18,9 +18,9 @@ public function checkout() {
$order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']);

$order_data = array();

$this->load->model('extension/extension');

$totals = array();
$taxes = $this->cart->getTaxes();
$total = 0;
Expand All @@ -31,15 +31,15 @@ public function checkout() {
'taxes' => &$taxes,
'total' => &$total
);

$i = 0;

$results = $this->model_extension_extension->getExtensions('total');

foreach ($results as $result) {
if ($this->config->get($result['code'] . '_status')) {
$this->load->model('total/' . $result['code']);

// We have to put the totals in an array so that they pass by reference.
$this->{'model_total_' . $result['code']}->getTotal($total_data);

Expand All @@ -50,9 +50,12 @@ public function checkout() {
$item->name = $order_data['totals'][$i]['title'];
$item->amount = number_format($order_data['totals'][$i]['value'], 2);
$item->qty = 1;
$item->id = $order_data['totals'][$i]['code'];
$item->price = $order_data['totals'][$i]['value'];
$item->url = $this->url->link('common/home', '', true);
$items[] = $item;
}

$i++;
}
}
Expand All @@ -66,6 +69,9 @@ public function checkout() {
$item->name = $product['name'];
$item->amount = $product['price'] * $product['quantity'];
$item->qty = $product['quantity'];
$item->id = $product['product_id'];
$item->price = $product['price'];
$item->url = $this->url->link('product/product', 'product_id=' . $product['product_id'], true);
$items[] = $item;
}

Expand Down Expand Up @@ -131,7 +137,7 @@ public function success() {

if ($order_info) {
$this->load->model('payment/g2apay');

$g2apay_order_info = $this->model_payment_g2apay->getG2aOrder($order_id);

$this->model_payment_g2apay->updateOrder($g2apay_order_info['g2apay_order_id'], $g2apay_transaction_id, 'payment', $order_info);
Expand Down

0 comments on commit 8131e2f

Please sign in to comment.