Skip to content

Commit

Permalink
Merge pull request #161 from razorpay/cron-confirmation
Browse files Browse the repository at this point in the history
PO-94 added cron creation steps in config
  • Loading branch information
abdulwahidsharief authored Apr 2, 2024
2 parents f18f0da + 7c0bf7c commit e1f57c1
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
14 changes: 13 additions & 1 deletion admin/controller/extension/payment/razorpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

class ControllerExtensionPaymentRazorpay extends Controller
{
const WEBHOOK_URL = HTTPS_CATALOG . 'index.php?route=extension/payment/razorpay/webhook';
const WEBHOOK_URL = HTTPS_CATALOG . 'index.php?route=extension/payment/razorpay/webhook';
const WEBHOOK_CRON_URL = HTTPS_CATALOG . 'index.php?route=extension/payment/razorpay/rzpWebhookCron';

private $error = array();

Expand Down Expand Up @@ -62,6 +63,7 @@ public function index()
$data['help_key_id'] = $this->language->get('help_key_id');
$data['help_order_status'] = $this->language->get('help_order_status');
$data['help_webhook_url'] = $this->language->get('help_webhook_url');
$data['text_webhook_cron'] = sprintf($this->language->get('text_webhook_cron'), "*/5 * * * * curl --request POST " . self::WEBHOOK_CRON_URL);

if (isset($this->error['warning']))
{
Expand Down Expand Up @@ -190,6 +192,16 @@ public function index()
$data['razorpay_subscription_status'] = $this->config->get('payment_razorpay_subscription_status');
}

//Webhook Cron Status
if (isset($this->request->post['payment_razorpay_webhook_cron_status']))
{
$data['razorpay_webhook_cron_status'] = $this->request->post['payment_razorpay_webhook_cron_status'];
}
else
{
$data['razorpay_webhook_cron_status'] = $this->config->get('payment_razorpay_webhook_cron_status');
}

$this->template = 'extension/payment/razorpay';
$this->children = array(
'common/header',
Expand Down
3 changes: 3 additions & 0 deletions admin/language/en-gb/extension/payment/razorpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@
$_['text_invoice'] = 'Invoice Details';
$_['text_not_select_sub_ID'] = 'Please Select Subscription ';
$_['text_subscription_status'] = 'Enable Subscription in Settings.';
$_['text_webhook_cron_header'] = 'Set the cron job in your WHMCS site server to call the Cron URL in every 5 mins frequncy.';
$_['text_webhook_cron'] = '<ol><li>In CLI run <strong>crontab -e</strong></li><li>Add the command: <strong>%s</strong></li><li>Save.</li><li>Run: <strong>crontab -l</strong> confirm below if cron is added.</li></ol>';
$_['text_webhook_cron_confirm'] = 'Confirm Cron created.';


//tooltip
Expand Down
16 changes: 16 additions & 0 deletions admin/view/template/extension/payment/razorpay.twig
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,22 @@
</select>
</div>
</div>
<div class="form-group alert-warning">
<div class="col-sm-12">
<label>{{ text_webhook_cron_header }}</label>
{{ text_webhook_cron }}
<div class="checkbox">
<label>
{% if razorpay_webhook_cron_status %}
<input type="checkbox" name="payment_razorpay_webhook_cron_status" id="input-webhook-cron" checked="checked"/>
{% else %}
<input type="checkbox" name="payment_razorpay_webhook_cron_status" id="input-webhook-cron"/>
{% endif %}
&nbsp; {{ text_webhook_cron_confirm }}
</label>
</div>
</div>
</div>
</form>
</div>
</div>
Expand Down

0 comments on commit e1f57c1

Please sign in to comment.