Skip to Content Skip to Menu

🌲 Merry Christmas! Great Savings on Professional and Developer Memberships! Get 25% off now with code XMAS-2025!

CBSubs Auto Actions not firing on PayPal payment completion

  • liaskas
  • liaskas
  • ONLINE
  • Posts: 504
  • Thanks: 42
  • Karma: 3
  • Add-ons
2 hours 6 minutes ago #342807 by liaskas
Website credentials and sandbox paypal account for test payments have been send by PM.
Thank you Krileon.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 49928
  • Thanks: 8533
  • Karma: 1465
55 minutes ago #342811 by krileon
Have reviewed your install. The PHP in your auto action isn't functional. Things like the following are not valid.
Code:
$basket = $variables->getCurrentBasket(); $payment = $variables->getPayment();

$variables is an array of variables sent by the trigger. They increment from left to right. This is all shown under the Global tab for the onCPayAfterPaymentStatusChange trigger. Specifically the following.
Code:
var1 = &$user var2 = &$paymentBasket var3 = &$subscriptions var4 = $unifiedStatus var5 = $previousUnifiedStatus var6 = $occurrences var7 = $autorecurring_type var8 = $autorenew_type

So for example your PHP should just be the following.
Code:
$basket = $variables['var2'];

As for the below. That function does not exist.
Code:
$payment = $variables->getPayment();

You should see this information with examples in the trigger fieldset under the Global tab. As for your query auto action you're trying to substitute in things that do not exist.
Code:
( '[USER_ID]', '[INVOICE_ID]', '[PLAN_ID]', '[INVOICE_NO]', '[TRANSACTION_ID]', 'paid', UTC_TIMESTAMP(), '[DATE_PAID]', '[ADDRESS_COUNTRY]', '[CURRENCY]', '[TOTAL_PRICE]', '[TAX_AMOUNT]', '[TOTAL_PRICE]', 'paypal', 'autoaction' );

The only substitution here that's valid is [user_id]. You need to retrieve the rest of that information from variables. So that query is probably failing depending on the structure of the table. Especially datetime columns since you're basically trying to set its value to a non-datetime string since the substitution [DATE_PAID] doesn't exist. This is specifically why I was instructing you to test with an Email action. It helps confirm everything is working to pinpoint the problem.

Based off the above you're needing payment data from like 3 different tables. A basket contains multiple payment items. So getting plan id doesn't make sense. There could be 3 plans in a basket or 3 plans in a payment. The best I can provide is the following. var2 being a payment basket object isbasically just a row in the _cbsubs_payment_baskets database table. So what information you see there you can easily retrieve with substitutions.
Code:
( '[user_id]', '[var2_invoice]', # '[PLAN_ID]', this doesn't exist in _cbsubs_payment_baskets as a basket can contain multiple plans # '[INVOICE_NO]', this is redundant to INVOICE_ID '[var2_txn_id]', 'paid', UTC_TIMESTAMP(), '[var2_time_paid]', '[var2_address_country]', # is the full country need or country code? if code use [var2_address_country_code] '[var2_mc_currency]', '[var2_mc_gross]', '[var2_tax]', # this isn't guaranteed and can be NULL # '[TOTAL_PRICE]', this is redundant to TOTAL_PRICE 'paypal', 'autoaction' );

I don't really know what to suggest at this point. I don't know what information is supposed to be vital to this table or why this is necessary given CBSubs > Payments view. If you need plan id for example then you need to log an entry per-plan so that would be subscription state change and not payment basket state change and if you're needing that then using CBSubs SQL Actions will be the by far simplest solution since it has CBSubs substitutions that can get a bunch of the information you're needing.


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