Services Products Downloads About Us Contact
 
My Account
 
Services
Consulting
Business Solutions
Skills
Training
Support
 
Professional Products
molib™
the sandbox™
sswf™
odbcpp™
Trinity℠
Order Made!®
PHP eFax
PHP Pay Junction
Instant Cart™
DLF™
Documents & White Papers
 
Consumer Products
Turn Watcher™
Download Our Products
CafePress
Forums
 
About Us
History
News Room
Blogs
FAQ
Terms and Conditions
Your Privacy
 
Contact Us
Contact
Press Kit
Jobs
Service Request
 
 
 
Languages Available:  français   español 
 

PHP Pay Junction Documentation

1.0

Introduction

Welcome to the PHP version of the PayJunction documentation.

What is PHP Pay Junction? PayJunction (http://payjunction.com) is a company that let's you process credit cards (see http://www.m2osw.com/trinity).

This class lets you process credit cards:

  • by swiping them;
  • by incorporating this class in your e-Commerce website; or
  • by calling using a phone (cell phones or land lines).
This class specifically helps you with your e-Commerce solution. And we will help you with getting your own merchant account. You can register now.

The e-Commerce system uses a secure HTTPS API called Quick Link. It can be used in a totally automated way to process credit cards.

At Made to Order Software, we use PHP Pay Junction for our own e-Commerce systems: our corporate cart system and our Order Made! product.

To use the PHP Pay Junction class:

How do I get my own copy of this product?

This class is available for sale on our m2osw.com website. Go to http://www.m2osw.com/trinity and add it to your cart. Then simply checkout. After a few seconds, you will gain access to the download area and you will be able to download this library.

Requirements

The class requires the availability of HttpRequest.

If it is not already installed on your Ubuntu or Debian system use the following commands to retrieve and recompile a version on your system:

    sudo apt-get install php5-dev
    sudo pecl install pecl_http

For Fedora and other RPM based systems, use yum instead of apt-get. The pecl command is the same.

For a Microsoft Windows and Mac OS/X systems, you may need to get the source and recompile as required.

The HttpRequest documentation can be found on the PHP website: HttpRequest

Process a credit card

The following code shows how you create a PayJunction object, initializes it to send a valid transaction and finally PayJunction::process() the transaction.

The parameters are only examples. You will need to set the parameters to what you need for your cart. This is used to process a card payment.

    $payjunction = new PayJunction;
    // set parameters
    $payjunction->set_account_info("login", "password");
    $payjunction->set_customer_name("first", "last");
    $payjunction->set_customer_address("street", "city", "state", "zip", "country");
    $payjunction->set_invoice_id("invoice-id");
    $payjunction->set_transaction_info(PayJunction::AUTHORIZATION_CAPTURE,
        "grand total", "tax", "shipping", PayJunction::CENTS);
    $payjunction->set_card("card number", "expiration month", "expiration year", "CVV2", true);
    // if you can get the track, use set_track() instead of set_card()
    //$payjunction->set_track("card track");
    // ready to process the card
    $result = $payjunction->process();
    if($result)
    {
        ... // handle success
    }
    else
    {
        ... // handle failure
    }

See also:
PayJunction::set_account_info()

PayJunction::set_customer_name()

PayJunction::set_customer_address()

PayJunction::set_invoice_id()

PayJunction::set_transaction_info()

PayJunction::set_card()

PayJunction::set_track()

PayJunction::process()

Running test transactions

To test a transaction with the PayJunction's test account, use the following parameters:

    // The login and password to access the test account
    $payjunction->set_account_info('test', 'test');
    // The type of transaction and amount, add tax and shipping if you want
    // The amount must be between $2.00 and $4.00 to work
    $payjunction->set_transaction_info(PayJunction::AUTHORIZATION_CAPTURE, 2.00)
    // The card information, the number can be 4433221111223344 or 4444333322221111
    // and the expiration needs to be in the future
    $payjunction->set_card('4433221111223344', 12, 2011, '123', false);

Always test your code by first sending many test transactions. Remember that PayJunction detects when two very similar transactions are sent one after another and refuses the second one (similar means the same person, card, address, amount.) This is very practical to avoid double transactions when your users click on Reload when they should not do so.

Parsing the response

Whenever the request is sent to the PayJunction gate, it returns a response that defines whether the transaction succeeded or not. The response includes a code that defines the type of success or the type of error. To check the code, one can use the PayJunction::get_transaction_result() function. To only check whether the transaction was successful, use PayJunction::get_success() instead. If the transaction failed, then you can get the corresponding error message with PayJunction::get_error_message(). The PayJunction::get_transaction_variable() function is also available to check any one variable returned by the transaction such as PayJunction::RESULT_NOTES and PayJunction::RESULT_MERCHANT_NAME.

Note that the PayJunction::process() function returns true if the transaction succeeds and false otherwise. Thus you do not always need to call the PayJunction::get_success() function.

    // Assuming you just called $payjunction->process();
    if($payjunction->get_success())
    {
        // save the good news in your database
    }
    else
    {
        // get the error and display it
        echo "Error #",
            $payjunction->get_transaction_result(),
            ": ",
            $payjunction->get_error_message();
    }

See also:
PayJunction::get_success()

PayJunction::get_transaction_result()

PayJunction::get_error_message()

Error Handling

Most functions will throw a PayJunctionException when an error occurs.

Exceptions are generated in several cases as defined below:

  • When a function is called that cannot legally be called;
  • When a function is called with invalid parameter; and
  • If some required parameters were not yet defined.
To complete the setup of a PayJunction object, you have to call a limited set of functions. Calling functions from another group generates an exception. For instance, calling PayJunction::set_card(), prevents you from calling PayJunction::set_posture(). Both functions are define in different groups (see the PayJunction class definition for a list of the available groups.)

When you call the set_customer_address(), you must either define the complete address or only the zip code. When you define the street address and not the city name, then the function generates an exception.

Checking for the result of a transaction before calling PayJunction::process() may generate an exception. A new PayJunction object is automatically in an error state.

Though it should not be necessary since the exception should never occur when the PayJunction class is properly used, it is possible to catch the PayJunctionException in this way:

    try {
        ... // deal with the PayJunction object
    }
    catch(PayJunctionException e)
    {
        ... // handle exception
    }

Note that the HttpRequest also throws some exceptions. Please read the HttpRequest reference manual for more information.

HttpRequest

Copyright (c) 2008 Made to Order Software Corp.

All Rights Reserved.

This software and its associated documentation contains proprietary, confidential and trade secret information of Made to Order Software Corp. and except as provided by written agreement with Made to Order Software Corp.

a) no part may be disclosed, distributed, reproduced, transmitted, transcribed, stored in a retrieval system, adapted or translated in any form or by any means electronic, mechanical, magnetic, optical, chemical, manual or otherwise,

and

b) the recipient is not entitled to discover through reverse engineering or reverse compiling or other such techniques or processes the trade secrets contained therein or in the documentation.


Generated on Mon Mar 24 00:32:05 2008 for PHP Pay Junction by  doxygen 1.4.7

 

Links:
  PHP Pay Junction