Developer guide

The developer's guide provides technical information, suggestions and answers of frequently asked questions about the Virtual Currency. If you would like to use this extension as payment gateway on your website, you should use Virtual Currency API, Joomla plugin events and its events to integrate it with your extensions.

How to extend Virtual Currency?

Joomla provides an excellent opportunity for developers and other third parties to extend the capabilities of the CMS through a variety of extensions.

You can extend the system developing Components, Modules or Plug-ins.

If you are new in Joomla, you can start from Developer Documentation to learn more about options to extend its capabilities.

What is Virtual Currency API?

This is a library that is part of the platform and you should use it to interact with the platform.

You will find a documentation about Virtual Currency API on the ITPrism APIs site.

Plugin Events

Information about all plug-in events provided by the extension. You will be able to use them to extend your application, developing own plug-ins.

 

onPreparePayment

Description

This is a request for information that should be placed on the payment wizard, step "Cart". This generates an HTML code providing functionality for processing payments.

Parameters

context - The context of the content being passed to the plugin - this is the component name and wizard step name (e.g. com_virtualcurrency.payment.prepare). Use this to check whether you are in the desired context for the plugin.

&item - A reference to the project object.

&params - A reference to an object that provides parameters of the component.

Return Value

String. Returned value from this event will be displayed on step "Cart" of the payment wizard.

Example

VirtualcurrencyPayment - Payment Gateway

Used in files

components/com_virtualcurrency/views/cart/view.html.php

 

onPaymentNotify

Description

This event will be invoked when the system receives notification data from a payment gateway. That event should process the transaction.

Parameters

context - The context of the content being passed to the plugin - this is the component name, the string "notify" and the name of the payment service (e.g. com_virtualcurrency.notify.paypal). Use this to check whether you are in the desired context for the plugin.

&params - A reference to an object that provides parameters of the component.

Return Value

This event returns an array that contains the name of the payment gateway and objects of a project, reward, transaction and payment session.

$result = array(
   "item"             => {object},
   "transaction"      => {object},
   "payment_session"  => {object},
   "service_provider" => {object},
   "service_alias"    => "PayPal"
);
Example

VirtualcurrencyPayment - PayPal

Used in files

components/com_virtualcurrency/controllers/notifier.raw.php

 

onAfterPayment

Description

This event will be triggered when the system completes with the processing of transaction. This will be invoked after the event onPaymentNotify.

Parameters

context - The context of the content being passed to the plugin - this is the component name, the string "notify" and the name of the payment service (e.g. com_virtualcurrency.notify.paypal). Use this to check whether you are in the desired context for the plugin.

&item - A reference to bought item object.

&transaction - A reference to transaction object.

&paymentSession - A reference to payment session object.

&params - A reference to an object that provides parameters of the component.

Return Value

None. It does not return value.

Example

Virtualcurrency\Payment\Plugin

Used in files

components/com_virtualcurrency/controllers/notifier.raw.php

 

onPaymentsCheckout

Description

This event is invoked when a user makes a payment. It is used from payment services which provide preapproved payments. This event will create a preapproved transaction record.

Parameters

context - The context of the content being passed to the plugin - this is the component name, the string "payments.checkout" and the name of the payment service (e.g. com_virtualcurrency.payments.checkout.paypal). Use this to check whether you are in the desired context for the plugin.

&item - A reference to the project object.

&params - A reference to an object that provides parameters of the component.

Return Value

Returns an associative array.

array(
"redirect_url" => "..." // A URL where the system should redirect the user when payment processing completes.
);
Example

VirtualcurrencyPayment - Payment Gateway

Used in files

components/com_virtualcurrency/controllers/payments.php

 

onPaymentsDoCheckout

Description

This event will be executed when the system has to process preapproved payment. It is used from payment services which provide preapproved payments. This event will register a preapproved transaction in the payment service.

Parameters

context - The context of the content being passed to the plugin - this is the component name, the string "payments.docheckout" and the name of the payment service (e.g. com_virtualcurrency.payments.docheckout.paypal). Use this to check whether you are in the desired context for the plugin.

&item - A reference to the project object.

&params - A reference to an object that provides parameters of the component.

Return Value

Returns an associative array.

array(
"redirect_url" => "..." // A URL where the system should redirect the user when payment processing completes.
);
Used in files

components/com_virtualcurrency/controllers/payments.php

 

onPaymentsCapture

Description

This event is triggered when the administrator decides to process a preapproved transaction. This event should make a request to payment services to capture preapproved amount. It is invoked only from back-end by the administrator.

Parameters

context - The context of the content being passed to the plugin - this is the component name, the string "payments.capture" and the name of the payment service (e.g. com_virtualcurrency.payments.capture.paypal). Use this to check whether you are in the desired context for the plugin.

&item - A reference to the project object.

&params - A reference to an object that provides parameters of the component.

