PHP code example of phpieces / anz-egate

1. Go to this page and download the library: Download phpieces/anz-egate 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/ */

    

phpieces / anz-egate example snippets


use PHPieces\ANZGateway\ChargeRequest;
$fields = ChargeRequest::getFields();

use PHPieces\ANZGateway\models\Card;
$fields = Card::getFields();

use PHPieces\ANZGateway\enums\FormFields\CardFields;
use PHPieces\ANZGateway\Gateway;

$gateway = Gateway::create();
$gateway->setAccessCode('mycode');
$gateway->setMerchantID('myid');

$response = $gateway->purchase([
    // This field must be unique for every transaction attempt.
    'vpc_MerchTxnRef'              => 'mymerchid',
    // This field will show up on the merchant account and is the primary way to search for transactions.
    'vpc_OrderInfo'                => 'orderid',
    // cents AUD
    'vpc_Amount'                   => '100',
    // using the available enum values for the form fields
    CardFields::CARD_NUMBER        => $_POST[CardFields::CARD_NUMBER],
    //YYmm
    CardFields::CARD_EXPIRY_DATE   => $_POST[CardFields::CARD_EXPIRY_DATE],
    // code from back of card
    CardFields::CARD_SECURITY_CODE => $_POST[CardFields::CARD_SECURITY_CODE],
])->send();

if($response->isSuccess()) {
    //proceed...
} else {
    $error = $response->getMessage();
}

html
<? foreach($fields as $label => $name) :