PHP Classes

PHP Authorize.net SIM: Generate payment forms for Authorize.net SIM API

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 147 All time: 9,125 This week: 41Up
Version License PHP version Categories
authorize-net-sim 1.0.0GNU General Publi...5HTML, PHP 5, E-Commerce
Description 

Author

This class can generate payment forms for Authorize.net SIM API.

It extends the base Authorize.net SDK SIM form class to customize the payment form details like the presentation details, text labels, return or cancel URLs, etc..

The class can generate HTML for a form with a button for the user to proceed to the payment page.

Picture of Samuel Adeshina
  Performance   Level  
Innovation award
Innovation award
Nominee: 7x

Winner: 1x

 

Recommendations

Authorize.net complete class for SIM method
Authorize.net class for SIM API

Example

<?php
   
/* IMPORTANT POINT: Make Sure You set your api login id and transaction key
        values in the auth.ini file if you are using this package in a production environment.
        But you can work with the ones that came with this package if you just want to test it
    */

    //require the AuthorizePayment.class.php file
   
require_once("AuthorizePayment.class.php");

   
/*
        We need to instantiate the AuthorizePayment_Form class
        contained in the file we included above.

        The constructor accepts one parameter which must be an array.

        This parameter must contain key index of: CUSTOMERID, AMOUNT, METHOD, URL, TEXT.

        * The CUSTOMERID index should be the actual id of the customer and this id will appear on the generated form
        * THE AMOUNT index should be the total recurring amount the transaction worths
        * The METHOD index should be the http method for submitting the form data to the receipt page, it could be
            one of LINK, GET, POST
        * The URL should be the actual url of the receipt page
        * The TEXT should be the text that'ld be displayed on the receipt page link

        for example, a parameter for the constructor method would be

        $parameter = array(
                            "CUSTOMERID"=>"1009",
                             "AMOUNT"=>"43.00",
                             "METHOD"=>"POST",
                             "URL"=>"www.mydomain.com.ng",
                             "TEXT"=>"Click Here To Go Back To Our HomePage"
                         );
       
        Consult the documentation accompanying this package for more info
    */

    //Class Instantiation
   
$parameter = array(
                       
"CUSTOMERID"=>"1009",
                        
"AMOUNT"=>"19800",
                        
"METHOD"=>"POST",
                        
"URL"=>"www.mydomain.com.ng",
                        
"TEXT"=>"Click Here To Go Back To Our HomePage"
                    
);
   
$authorizepaymentInstance = new AuthorizePayment_Form($parameter);

   
/*
        The generated page can be customized by supplying an approprate value to one of the
        following
            HEADER, FOOTER, LINKCOLOR, BACKGROUNDCOLOR, TEXTCOLOR, LOGO, BACKGROUNDIMAGE
            CANCELURL, CANCELURLTEXT, CUSTOMCSS, DESCRIPTION, SUBMITTEXT indexes of an array

        for instance to set the backgroundcolor to blue, the following would be passed
        as parameter to the customizeForm() method:
        $array = array("BACKGROUNDCOLOR"=>"#00f");


        consult the documentation for more information
    */

    //Below is an example initialization of the customizeForm() method
   
$customParams = array(
               
"HEADER"=>"PLEASE FILL IN THIS FORM TO PAY FOR THE BEST ITEM MONEY CAN BUY!",
               
"FOOTER"=>"Please Note That Your Credit Card Details Are Safe",
               
"BACKGROUNDCOLOR"=>"#87CEFA",
               
"LINKCOLOR"=>"#f00",
               
"TEXTCOLOR"=>"#000",
               
"LOGO"=>"https://sp.yimg.com/ib/th?id=JN.VacOaoed%2b6TU2B3wRrmgCQ&pid=15.1&P=0",
               
"CANCELURL"=>"http://www.mydomain.com",
               
"CANCELURLTEXT"=>"Cancel, I don't have my card details yet",
               
"DESCRIPTION"=>"Arduino Kit for PHP Programmers ;)",
               
"SUBMITTEXT"=>"Click Here To Enter Your Payment Details"
       
);
   
$authorizepaymentInstance->customizeForm($customParams);

   
/*
        You may want to change the labels of a particular field on the generated form,
        the renameFormFields() method helps you do this by supplying an array with the
        field to change and the new value as parameters.

        The following are the default names for the field labels:
        RECURRINGBILLING, CURRENCYCODE, INVOICENUMBER, DESCRIPTION, FIRSTNAME, LASTNAME,
        COMPANY, ADDRESS, CITY, STATE, ZIP, COUNTRY, PHONE, FAX, EMAIL, CUSTOMERID,
        SHIPTOFIRSTNAME, SHIPTOLASTNAME, SHIPTOCOUNTRY, SHIPTOADDRESS, SHIPTOCITY,
        SHIPTOSTATE, SHIPTOZIP, TAX, FREIGHT, DUTY, TAXEXEMPT, PURCHASENUMBER
    */

    //The Example below demonstrates how to rename a label

   