Return Value

Returns an associative array.

array(
"message" => "The transaction was...", // A message to the user
"type" => "message" // The type of the message - error or message.
);
Used in files

administrator/components/com_virtualcurrency/controllers/payments.php

 

onPaymentsVoid

Description

This event is triggered when the administrator decides to cancel a preapproved transaction. It is invoked only from back-end by the administrator.

Parameters

context - The context of the content being passed to the plugin - this is the component name, the string "payments.capture" and the name of the payment service (e.g. com_virtualcurrency.payments.capture.paypal). Use this to check whether you are in the desired context for the plugin.

&item - A reference to the project object.

&params - A reference to an object that provides parameters of the component.

Return Value

Returns an associative array.

array(
"message" => "The transaction was...", // A message to the user
"type" => "message" // The type of the message - error or message.
);
Used in files

administrator/components/com_virtualcurrency/controllers/payments.php

 

onPaymentsPreparePayment

Description

This event is invoked to provide additional data to a plug-in. That will be received by AJAX request and will be used from users to continue with their payment.

Parameters

context - The context of the content being passed to the plugin - this is the component name, the string "preparepayment" and the name of the payment service (e.g. com_virtualcurrency.preparepayment.mollieideal). Use this to check whether you are in the desired context for the plugin.

&params - A reference to an object that provides parameters of the component.

Return Value

Returns an associative array.

array(
"success" true, // TRUE or FALSE
"title" => "The data was...", // A message to the user
"data" => array(
"url" => "..." // A URL where the system should redirect the user when payment processing completes.
)
);
Used in files

components/com_virtualcurrency/controllers/payments.raw.php

 

How to debug the system and payment plug-ins?

If there is a problem with your system and you would like to find more information about the error, you have to debug your system. That will give you more information about the problem.

  1. Go to "System" -> "Global Configuration" -> "System" -> "Debug Settings".
  2. Set to "Yes" the option "Debug System".
  3. Now go to tab "Server" and set option "Error Reporting" to maximum.

Now, the system should display information about the error.

You can also check log files in folder "/logs" or the log file "error_log" in your main folder.

How to change PHP version on your hosting?

You will find a tool in your hosting control panel, that will give you an option to switch your PHP version to higher.

Here you are more information.

How to change PHP version on shared servers?

PHP version change

How to change your PHP version in CPanel?

How to edit views of the extension?

If you would like to add elements or to edit the HTML code of some pages, you have to override the component views. The system provides an easy way to do that. You have to make a copy of a view in your template folder and you have to edit it.
Here you are more information about how to do it.

How to customize styles for a component page and modules?

If you would like to write styles for some elements or modules to fine-tune the appearance of your site, you should use class suffix options.

You will find more information about that feature on the following pages.

How to override the styles of the component?

Virtual Currency includes CSS file with some styles. If you would like to edit these styles, you should override the file.

The file is "media/com_virtualcurency/css/frontend.style.css".

To override it, you have to make a new one in a folder "css/com_virtualcurency" in your template.

For example, you have to paste the file in that folder.

templates/my_template/css/com_virtualcurency/frontend.style.css

So, the system will load the new styles instead old ones.

The styles of the components are included in "components/com_virtualcurency/virtualcurency.php"

You will find more information about that Joomla! feature on the following pages.

How to include missed Twitter Bootstrap styles and components?

Some templates do not provide a full set of Twitter Bootstrap styles and JavaScript components. That makes your pages to look badly.

There are several solutions:

  • You can include missed styles and components in your template code manually.
  • You can find a template that provides many of the standard Bootstrap elements. If you would like, you can try the templates developed by YouJoomla.
  • You can hire a designer to fix your template or to do a template for your needs. You can do it on sites for freelancers like Freelancer.com.

How to disable strict errors?

If you get error message like this "Strict Standards: Declaration of ..... should be compatible with ...." you should change the error reporting option.

There are two solutions:

  • To change Joomla! option

Go to System -> Global Configuration -> Server (Tab). Select other option for "Error Reporting".

  • To change server options

Check this out - PHP 5 disable strict standards error

How to contribute code to the platform?

If you would like to contribute a code (fix an issue or add new feature), you should send pull request to the distribution of Virtual Currency.

  1. You should fork the repository and clone "develop" branch on your PC.
  2. Install distribution just like do with Joomla.
  3. Create a branch, write your code and send pull request to the branch "develop".

Here you are additional information about how to contribute and create pull request on GitHub.

 

Share this post

Submit to DeliciousSubmit to DiggSubmit to FacebookSubmit to Google PlusSubmit to StumbleuponSubmit to TechnoratiSubmit to TwitterSubmit to LinkedIn

Free Subscription

You can get the latest publication via RSS, Twitter or Facebook. And I can also deliver last news to you for free via Email:

RSS subscription Find us on Facebook Google+ page Follow me