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:
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:
If you don't yet have a Pay Junction account, we can set one up for you. Go to http://www.m2osw.com/trinity_register and for more information about the Trinity software, go to http://www.m2osw.com/trinity
Owners of a Pay Junction account can process credit cards at their business place, on the Internet, and by phone.
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.
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 }
PayJunction::set_customer_name()
PayJunction::set_customer_address()
// 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.
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(); }
Exceptions are generated in several cases as defined below:
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 }
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.