Skip to content

Commit

Permalink
Adding support for underpaid orders. Closes #6
Browse files Browse the repository at this point in the history
  • Loading branch information
jaimehgb committed Jul 27, 2017
1 parent ed7c305 commit 3adde1a
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
8 changes: 7 additions & 1 deletion upload/admin/controller/payment/mycelium.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public function index() {
$this->setting('status', $this->request->post['mycelium_status']);
$this->setting('paid_status', $this->request->post['mycelium_paid_status']);
$this->setting('complete_status', $this->request->post['mycelium_complete_status']);
$this->setting('underpaid_status', $this->request->post['mycelium_underpaid_status']);
$this->setting('shifty_enabled', $this->request->post['mycelium_shifty_enabled']);
$this->setting('address_reuse_time', abs($this->request->post['mycelium_reuse_time']));

Expand Down Expand Up @@ -94,6 +95,7 @@ public function index() {
$data['entry_paid_status'] = $this->language->get('entry_paid_status');
$data['entry_confirmed_status'] = $this->language->get('entry_confirmed_status');
$data['entry_complete_status'] = $this->language->get('entry_complete_status');
$data['entry_underpaid_status'] = $this->language->get('entry_underpaid_status');
$data['entry_debug'] = $this->language->get('entry_debug');


Expand Down Expand Up @@ -121,6 +123,7 @@ public function index() {
$data['help_paid_status'] = $this->language->get('help_paid_status');
$data['help_confirmed_status'] = $this->language->get('help_confirmed_status');
$data['help_complete_status'] = $this->language->get('help_complete_status');
$data['help_underpaid_status'] = $this->language->get('help_underpaid_status');
$data['help_callback_url'] = $this->language->get('help_callback_url');
$data['help_return_url'] = $this->language->get('help_return_url');
$data['help_back_url'] = $this->language->get('help_back_url');
Expand Down Expand Up @@ -181,6 +184,7 @@ public function index() {
$data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses();
$data['mycelium_paid_status'] = (isset($this->request->post['mycelium_paid_status'])) ? $this->request->post['mycelium_paid_status'] : $this->setting('paid_status');
$data['mycelium_complete_status'] = (isset($this->request->post['mycelium_complete_status'])) ? $this->request->post['mycelium_complete_status'] : $this->setting('complete_status');
$data['mycelium_underpaid_status'] = (isset($this->request->post['mycelium_underpaid_status'])) ? $this->request->post['mycelium_underpaid_status'] : $this->setting('underpaid_status');

// #ADVANCED
$data['mycelium_callback_url'] = (isset($this->request->post['mycelium_callback_url'])) ? $this->request->post['mycelium_callback_url'] : $this->setting('callback_url');
Expand Down Expand Up @@ -378,14 +382,15 @@ public function install() {
$default_paid = null;
$default_confirmed = null;
$default_complete= null;
$default_underpaid = 'Failed'; // there is no default underpaid, needs to be added at Settings/Localisation/Order Statuses
foreach ($order_statuses as $order_status) {
if ($order_status['name'] == 'Processing') {
$default_paid = $order_status['order_status_id'];
} elseif ($order_status['name'] == 'Processed') {
$default_confirmed = $order_status['order_status_id'];
} elseif ($order_status['name'] == 'Complete') {
$default_complete = $order_status['order_status_id'];
}
}
}
// default urls
$default_notify_url = $this->url->link('payment/mycelium/callback', $this->config->get('config_secure'));
Expand Down Expand Up @@ -426,6 +431,7 @@ public function install() {
'mycelium_paid_status' => $default_paid,
'mycelium_confirmed_status' => $default_confirmed,
'mycelium_complete_status' => $default_complete,
'mycelium_underpaid_status' => $default_underpaid,
'mycelium_valid_settings' => 'false',
'mycelium_debug' => '0',
);
Expand Down
2 changes: 2 additions & 0 deletions upload/admin/language/english/payment/mycelium.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
$_['entry_status'] = 'Status';
$_['entry_paid_status'] = 'Paid Status';
$_['entry_complete_status'] = 'Complete Status';
$_['entry_underpaid_status'] = 'Underpaid Status';
$_['entry_debug'] = 'Debug Logging';
$_['entry_shifty'] = 'Enable Shifty button';
$_['entry_reuse_time'] = 'Address reuse interval';
Expand All @@ -62,6 +63,7 @@
$_['help_paid_status'] = 'A fully paid invoice awaiting confirmation';
$_['help_confirmed_status'] = 'A confirmed invoice with based on the number of confirmations set for your Gateway.';
$_['help_complete_status'] = 'A confirmed invoice with based on the number of confirmations set for your Gateway.';
$_['help_underpaid_status'] = 'An order which has been underpaid. You should add a new order status at Settings/Localisation/Order Statuses.';
$_['help_notify_url'] = 'Mycelium will post invoice status updates to this URL';
$_['help_return_url'] = 'User will be redirected here after a successful payment.';
$_['help_debug'] = 'Enabling debug will write sensitive data to a log file. You should always disable unless instructed otherwise';
Expand Down
14 changes: 14 additions & 0 deletions upload/admin/view/template/payment/mycelium.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,20 @@
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label"><span data-toggle="tooltip" title="<?php echo $help_underpaid_status; ?>"><?php echo $entry_underpaid_status; ?></span></label>
<div class="col-sm-10">
<select name="mycelium_underpaid_status" class="form-control">
<?php foreach ($order_statuses as $order_status) { ?>
<?php if ($order_status['order_status_id'] == $mycelium_underpaid_status) { ?>
<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>
<br>
<h3 class="col-sm-10 col-sm-offset-2<?php if ($error_notify_url || $error_return_url) { ?> text-danger<?php } ?>">
<?php echo $text_advanced; ?>
Expand Down
5 changes: 5 additions & 0 deletions upload/catalog/controller/payment/mycelium.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,11 @@ public function callback() {
$order_message = $this->language->get('text_progress_complete');
$this->model_payment_mycelium->freeKeychainId($keychain_id);
break;
case '3':
// underpaid :P
$order_status_id = $this->setting('underpaid_status');
$order_message = $this->language->get('text_progress_underpaid');
break;
case '4':
// paid, confirmed, overpaid actually
$order_status_id = $this->setting('complete_status');
Expand Down

0 comments on commit 3adde1a

Please sign in to comment.