Made to Order Software Corporation Logo

PHP Pay Junction: Main Page



How do I get my own copy of this product?
Process a credit card
Running test transactions
Parsing the response
Error Handling
Copyright (c) 2008-2010 Made to Order Software Corp.


Welcome to the PHP version of the PayJunction documentation.

What is PHP Pay Junction? PayJunction (PHP Pay Junction) is a company that let's you process credit cards (see the Trinity System).

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 website. Go to 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.

If you don't yet have a Pay Junction account, we can set one up for you. Go to and for more information about the Trinity software, go to

Owners of a Pay Junction account can process credit cards at their business place, on the Internet, and by phone.


The library requires PHP 5.

The class requires the availability of curl. Since you must have PHP 5.0+, there is no reason for you not to have curl unless it was not compiled in your version of PHP. You are responsible for recompiling your server when necessary.

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");
        "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();
        ... // handle success
        ... // handle failure

See also:








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();
        // save the good news in your database
        // get the error and display it
        echo "Error #",
            ": ",

See also:



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

Copyright (c) 2008-2010 Made to Order Software Corp.

Complete License

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,


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.

Documentation generated by Doxygen on Wed Aug 4 23:50:07 2010