Skip to Content Skip to Menu

[#7098] onCPayUserStateChange only trigger from backend

  • LnG
  • LnG
  • OFFLINE
  • Posts: 37
  • Thanks: 2
  • Karma: 0
6 years 7 months ago - 6 years 7 months ago #303408 by LnG
I'm exporting donations to an external database, first I tried with SQL Action but nothing fires at all there, tested with simple queries to an external database and nothing.

So I turned to AutoAction and got it to work perfect, tested by addding the donation from backend on a user. But then when someone actually donated and payed using paypal it was not triggered anymore so I'm abit confused why.

onCPayUserStateChange
[var3] Equal to 3
[var2] Equal to A

I use this to fire a simple php script that fetch the donation amount from the last donation made by the user and insert it into the external database. Works perfect from the backend on any user I tried.
Code:
(connecting to joomla and external database) $userid = $user->user_id; $result = $db2->query('SELECT * FROM `jos_cbsubs_donations` WHERE `user_id` = '.$userid.' AND `plan_id` = 3 ORDER BY `id` DESC LIMIT 1'); foreach ($result as $row) { $amount = $row['amount']; } $db->query('INSERT INTO `donations` (`user_id`, `date`, `donation`) VALUES ('.$userid.', UNIX_TIMESTAMP(), '.$amount.')');
Last edit: 6 years 7 months ago by krileon. Reason: Added [#7098] tag to subject

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48495
  • Thanks: 8284
  • Karma: 1443
6 years 7 months ago #303422 by krileon

I'm exporting donations to an external database, first I tried with SQL Action but nothing fires at all there, tested with simple queries to an external database and nothing.

Should work perfectly fine for donations. There are no renewals for donation/merchandise plan so it should always fire the "Activation" state for integrations for donations/merchandise plans.

So I turned to AutoAction and got it to work perfect, tested by addding the donation from backend on a user. But then when someone actually donated and payed using paypal it was not triggered anymore so I'm abit confused why.

No idea, payment method should be irrelevant. You are only checking the activate state though. Is the payment pending at PayPal? Does it work fine from frontend using the dummy test gateway?


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.

  • LnG
  • LnG
  • OFFLINE
  • Posts: 37
  • Thanks: 2
  • Karma: 0
6 years 7 months ago - 6 years 7 months ago #303427 by LnG
Well I tested SQL Action with a simple insert query with fake information that did work through phpmyadmin, the database information was correct and the query was on Activation, nothing. I only tried this adding a donation through the backend, never tested it from the frontend with a real donation, should make no difference?

SQL Action is published and using version 4.2.0+build.2018.03.16.15.25.02.efb5cc37c
CB Subs 4.2.0+build.2018.03.16.15.25.02.efb5cc37c
AutoAction 7.2.0+build.2018.03.15.18.56.12.5d366d3e0
CB Version 2.1.3
Joomla version 3.8.2

All donations from backend manually and frontend using paypal are showing up in the donation list as Active. Maybe there is an old bugg here and I just need to update, Im worried about updating though since my CB Subs has expired and Im not sure about compability if I update CB.

I have no dummy gateway setup, will look into this since it could be useful for testing. The payment is not pending on paypal, I get redirected back to the site and it changes to Active in the donation list. But the phpscript isnt fired or it isnt getting the userid from frontend maybe, Im lost.

Updatelogs from Paypal donation:
Donation record created By user
Donation paid and activated By system
Old value R new value A

Updatelogs from backend donation:
Donation record created By admin
Donation paid and activated By admin
Old value I new value A
On this one it also has old value parent_plan 0 and parent_subscription 0 and new value for those is nothing, this is the only difference I see when checking the logs.

Edit: Removed userid and amount fetch from the phpscript and tested with a fake query to see if the was atleast triggered and it was not. I guess next step is to update everything to the latest version. Just noticed my CBSubs hasnt expired yet so I could update.
Last edit: 6 years 7 months ago by LnG. Reason: Added autoaction version

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48495
  • Thanks: 8284
  • Karma: 1443
6 years 7 months ago #303429 by krileon
Remove your "[var2] Equal to A" condition and retry as it maybe the state check that's causing an issue.


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.

  • LnG
  • LnG
  • OFFLINE
  • Posts: 37
  • Thanks: 2
  • Karma: 0
6 years 7 months ago - 6 years 7 months ago #303431 by LnG
Removed the condition but it did not trigger.

However I have now decided to put my website offline and turn on error messaging and got this:
Fatal error: Class 'cbDatabase' not found in components/com_comprofiler/plugin/user/plug_cbpaidsubscriptions/plugin/cbsubssqlactions/cbsubs.sqlactions.php on line 89

I did not bother to check why the backend crashed everytime I added a donation, since the donation itself worked from the backend, and since it does not crash when donating from the frontend I did not see the connection but maybe this is the culprit.

I also wrote the wrong version of AutoAction, I have AutoAction 6.3.7+build.2017.08.01.23.45.46.6a2833787 but this does not matter if I can get sqlaction to work instead.

Edit: Disabled sqlaction and then the autoaction started to work, so this can be considered solved. Although would be glad to know whats wrong with my sqlaction, I updated it but that did not fix it.
Last edit: 6 years 7 months ago by LnG.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48495
  • Thanks: 8284
  • Karma: 1443
6 years 7 months ago #303438 by krileon
Thank you for providing the error. Was exactly what I needed to track this down. Appears to be a bug in the SQL Actions integrations external database connection API. I've added a bug ticket and submitted a fix for review and merge for next CBSubs build.

#7098


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