PHP code example of cardgate / omnipay-cardgate

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

    

cardgate / omnipay-cardgate example snippets



	$gateway = Omnipay::create( 'Cardgate' );
	$gateway->initialize( 
		array(
				'siteId' => '<siteid>',
				'merchantId' => '<merchantid>',
				'apiKey' => '<apikey>',
				'notifyUrl' => '<notifyurl>',
				'returnUrl' => '<returnurl>',
				'cancelUrl' => '<cancelurl>',
				'testMode' => <bool:enabled>
		) );

	// Start the purchase
    
	$response = $gateway->purchase( 
 		array(
 				'paymentMethod' => '<paymentmethodid>',
 				'issuer' => <nummeric-issuerid>,
 				'description' => "Test description.",
 				'transactionReference' => 'TEST_TransactionReference_000123_mustBeUnique',
 				'amount' => '10.00',
 				'currency' => 'EUR',
 				'ipaddress' => '10.10.10.10'
 		) )->send();
    
    if ( $response->isSuccessful() ) {
        // payment was successful: update database
        print_r( $response );
    } elseif ( $response->isRedirect() ) {
        // redirect to offsite payment oGateway
        $response->redirect();
    } else {
        // payment failed: display message to customer
        echo $response->getMessage();
    }


$response = $oGateway->fetchIssuers()->send();
if($response->isSuccessful()){
    $oIssuers = $response->getIssuers();
}