$renameParams = array("DESCRIPTION"=>"WHAT IS THIS?", "FIRSTNAME"=>"Enter Your FirstName", "PHONE"=>"Mobile Number");
   
$authorizepaymentInstance->renameFormFields($renameParams);


   
/*
        The next thing is display a button that takes the user to the form.
        This can be done by instantiating the completeTransaction() method.

        It accepts no parameter
    */

   
$authorizepaymentInstance->completeTransaction();


   
/*
        ..... And thats all. The user is redirected to the authorize.net website where he/she
        can complete the form to make payments. After that, the user is redirected back to the
        URL you supplied in the constructor parameter.


        You should go through the readme file accompanying this package, if you need a quick
        explanation about a method or the class as a whole Or you can ask for more help
        on this class' message forum on the PHPClasses site.
    */


?>


Details

|************************************************************************************************| |* CLASS NAME : PHP SECURE PAYMENT GATEWAY *| |* DEVELOPER : Samuel Adeshina <samueladeshina73@gmail.com> *| |* LICENSE : GPL(Generic Public License) *| |* DATE : 23 June 2015 *| |* DESCRIPTION : This class uses the Authorize.Net SIM API to provide *| |* a secure payment platform on any website. It provides methods *| |* for customizing the payment page to suite the merchant's website *| |* in terms of color and layout. *| |* It also provides methods for changing form labels, this would make *| |* it easy to translate the payment form into different languages *| |* depending on the customers locale. *| ************************************************************************************************ CLASS OBJECTIVE: Provide A PHP Interface / Object Oriented Implementation For The Authorize.Net SIM API CLASS ATTRIBUTES: private $login; The API_LOGIN_ID, set this value in the auth.ini file, if you want to use it in a production environment private $key; The TRANSACTION_KEY, also set this value in the auth.ini file private $amount; Total recurring cost of the transaction to be made private $sequence; A uniquely generated value, required for figerprint hash generation private $timestamp; private $fingerprint; A Uniquely generated Hashed value as certificate private $customerid; Customer's ID private $receiptlinkmethod; Method for receipt generation (GET, LINK or POST) private $receiptlinktext; Text to show on receipt generation link button or anchor private $receiptlinkurl; URL of the page containing the generated receipt CLASS METHODS: __Construct(): Method responsible for the instantiation of the class, it accepts an array parameter _initializeGateway(): Accepts 5 parameters and is private method, the user need not worry about this method __keyExists(): checks if a key exists in an array, returns a boolean value and is a private method customizeForm(): for changing the look and feel of the generated form. Accepts a single parameter which must be an array renameFormFields(): for changing the label texts on the generated form. It accepts an array which contains the field label to change and the value to change to. ALL OTHER METHODS BELOW EXCEPT THE COMPLETE TRANSACTION METHOD, GENERATES AN HTML FORM WHICH IS NEEDED TO PROCESS PAYMENT ON THE AUTHORIZE.NET PLATFORM. THEY ARE ALL PRIVATE METHODS _initGateway(); _postData(); _merchantCustomizationInterface(); _merchantCustomizationDisplay(); completeTransaction(): This method, completeTransaction(), displays and hidden form and a button which takes the user to the payment page ***ADDITIONAL INFORMATION: You should register on the Authorize.Net website if you want to use this class in a production environment in order to get your developer API_LOGIN_ID and your TRANSACTION_KEY. Once you get them, edit the auth.ini file and insert them into the right field. HAVE FUN WHILE CODING, DON'T FORGET TO RATE THIS PACKAGE ON THE PHPCLASSES SITE AND YOU CAN ALWAYS FIND ME ON ONE OF THE ADDRESSES BELOW IF YOU HAVE A QUESTION OR YOU JUST WANT TO TALK ABOUT ENNGINEERING SOFTWARES! facebook => email => samueladeshina73@gmail.com twitter => whatsapp => +23408139344522

  Files folder image Files (422)  
File Role Description
Files folder imagesdk (9 files, 4 directories)
Accessible without login Plain text file auth.ini Data First Commit
Plain text file AuthorizePayment.class.php Class First Commit
Accessible without login Plain text file AuthorizeTest.php Example First Commit
Accessible without login Plain text file composer.json Data First Commit
Accessible without login Plain text file LICENSE Lic. First Commit
Accessible without login Plain text file readme.txt Doc. First Commit

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:147
This week:0
All time:9,125
This week:41Up