PHP code example of schoolaid / powertranz

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

    

schoolaid / powertranz example snippets


use SchoolAid\Powertranz\Actions\Alive;

$response = Alive::getInstance()->submit()

use SchoolAid\Powertranz\Requests\PowertranzBody;
use SchoolAid\Powertranz\Actions\Capture;

$body = PowertranzBody::capturePowertranzBody($transactionIdentifier, $amount, $externalIdentifier)
$response = Capture::getInstance()->setBody($body)->submit()

use SchoolAid\Powertranz\Requests\PowertranzBody;
use SchoolAid\Powertranz\Actions\Refund;

$body = PowertranzBody::refundPowertranzBody($transactionIdentifier, $amount, $externalIdentifier)
$response = Refund::getInstance()->setBody($body)->submit()

use SchoolAid\Powertranz\Requests\PowertranzBody;
use SchoolAid\Powertranz\Actions\Revert;

$body = PowertranzBody::voidPowertranzBody($transactionIdentifier, $cardId)
$response = Revert::getInstance()->setBody($body)->submit()

use SchoolAid\Powertranz\Requests\PowertranzBody;
use SchoolAid\Powertranz\Actions\Sale;

$body = PowertranzBody::powertranzBody(
    $transactionId,
    $orderId,
    $cardPan,
    $cardCvv, //yyMM format
    $cardExpiration,
    $cardName,
    $billingAddress
)
$response = Sale::getInstance()->setBody($body)->submit()

use SchoolAid\Powertranz\Requests\PowertranzBody;
use SchoolAid\Powertranz\Actions\SPIAuth;

$body = PowertranzBody::powertranzBody(
    $transactionId,
    $orderId,
    $cardPan,
    $cardCvv, //yyMM format
    $cardExpiration,
    $cardName,
    $billingAddress
)
$response = SPIAuth::getInstance()->setBody($body)->submit()

use SchoolAid\Powertranz\Requests\PowertranzBody;
use SchoolAid\Powertranz\Actions\SPIPayment;

$spiToken = '...';
$response = SPIPayment::getInstance()->setToken($token)->submit()

use SchoolAid\Powertranz\Requests\PowertranzBody;
use SchoolAid\Powertranz\Actions\SPISale;

$body = PowertranzBody::powertranzBody(
    $transactionId,
    $orderId,
    $cardPan,
    $cardCvv, //yyMM format
    $cardExpiration,
    $cardName,
    $billingAddress
)
$response = SPISale::getInstance()->setBody($body)->submit()

use Schoolaid\Powertranz\Entities\PowertranzCreditCard;
use SchoolAid\Powertranz\Requests\PowertranzBody;

$cc = new PowertranzCreditCard($id, $pan, $cvv, $expDate, $name, ?$billingAddress)

$body = PowertranzBody::fromCreditCard($cc);
$voidBody = PowertranzBody::fromCreditCard($cc, $transactionId, true);