Skip to Content Skip to Menu

Question about auto action related to cbsubs gateway

  • liaskas
  • liaskas
  • ONLINE
  • Posts: 418
  • Thanks: 37
  • Karma: 3
  • Add-ons
6 days 21 hours ago #340656 by liaskas
Hello...
Is there a way to have 2 gateways set in our cbsubs that will auto activate and deactivate?
Scenario...

Gateway 1 -> We want to receive payments through this gateway from 07:00 am to 20:00 pm

Gateway 2 -> We want to receive payments through this gateway from 20:00 pm to 07:00 am

Is this possible?
Can this be done with auto actions? If not, how can this be done?

Thank you.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48978
  • Thanks: 8372
  • Karma: 1453
6 days 11 hours ago #340662 by krileon
If you have auto recurring payments then no that's not doable as the gateway needs to be accessible for it to be notified of payments. If you only accept single payments then yes that should be doable using CB Auto Actions and either a CRON task or a Joomla Scheduled Task.

Can you provide some more details regarding why you'd need this? Don't think I've ever heard of timed gateways. You could toggle a coupon to adjust pricing if you're need some kind of dynamic pricing.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

  • liaskas
  • liaskas
  • ONLINE
  • Posts: 418
  • Thanks: 37
  • Karma: 3
  • Add-ons
6 days 11 hours ago #340665 by liaskas
Thank you for your reply Krileon.
I have made an auto action (cod / php) and i have set Joomla Scheduled Tasks to run.
I am waiting till 20:00 to run and see what happens. If everything works fine i will post here (if i am allowed). Please tell me.

Please Log in or Create an account to join the conversation.

  • liaskas
  • liaskas
  • ONLINE
  • Posts: 418
  • Thanks: 37
  • Karma: 3
  • Add-ons
6 days 10 hours ago #340669 by liaskas
It is not working...

Here is what i have done...

Created 2 code auto actions both with the same php code.
Code:
<?php // No direct access defined('_JEXEC') or die; // Get the Joomla Database object $db = JFactory::getDbo(); // Get the current hour $currentHour = (int)date("H"); try {     if ($currentHour >= 6 && $currentHour < 20) {         // From 06:00 to 20:00         $query1 = $db->getQuery(true)                      ->update($db->quoteName('#__cbsubs_gateway_accounts'))                      ->set($db->quoteName('enabled') . ' = 1')                      ->where($db->quoteName('id') . ' = 2');                  $query2 = $db->getQuery(true)                      ->update($db->quoteName('#__cbsubs_gateway_accounts'))                      ->set($db->quoteName('enabled') . ' = 0')                      ->where($db->quoteName('id') . ' = 5');     } else {         // From 20:00 to 06:00         $query1 = $db->getQuery(true)                      ->update($db->quoteName('#__cbsubs_gateway_accounts'))                      ->set($db->quoteName('enabled') . ' = 0')                      ->where($db->quoteName('id') . ' = 2');                  $query2 = $db->getQuery(true)                      ->update($db->quoteName('#__cbsubs_gateway_accounts'))                      ->set($db->quoteName('enabled') . ' = 1')                      ->where($db->quoteName('id') . ' = 5');     }     // Execute the queries     $db->setQuery($query1);     $db->execute();          $db->setQuery($query2);     $db->execute();     echo "Gateway accounts updated successfully."; } catch (Exception $e) {     echo "Database error: " . $e->getMessage(); } ?>

Then created 2 Scheduled Tasks of "Execute Auto Actions" type

One is running on 6 am and one is running at 20 pm.

It did not work at 20pm

Should i create Scheduled Tasks of "Execute Auto Actions" type or i should use one of the following?

Run Auto Actions

Trigger Auto Actions

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48978
  • Thanks: 8372
  • Karma: 1453
6 days 9 hours ago #340672 by krileon
Your auto action should have no Triggers selected. I would just use a Query action and supply your necessary SQL then schedule Joomla to run that task at whatever time you need. A more reliable approach is using CRON with a wget call to the URL.

I would verify your query action is working as expected by accessing its URL directly. Once confirmed working you can then deal with scheduling them. Joomla's task scheduler requires backend or frontend interactions to process the queue or it requires CRON.

Should i create Scheduled Tasks of "Execute Auto Actions" type or i should use one of the following?

Read the description of each and use whichever best fits your needs. Some logic is skipped based off the method of running the auto action. You don't need user, access, or condition processing for example.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum