Skip to Content Skip to Menu

[SOLVED] Trying to find out when onCPayUserStateChange is triggered

  • GUEST
9 years 2 days ago - 8 years 11 months ago #272248 by
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
Last edit: 8 years 11 months ago by krileon.

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

  • nant
  • nant
  • OFFLINE
  • Posts: 12339
  • Thanks: 1467
  • Karma: 877
9 years 2 days ago #272270 by nant

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48435
  • Thanks: 8275
  • Karma: 1443
9 years 2 days 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 or Create an account to join the conversation.

  • GUEST
9 years 1 day ago - 9 years 1 day ago #272356 by

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.
Last edit: 9 years 1 day ago by .

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

  • GUEST
9 years 1 day ago #272360 by
I cannot get this trigger to fire, for some reason... My code so far:
Code:
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 or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48435
  • Thanks: 8275
  • Karma: 1443
9 years 1 day 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 or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum