PHP code example of ignited / omnipay-zippay

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

    

ignited / omnipay-zippay example snippets


$omniZip = Omnipay::create('ZipPay_Rest');
$omniZip->setApiKey($zipApiKey);
$authTx = $omniZip->authorize([
  'reference'=> $ref,
  'amount' => 10.00,
  'currency' => 'AUD',
  'returnUrl' => 'https://mysite.com/zip/return',
  'card' => $this->OmniPayCardFactory(), //Customers Details, no credit card number
  'items' => $this->zipItemList(), // Array of items implementing Omnipay\ZipPay\ItemInterface   
]);
$result = $authTx->send();
if($response->isRedirect()) { // Authorize worked
  $resData = $result->getData();
  $this->saveAuthorizeId($resData['id']);
  $response->redirect(); //Sends customer off to ZipPay to complete signup
}

if (!isset($_REQUEST['result']) || $_REQUEST['result'] !== 'approved') 
  throw new \RuntimeError('Problem with your authorization');
$omniZip = Omnipay::create('ZipPay_Rest');
$omniZip->setApiKey($zipApiKey);
$compTx = $omniZip->completeAuthorize([
  'authorityType' => 'checkout_id',
  'authorityValue' => $this->getAuthorizeId(),
  'amount' => 10.00,
  'currency' => 'AUD',
  'captureFunds' => true;
]);
$result = $compTx->send();
if($result->isSuccessful())
  $this->paid();
else
  $this->paymentFailed();