Generate invoice in pdf

6 years 3 months ago #299849 by activha
Generate invoice in pdf was created by activha
Hello

I am trying to figure out a way to automatically email invoices in pdf format when a basket is marked as completed

Do you have some ideas about this ?

Thanks
Jean

Please Log in to join the conversation.

6 years 3 months ago #299855 by krileon
Replied by krileon on topic Generate invoice in pdf
You'd need s 3rd party extension or custom coding to generate the PDF. You can probably execute the 3rd party extensions API or your custom coding in CB Auto Actions using a Code action. Probably the best trigger for that is onCPayAfterPaymentStatusUpdateEvent since it's fired when payment status of a basket changes (e.g. when it's paid). The emailing can be handled by any of our usages that support attachments as long as the PDF is in an accessible location.

See the below for phpdoc regarding that trigger.

/**
 * Handles changes of payment basket $paymentBasket payment statuses events
 * This function may be called more than one time for events different than the Completed or Processed state if there are multiple notifications
 *
 * $unifiedStatus status mappings with e.g. Paypal status:
 * 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
 * @param  cbpaidPaymentBasket            $paymentBasket           CBPaid Payment basket being paid (corresponding to PayPal variable names)
 * @param  cbpaidUsersubscriptionRecord[] $subscriptions           CBPay Subscriptions being paid
 * @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'
 * @param  cbpaidPaymentNotification      $notification            notification object of the payment
 * @return void
 */
public function onCPayAfterPaymentStatusUpdateEvent( $user, $paymentBasket, $subscriptions, $unifiedStatus, $previousUnifiedStatus, $eventType, $notification )

You'll want to make sure $unifiedStatus ([var4]) is Completed or Processed in your action.


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.

6 years 1 month ago - 6 years 1 month ago #302047 by activha
Replied by activha on topic Generate invoice in pdf
Thanks

With this trigger and if $unifiedStatus ([var4]) = Pending, do we have access to [INVOICE_CONTENT_HTML] in a code auto action ?

If I remember well of last year, it was impossible to access this wen the status was pending with the auto action in case of an offline payment for instance ([var2_payment_method] = offline )

Did it change ?

Please Log in to join the conversation.

6 years 1 month ago #302049 by krileon
Replied by krileon on topic Generate invoice in pdf

do we have access to [INVOICE_CONTENT_HTML] in a code auto action ?

No, but since it's a code action you've access to PHP directly. That trigger includes the basket object as var2, which you can access using $variables. The substitution INVOICE_CONTENT_HTML is just the below API call on the basket.

INVOICE_CONTENT_HTML
$return = $variables['var2']->displayInvoice( $user, true, false );


INVOICE_ITEMS_HTML
$return = $variables['var2']->displayBasket( null, null, 'invoice' );


BASKET_CONTENT_HTML
$return = $variables['var2']->displayBasket( null, null );


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.

6 years 1 month ago #302052 by activha
Replied by activha on topic Generate invoice in pdf
Sorry I meant access INVOICE_CONTENT_HTML in an email auto action and not a code auto action.

That would allow us to directly send an invoice copy by email to our own accounting system.

So can we now use this combination ?

users : all
trigger : onCPayAfterPaymentStatusUpdateEvent
condition : $unifiedStatus ([var4]) = Pending
email html : [INVOICE_CONTENT_HTML]

Please Log in to join the conversation.

6 years 1 month ago #302054 by beat
Replied by beat on topic Generate invoice in pdf
CBSubs does not generate PDF invoices, and it's not planed to add that for the time benig.

Would this help www.joomlapolis.com/forum/255-developer-members-support/238569-cb-subs-invoices#302053 ?

Beat - Community Builder Team Member

Before posting on forums: Read FAQ thoroughly -- Help us spend more time coding by helping others in this forum, many thanks :)
CB links: Our membership - CBSubs - Templates - Hosting - Forge - Send me a Private Message (PM) only for private/confidential info

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.227 seconds

Facebook Twitter LinkedIn