PHP code example of vincsis / omnipay-ticketasa

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

    

vincsis / omnipay-ticketasa example snippets


{
  "TransactionType": 1,
  "Approved": true,  // must be true
  "AuthorizationCode": "123456", // Authorization number from bank
  "TransactionIdentifier": "3dbff695-d7e0-4e90-8187-1e93cf13bb40", // Order Number
  "TotalAmount": 1,  //Mount
  "CurrencyCode": "320", 
  "RRN": "227603509881",
  "CardBrand": "Visa",
  "IsoResponseCode": "00", 
  "ResponseMessage": "Transaction is approved", // Message Approvement.
  "OrderIdentifier": "TICKET-ASA-3dbff695-d7e0-4e90-8187-1e93cf13bb40" // Order Identifier PREFIX +  Order Number
}

{
    "AuthorizationCode": "123456",
    "CurrencyCode": "320",
    "IsoResponseCode": "00", // successfull is 00
    "OrderSummary": {
        "CaptureCount": 1,
        "CreditCount": 0,
        "CurrencyCode": "320",
        "LastCaptureDateTime": "2022-10-31T21:38:49.663",
        "OrderIdentifier": "TICKET-ASA-4e895e54-3f5a-428c-ac30-1c0e7bd8ab86",
        "OriginalTrxnDateTime": "2022-10-31T21:38:49.663",
        "OriginalTrxnIdentifier": "4e895e54-3f5a-428c-ac30-1c0e7bd8ab86",
        "SettledAmount": 1.00,
        "TotalCaptureAmount": 1.00,
        "TotalCreditAmount": 0.00
    },
    "OtherAmount": 0.00,
    "TaxAmount": 0.00,
    "TipAmount": 0.00,
    "TotalAmount": 1.00,
    "TransactionDateTime": "2022-10-31T21:38:20.193",
    "TransactionIdentifier": "4e895e54-3f5a-428c-ac30-1c0e7bd8ab86",
    "TransactionType": 2
}

{
    "OriginalTrxnIdentifier": "a",
    "TransactionType": 5,
    "Approved": false,
    "TransactionIdentifier": "27909349-a43f-411a-9cc1-1ec6e3ab4d89",
    "TotalAmount": 1.00,
    "CurrencyCode": "220",
    "RRN": "230714276757",
    "IsoResponseCode": "96",
    "ResponseMessage": "System error",
    "ExternalIdentifier": "-81aa-42c1-960e-6b535c5f4ae3",
    "Errors": [
        {
            "Code": "451",
            "Message": "General processor error"
        }
    ]
}
 php

use Omnipay\Omnipay;
try {
    $gateway = Omnipay::create('Ticketasa');
    $gateway
        ->setTestMode(true)  // false to use productions links  , true to use test links 
        ->setPWTId('xxxxxxxx') 
        ->setPWTPwd('xxxxxxxx')
        // **Required and must be https://
        ->setNotifyUrl('https://localhost/webhook.php')
        // **Required and must be https://    
        ->setReturnUrl('https://localhost/webhook.php')        
        ->setDiscount(false);
        

    $cardData = [
         'firstName' => 'Gabriel', //optional 
         'LastName' => 'Arzu', // optional
    ];

    $transactionData = [
        'card' => $cardData,
        'amount' => '1.00',   // Mandatory
        'TransactionId' => '2100001',  // mandatory, must be unique in each transaction
    ];

    $response = $gateway->purchase($transactionData)->send();

    if($response->isSuccessful())
         $response->getHostedPageURL();  // return the link with encrypted params 

         $response->redirectToHostedPage(); //Redirect automatically to payment form 

} catch (Exception $e){
    $e->getMessage();
}