Skip to content

Commit

Permalink
gateway-nimbuz class improved
Browse files Browse the repository at this point in the history
  • Loading branch information
Camoo Dev committed Jan 10, 2021
1 parent 2072f70 commit c88fcf7
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 11 deletions.
2 changes: 1 addition & 1 deletion includes/admin/send/class-wpsms-send.php
Expand Up @@ -59,7 +59,7 @@ public function render_page()
$gateway_name = Option::getOption('gateway_name');
$credit = Option::getOptions('wp_camoo_sms_gateway_credit');

if ($gateway_name && ! $credit) {
if ($gateway_name && $credit === null) {
echo '<br><div class="update-nag">' . __('You should have sufficient funds for sending sms in the account', 'wp-camoo-sms') . '</div>';

return;
Expand Down
25 changes: 20 additions & 5 deletions includes/admin/send/send-sms.php
Expand Up @@ -33,9 +33,16 @@ function () {
})
});
</script>
<?php
$options = \CAMOO_SMS\Option::getOptions('wp_camoo_sms_settings');
$gateway_name = $options['gateway_name'];
$posCamoo = strpos($gateway_name, 'camoo');
$isCamoo = $posCamoo !== false;
$currency = $isCamoo ? 'XAF' : 'Units';
?>

<div class="wrap">
<h2><?php _e('Send SMS', 'wp-camoo-sms'); ?></h2>
<h2><?php _e('Send SMS', 'wp-camoo-sms'); ?> via <?php echo strtoupper($gateway_name);?></h2>
<div class="postbox-container" style="padding-top: 20px;">
<div class="meta-box-sortables">
<div class="postbox">
Expand Down Expand Up @@ -123,11 +130,14 @@ function () {
<td>
<textarea dir="auto" cols="80" rows="5" name="wp_get_message" id="wp_get_message"></textarea><br/>
<p class="number">
<?php echo __('Your account credit', 'wp-camoo-sms') . ': XAF ' . $credit; ?>
<?php echo __('Your account credit', 'wp-camoo-sms') . ': '. sprintf('%s %s', $currency, $credit); ?>
</p>
</td>
</tr>
<?php if ($this->sms->flash == "enable") { ?>
<?php
if ($isCamoo === true) {

if ($this->sms->flash == "enable") { ?>
<tr>
<td><?php _e('Send a Flash', 'wp-camoo-sms'); ?>:</td>
<td>
Expand All @@ -139,7 +149,9 @@ function () {
<p class="description"><?php _e('Flash is possible to send messages without being asked, opens', 'wp-camoo-sms'); ?></p>
</td>
</tr>
<?php } ?>
<?php
}
?>
<tr>
<td><?php _e('SMS route', 'wp-camoo-sms'); ?>:</td>
<td>
Expand All @@ -150,7 +162,10 @@ function () {
<br/>
<p class="description"><?php echo sprintf(__("The SMS route that is used to send the message. <span style='color:#ff0000;'>The classic route works only for cameroonian mobile phone numbers.</span> <a href='%s' target='_blank'>Check Wiki for more explanation</a>", 'wp-camoo-sms'), 'https://github.com/camoo/sms/wiki/Send-a-message#optional-parameters'); ?></p>
</td>
</tr>
</tr>
<?php
}
?>
<tr>
<td>
<p class="submit" style="padding: 0;">
Expand Down
Expand Up @@ -7,9 +7,9 @@ class Nimbuz extends \CAMOO_SMS\Gateway
private $client = null;
private $http;
public $tariff = "";
public $unitrial = false;
public $unitrial = true;
public $unit;
public $flash = "enable";
public $flash = "disable";
public $isflash = false;
public $encrypt_sms = false;
public $isUnicode = false;
Expand Down Expand Up @@ -98,15 +98,20 @@ public function sendSMS()
'variables' => [
'message' => 'message',
'recipient' => 'to',
'message_id' => 'message_id',
'message_id' => 'id',
'sender' => 'from',
'response' => 'response',
]
];
$oResult = $oMessage->sendBulk($hCallback);
} else {
$oResult = $oMessage->send();
$hLog['message_id'] = \Nimbuz\Sms\Lib\Utils::getMessageKey($oResult, 'id');
if ($oResult->getResponseStatus() === 'KO') {
$hLog['response'] = $oResult->getBody();
$this->log($hLog, 'error');
return new \WP_Error('send-sms', 'Message could not be sent');
}
$hLog['message_id'] = $oResult->getId();
$hLog['response'] = $oResult;
$this->log($hLog);
}
Expand Down Expand Up @@ -137,7 +142,7 @@ public function getCredit()
$oBalance = call_user_func_array($this->oBalance, [$this->username, $this->password]);
try {
$ohBalance = $oBalance->get();
return $ohBalance->balance->balance;
return $ohBalance->getValue();
} catch (\Nimbuz\Sms\Exception\NimbuzSmsException $e) {
return new \WP_Error('account-credit', $e->getMessage());
}
Expand Down

0 comments on commit c88fcf7

Please sign in to comment.