Hey! Keep up to date with the project through its beta and public launch by following @getsparks.

 
1
0
0
1,997 Installs

Basic Information: realex-payments

Spark to use the Realex Payments RealAuth service

Contributor : seandowney
Email : Log in to view
Author Website :
Spark Website : https://bitbucket.org/seandowney/realex_payments
Repository Type : hg
Number of Installs : 1,997

Get the Latest

How-To

Realex Payments Spark

Realex Payments is an online payments provider which provides a solution which does not require the merchant to have their own secure server. The Realex Payments Spark provides an easy to use library to get up an running with Realex very quickly.

Note: Realex Payments is fully PCI compliant to the highest level of PCI, allowing redirect integration which significantly reduces the merchants PCI compliance requirements. Remote integration merchants will need to be fully compliant with PCI.

Core Features

  • Provides the RealAuth solution from Realex Payments
  • Returns the form to connect to Realex
  • Provides the Payment Response end point which Realex calls after a payment has been processed
  • Provides basic success and failure views which are returned to Realex to display on the Payment page

Setup Your Config Preferences

In sparks/realex-payments/config/realex_payments.php you will find the preferences for connecting to your Realex account. The config file is well commented.

Setup Your Languages

In sparks/realex-payments/language/english/realex_payments.php you will find the English language messages used in the form and response view files.

Basic Usage From Your Controller

function __construct(){
    parent::__construct();
    // load the Realex Payments spark
    $this->load->spark( 'realex-payments/[version #]');
}

function index(){
    // setup the details of the form
    $this->realex_payments->set_field('form_name', 'realex_form')
                            ->set_field('form_id', 'realex_id')
                            ->set_field('currency', 'EUR')
                            ->set_button_delimiters('<div>', '</div>');
    // set specific order details
    $this->realex_payments->set_field('customer_num', 'cust123')
                            ->set_field('product_id', 'PRO-1234')
                            ->set_field('comment1', 'This is a comment about the order')
                            ->set_field('comment2', 'This is another comment');
    // display the form - passing in the order_id and amount
    echo $this->realex_payments->return_form('ORD-1231', '1200');
}

function payment_response()
{
    // get the Post details and return in a usable format
    $response_array = $this->realex_payments->return_response_status();

    // Check if the payment was successful
    if( !empty($response_array['success']) ) {
        // perform any database updates
        // display the success view
        $this->load->view('success', $response_array);
    }
    else {

        switch ($response_array['error'])
        {
            case 'PAYMENT_FAILURE':
                $response_array['failure_message'] = $this->_payment_failure($response_array);
                break;
            case 'HASH_MISMATCH':
                $response_array['failure_message'] = $this->CI->lang->line( 'realex_payments_response_hash_mismatch' );
                break;

            default:
                $response_array['failure_message'] = $this->CI->lang->line( 'realex_payments_response_no_data' );
                break;
        }

        // perform any database updates

        // display the failure view
        $this->load->view('failure', $response_array);
    }
}

function _payment_failure($response_array)
{
    $failure_message = '';
    switch ($response_array->cause)
    {
        case 'DECLINED':
            $failure_message = $this->CI->lang->line( 'realex_response_declined' );
            break;
        case 'LOST_STOLEN':
            $failure_message = $this->CI->lang->line( 'realex_response_lost_stolen' );
            break;
        case 'BANK_ERROR':
            $failure_message = $this->CI->lang->line( 'realex_response_bank_error' );
            break;
        case 'PAYMENT_SYSTEM_ERROR':
            $failure_message = $this->CI->lang->line( 'realex_response_payment_system_error' );
            break;

        default:
            $failure_message =  $this->CI->lang->line( 'realex_response_other_error' );
            break;
    }

    return $failure_message;
}

Overriding the Realex Payments Views

You can edit the success and failure view files. It is advisable that all returned data is Not displayed to the user.

Older Versions

Comments

blog comments powered by Disqus