How to use custom message in a payment plugin

Phoca Cart - complex e-commerce extension
User avatar
b2z
Phoca Enthusiast
Phoca Enthusiast
Posts: 52
Joined: 09 Dec 2016, 13:52

How to use custom message in a payment plugin

Post by b2z »

Hi Jan,

Can you please explain how to use a custom message in a payment plugin?
$message - custom message array set by plugin to override standard messages made by component.
Thank you!

Kind regards,
Dmitrijs
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 47883
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: How to use custom message in a payment plugin

Post by Jan »

Hi, the flow is following for example:

event onPCPbeforeProceedToPayment in plugin

you set some custom message (which is only assigned to orders which have download active - user orders some product which is downloadable):

$message['order_download'] = 'Some Custom message';

Such will be returned by plugin to e.g. proceedToPaymentGateway() function which returns it as part of response

There are some calls of functions which you can skip checking to simlify this explanation:
-----
This message "Some Custom message" overrides then the variable: $this->message_after_order which is returned by getMessageAfterOrder function which is stored in session "infomessage" which is then displayed
----

In the end, user who goes back e.g. from payment gateway gets custom info message in info view:
components/com_phocacart/views/info/view.html.php

(because he left eshop page, such message is stored in session)

Simple exaplained:

There is prepared info message for users who return back (or not, depends on payment plugin) from payment gateway, such message:

- is set fix in language string
- can be overriden in language file or language override
- AND can be overriden by payment plugin

If set in payment plugin, such custom message is just stored in session instead the core language string and displayed when user comes to info page.

Here you can see the example, line cca 39:
plugins/pcp/paypal_standard/paypal_standard.php

Code: Select all

// THERE ARE 3 PLACES WHERE THE MESSAGE CAN BE CREATED:
// 1) COMPONENT - components/com_phocacart/views/info/tmpl/ ...
// 2) LANGUAGE FILE - there is specific string in language file which can be customized for each e-shop (see top of ini file)
// 3) PAYMENT PLUGIN - means that payment plugin can override the component (1) and language file (2) message
// See examples:

$proceed = 1;
$message = array();
/*
// Order processed successfully made - no downloadable items
$message['order_nodownload'] 	= JText::_('COM_PHOCACART_ORDER_SUCCESSFULLY_PROCESSED')
.'</br>' . JText::_('COM_PHOCACART_ORDER_PROCESSED_ADDITIONAL_INFO');
// Order processed successfully made - downloadable items
$message['order_download'] 		= JText::_('COM_PHOCACART_ORDER_SUCCESSFULLY_PROCESSED')
.'</br>' . JText::_('COM_PHOCACART_ORDER_PROCESSED_DOWNLOADABLE_ITEMS_ADDITIONAL_INFO');
// Order and payment successfully made - no downloadable items
$message['payment_nodownload'] 	= JText::_('COM_PHOCACART_ORDER_AND_PAYMENT_SUCCESSFULLY_PROCESSED')
.'</br>' . JText::_('COM_PHOCACART_ORDER_PAYMENT_PROCESSED_ADDITIONAL_INFO');
// Order and payment successfully made - downloadable items
$message['payment_download']	= JText::_('COM_PHOCACART_ORDER_AND_PAYMENT_SUCCESSFULLY_PROCESSED')
.'</br>' . JText::_('COM_PHOCACART_ORDER_PAYMENT_PROCESSED_DOWNLOADABLE_ITEMS_ADDITIONAL_INFO');
*/

return true;
As you can see, the message can be different for different types of orders (no downloadable items, downloadable items - with or without payment, etc.)

Jan
If you find Phoca extensions useful, please support the project
Post Reply