[SOLVED] Trying to find out when onCPayUserStateChange is triggered

8 years 6 months ago - 8 years 6 months ago #272248 by c_schmitz
Hi!

In the SQL Actions plugin to CBSubs, there's a line saying:

// } elseif ( ( $status == 'C' ) && ( $cause == 'SubscriptionDeactivated' ) ) { when the Cancel payment link is clicked: nothing to do here.

Should I understand by this that the trigger is triggered when I press cancel payment?

I've tried to insert a couple of error_log, but get no reaction. The class and function is registered like in SQL Actions (code more or less copied). Is it also triggered when clicking "Upgrade"?

Any help appreciated.

Regards
Olle
LimeSurvey.org

Please Log in to join the conversation.

8 years 6 months ago #272270 by nant

Please Log in to join the conversation.

8 years 6 months ago #272290 by krileon
onCPayUserStateChange is triggered any time a subscription state changes. This could be from unpaid to active, expired to renewed, or active to cancelled, etc..


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 to join the conversation.

8 years 6 months ago - 8 years 6 months ago #272356 by c_schmitz

krileon wrote: onCPayUserStateChange is triggered any time a subscription state changes. This could be from unpaid to active, expired to renewed, or active to cancelled, etc..


Any way I can call my trigger method programatically, with the correct arguments? For testing purposes. Say, as a unit-test.

Please Log in to join the conversation.

8 years 6 months ago #272360 by c_schmitz
I cannot get this trigger to fire, for some reason... My code so far:
global $_PLUGINS;

$_PLUGINS->registerFunction('onCPayUserStateChange', 'onCPayUserStateChange', 'LimeSurveyOnPay' );
$_PLUGINS->registerFunction('onBeforeUserProfileDisplay','test','LimeSurveyOnPay');

class LimeSurveyOnPay extends cbTabHandler {

        public function test() {
                error_log("test");  // This works when user profile is shown
        }

        public function onCPayUserStateChange( &$user, $status, $planId, $replacedPlanId, &$integrationParams, $cause, $reason, /** @noinspection PhpUnusedParameterInspection */ $now, &$subscription ) {
            error_log("onCPayUserStateChange");  // This does not work when payment is done
        }

}

What am I doing wrong?

Please Log in to join the conversation.

8 years 6 months ago #272381 by krileon
I've no idea where you're calling this from. Is it from a CB plugin, CBSubs plugin, or is it from outside of CB? If it's from outside of CB you need to first load CB API then load CBs plugins. I've attached an installable example CBSubs plugin that you could modify to fit your needs. Please note the plugin must be published and public for it to reliably act on triggers.


File Attachment:

File Name: cbsubsexample.zip
File Size:2 KB


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.
Attachments:

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.269 seconds

Facebook Twitter LinkedIn