Made to Order Software Corporation Logo

mo_payjunction.module File Reference

mo_payjunction.module File Reference

Use PayJunction to collect payment and process orders. More...

Enumerations

enum  MO_PAYJUNCTION_VERSION
 Define the version of the MO PayJunction module. More...

Functions

 mo_payjunction_perm ()
 Implementation of hook_perm()

 mo_payjunction_help ($section)
 The help pages for the MO PayJunction module.

 mo_payjunction_form_alter (&$form, &$form_state, $form_id)
 Implementation of hook_form_alter()

 mo_payjunction_payment_gateway ()
 Implementation of hook_payment_gateway()

 _mo_payjunction_settings_form ()
 Callback function used by Ubertcard to get the MO PayJunction settings.

 mo_payjunction_validate ($form, &$form_state)
 Validate the password.

 mo_payjunction_recurring_info ()
 Implementation of hook_recurring_info().

 mo_payjunction_recurring_fee_process ($order, $fee, $op)
 Implementation of the processing function for the recurring fee.

 mo_payjunction_recurring_fee_renew ($order, $fee, $op)
 Implementation of the processing of a recurring fee.

 _mo_payjunction_charge ($order_id, $amount, $data)
 Charge the customer credit card.

 _mo_payjunction_charge_order ($order, $amount, $data)
 Charge the customer credit card.


Detailed Description

Implementation of the functions used to handle the MO PayJunction module.

Copyright (c) 2009-2011 Made to Order Software Corp.

http://www.m2osw.com/mo_payjunction contact@m2osw.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


Enumeration Type Documentation

This variable defines the version of the MO PayJunction module. This will always be the same as the version defined in Drupal (throught the .info file.)


Function Documentation

_mo_payjunction_charge ( order_id,
amount,
data 
)

This function is called at the time the user clicks on Process (or whatever button used to process the order.)

The $amount parameter is the total amount of the invoice. The order identifier is used to read the corresponding order and fill in the data for PayJunction.

This function does not manage recurring charges. Since PayJunction generates a unique identifier for each charge processed and that identifier can be reused later to charge the same card, we don't actually have to do anything more.

Note:
In the $data array we expect 'txn_type' to be set to the current type of transaction to perform. We only support "Authorization" and "Authorization and Capture".
Parameters:
[in]$order_idThe identifier of the order being processed
[in]$amountThe amount being charged
[in]$dataSome additional data defined by the Credit Card system
Returns:
An array with the results (success/failure, messages, etc.)

References _mo_payjunction_charge_order().

_mo_payjunction_charge_order ( order,
amount,
data 
)

This is a sub-function of _mo_payjunction_charge() that accepts an order object instead of the order identifier. This is useful to avoid loading the order again and called whenever a recurring fee is charged to a customer.

Note:
In the $data array we expect 'txn_type' to be set to the current type of transaction to perform. We only support "Authorization" and "Authorization and capture".
In the $data array we expect the 'pj_transaction_id' for recurring payments. Do not set this entry for non-recurring payments.
Parameters:
[in]$orderAn order object to process
[in]$amountThe amount being charged
[in]$dataSome additional data defined by the Credit Card system
Returns:
An array with the results (success/failure, messages, etc.)

Referenced by _mo_payjunction_charge(), and mo_payjunction_recurring_fee_renew().

The Ubercart module uses this function to request a form of settings for the MO PayJunction module.

This includes the username, the password, and a flag to know whether the module is used in test mode or not. When not in test mode, a valid login and password are required.

Returns:
The PayJunction form.
mo_payjunction_form_alter ( &$  form,
&$  form_state,
form_id 
)

This function is an implementation of the hook_form_alter().

It is used to:

  • Edit the description of the currency code to inform the user that only USD is supported by PayJunction.
  • Edit the gateway settings form and add a validation function.
Parameters:
[in,out]$formThe form to edit
[in,out]$form_stateThe current state of the form
[in]$form_idThe unique identifier of the form.
mo_payjunction_help ( section)

Display some help whenever the user goes to the Drupal help section of the website.

Parameters:
[in]$sectionThe section of help the user is interested in
Returns:
The help strings.

This function returns one or more gateway supported by this module.

At this time, the MO PayJunction module returns one gateway.

Returns:
The MO PayJunction gateway.

This function returns a list of permissions supported by the MO PayJunction module.

At this time the module supports 'allow PayJunction test charge' to let only a few users use the test mode of the module. This works by assigning a specific role to the few users who will be able to use the test mode of the module. (i.e. Anonymous users should never be allowed to run a test charge.) When in test mode, any user not in that group will get an error message if they try to order using PayJunction (and their information will NOT be sent to PayJunction.)

Note:
The administrator (user #1) is always allowed to use the module in test mode.
Returns:
The array of supported permissions
mo_payjunction_recurring_fee_process ( order,
fee,
op 
)

This function is called by the uc_recurring module whenever a product order has a recurring fee. It is expected to setup the recurring fee with the processor. For PayJunction we already have the Transaction ID saved in our database so we ignore this call and simply return TRUE.

Parameters:
[in]$orderThe order being processed
[in]$feeThe fee definition (fee handler object) including the amount to charge
[in]$opThe operation (i.e. 'process callback')
Returns:
TRUE
mo_payjunction_recurring_fee_renew ( order,
fee,
op 
)

This function is called by the uc_recurring module whenever a product order has a recurring fee that needs to be processed. The function uses the transaction identifier to process the fee and return TRUE unless the processing fails.

The transaction identifier is taken from the order that was successfully processed.

Note that the $order parameter is a copy of the original order and not the main order.

Parameters:
[in]$orderThe new order being processed
[in]$feeThe fee definition (fee handler object) including the amount to charge
[in]$opThe operation (i.e. 'renew callback')
Returns:
TRUE on success, FALSE otherwise

References _mo_payjunction_charge_order().

This function is called by the uc_recurring module to gather all the different modules that support recurring fees.

The MO PayJunction supports recurring fees using the transaction identifier generated by the very first charge.

Note that you cannot charge a credit card twice in a row. This means you cannot setup a recurring fee to be processed immediately after the main charge on a credit card. For that to happen, you need to increase the cost of your product or service inclusive of the first recurring fee. Another solution, is to charge the recurring fee within 1 or 2 days...

Returns:
A recurring info array with the MO PayJunction handler.
mo_payjunction_validate ( form,
&$  form_state 
)

This function validates the password, which simply means that it copies the existing password in the password field of the form if the field is empty. This means we won't lose the password if left unchanged.

Parameters:
[in]$formThe form being validated, i.e. the PayJunction settings
[in,out]$form_stateThe form state being validated
Documentation generated by Doxygen on Fri Aug 9 2013 16:19:17