PHP code example of hps / heartland-php

1. Go to this page and download the library: Download hps/heartland-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

hps / heartland-php example snippets




 $response = $chargeSvc->charge(17.01, "usd", TestCreditCard::validVisaCreditCard(), TestCardHolder::certCardHolderShortZip());
 

 $response = $this->service
                  ->charge()
                  ->withAmount(17.01)
                  ->withCurrency("usd")
                  ->withCard(TestCreditCard::validVisaCreditCard())
                  ->withCardHolder(TestCardHolder::certCardHolderShortZip())
                  ->execute();

     try
            {
                 $response = $this->service
                                  ->charge()
                                  ->withAmount(5)
                                  ->execute();
            }
            catch (HpsInvalidRequestException $e)
            {
                // handle errors for invalid arguments such as a charge amount less than zero dollars
            }
            catch (HpsAuthenticationException $e)
            {
                // handle errors related to your HpsServiceConfig (username, pw, api keys etc.)
            }
            catch (HpsCreditException $e)
            {
                // handle card-related exceptions: card declined, processing error, etc                 
            }
json
{
    "ps/heartland-php": "*"
    }
}

$ git clone https://github.com/SecureSubmit/heartland-php.git
$ cd heartland-php
$ composer install
$ php vendor/bin/phpunit -c tests/phpunit.xml