CBsubs trigger order

5 years 6 months ago #307126 by activha
CBsubs trigger order was created by activha
Hello

We use the trigger onCPayAfterPaymentStatusUpdateEvent to send data to our pdf invoicing system.

Can you tell me if this trigger occurs before or after the promotion uses ?

It seems that recently the auto action sent the mc_gross amount before any application of our promotions, making the net amount wrong.

This works fine for payments without promotions though.

The promotion applied is a fixed amount from a CB field

Thanks for your help
Jean

Please Log in to join the conversation.

5 years 6 months ago #307129 by krileon
Replied by krileon on topic CBsubs trigger order
It's sent after the status of a payment is updated. What status change you act on is entirely up to you. Ideally you should be making sure [var4] ($unifiedStatus) is Completed or Processed to ensure the payment is complete. Example condition as follows.

[var4] Is REGEXP /Completed|Processed/

The basket is var2, which can be used to grab the amount paid which will be after promotions, but again it depends on the status you're acting on as it could be updated before the promotions are added then again after they are added. phpdoc for that trigger usage as follows.

/**
 * Event handler for onCPayAfterPaymentStatusUpdateEvent, called each time an update occurs to the payment status of the payment basket
 *
 * Paypal status mappings:
 * CB Unified status				Paypal status
 * Completed				<--		Completed
 * Processed				<--		Processed, Canceled_Reversal
 * Denied					<--		Denied, Expired, Failed, Voided
 * Refunded					<--		Reversed, Refunded, Partially-Refunded
 * Pending					<--		Pending, In-Progress
 * RegistrationCancelled	<--		A new cb registration got cancelled by user (e.g. paypal cancel payment button)
 *
 * @param  UserTable           $user                   User paying the payment basket
 * @param  cbpaidPaymentBasket $paymentBasket          Payment basket
 * @param  cbpaidSomething[]   $subscriptions          Subscriptions in the basket
 * @param  string              $unifiedStatus          New Unified status (see above)
 * @param  string              $previousUnifiedStatus  Previous Unified status (see above)
 * @param  string              $eventType              type of event (paypal type): 'web_accept', 'subscr_payment', 'subscr_signup', 'subscr_modify', 'subscr_eot', 'subscr_cancel', 'subscr_failed'
 * @return void
 */
public function onCPayAfterPaymentStatusUpdateEvent( &$user, &$paymentBasket, &$subscriptions, $unifiedStatus, $previousUnifiedStatus, $eventType )


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.
The following user(s) said Thank You: nant

Please Log in to join the conversation.

5 years 6 months ago #307154 by activha
Replied by activha on topic CBsubs trigger order
We are acting on [var2] Is REGEXP /Completed|Processed/ with onCPayAfterPaymentStatusUpdateEvent

Can you confirm that all promotions are processed before this status is updated ?

Please Log in to join the conversation.

5 years 6 months ago #307158 by krileon
Replied by krileon on topic CBsubs trigger order
onCPayAfterPaymentStatusUpdateEvent is fired when the payment status of a basket is updated. It's irrelevant whether promotions have been applied or not as that's not the purpose of that event, but typically yes they should've been applied by then but may not be the case for auto applying promotions. Promotions and Taxes modify the totalizers of a basket. Those are guaranteed completed on the onCPayAfterPaymentBasketUpdated trigger, which specifically is fired when a basket is (re)computed.


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.

5 years 6 months ago #307161 by activha
Replied by activha on topic CBsubs trigger order
So your suggestion is to use the trigger onCPayAfterPaymentBasketUpdated instead of onCPayAfterPaymentStatusUpdateEvent ?

With same [var2] Is REGEXP /Completed|Processed/ ?

Please Log in to join the conversation.

5 years 6 months ago #307164 by krileon
Replied by krileon on topic CBsubs trigger order
It depends entirely on what you're trying to do. You may even need both.


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.

Moderators: beatnantkrileon
Time to create page: 0.392 seconds

Facebook Twitter LinkedIn