jonathanmontes/omnipay-first-atlantic-commerce

omnipay-first-atlantic-commerce

v1.0.2 2021-03-10 16:54 UTC

This package is not auto-updated.

Last update: 2024-04-20 19:00:43 UTC


README

First Atlantic Commerce driver for the Omnipay PHP payment processing library

Latest Version on Packagist GitHub Tests Action Status Total Downloads

Omnipay is a framework agnostic, multi-gateway payment processing library for PHP. This package implements First Atlantic Commerce support for Omnipay.

Support us

Installation

You can install the package via composer:

For PHP 8.0+

composer require shamarkellman/omnipay-first-atlantic-commerce "^2.0.0"

For PHP 7.4

composer require shamarkellman/omnipay-first-atlantic-commerce "^1.0.0"

Usage

Authorize Request

$gateway = Omnipay::create('FirstAtlanticCommerce');
$gateway->setMerchantId('123456789');
$gateway->setMerchantPassword('abc123');
$gateway->setAcquirerId(12345);

$cardData = [
    'number' => '4242424242424242',
    'expiryMonth' => '6',
    'expiryYear' => '2016',
    'cvv' => '123'
];

$response = $gateway->authorize([
    'createCard' => true, //optional - Will return tokenized card if included
    'amount' => '10.00',
    'currency' => 'USD',
    'transactionId' => '1234',
    'card' => $cardData,
    'testMode' => true //use for calls to FAC sandbox
])->send();

if ( $response->isSuccessful() ) {
    print_r($response);
}
else {
    echo $response->getMessage();
}

Single Pass Purchase Request

$gateway = Omnipay::create('FirstAtlanticCommerce');
$gateway->setMerchantId('123456789');
$gateway->setMerchantPassword('abc123');
$gateway->setAcquirerId(12345);

$cardData = [
    'number' => '4242424242424242',
    'expiryMonth' => '6',
    'expiryYear' => '2016',
    'cvv' => '123'
];

$response = $gateway->purchase([
    'createCard' => true, //optional - Will return tokenized card if included
    'amount' => '10.00',
    'currency' => 'USD',
    'transactionId' => '1234',
    'card' => $cardData,
    'testMode' => true //use for calls to FAC sandbox
])->send();

if ( $response->isSuccessful() ) {
    print_r($response);
}
else {
    echo $response->getMessage();
}

Capture Previous Transaction

$gateway = Omnipay::create('FirstAtlanticCommerce');
$gateway->setMerchantId('123456789');
$gateway->setMerchantPassword('abc123');
$gateway->setAcquirerId(12345);

$response = $this->gateway->capture([
    'amount' => '10.00',
    'currency' => 'USD',
    'transactionId' => '1234',
])->send();

if ( $response->isSuccessful() ) {
    $response->getCode();
    $response->getResponseCode();
    $response->getMessage();
    $response->getOriginalResponseCode();
}
else {
    echo $response->getMessage();
}

Hosted Page Request

$gateway = Omnipay::create('FirstAtlanticCommerce');
$gateway->setMerchantId('123456789');
$gateway->setMerchantPassword('abc123');
$gateway->setAcquirerId(12345);

$response = $this->gateway->hostedPage([
    'amount' => '10.00',
    'currency' => 'USD',
    'transactionId' => '1234',
    'transactionCode' => TransactionCode::SINGLE_PASS + TransactionCode::REQUEST_TOKEN, //Use values based on requirements 
    'cardHolderResponseURL' => 'https://merchant/response/page.php',
    'pageSet' => 'pageSetFromPanel',
    'pageName' => 'pageNameFromPanel',
])->send();

if ( $response->isSuccessful() ) {
    $response->getRedirectUrl();
    $response->getToken(); //the single use token to build hosted page URL. See doc
}
else {
    echo $response->getCode();
    echo $response->getMessage();
}

Hosted Page Result Request

This returns the payment data for the hosted payment

$gateway = Omnipay::create('FirstAtlanticCommerce');
$gateway->setMerchantId('123456789');
$gateway->setMerchantPassword('abc123');
$gateway->setAcquirerId(12345);

$response = $this->gateway->hostedPageResult([
    'token' => '_JBfLQJNiEmFBtnF3AfoeQ2', //token is provided returned in callback after completes hosted page
]);

if ( $response->isSuccessful() ) {
    echo $response->getResponseCode();
    echo $response->getMessage();
    echo $response->getTransactionId();
    echo $response->getCardReference(); //if tokenization was requested
}
else {
    echo $response->getCode();
    echo $response->getMessage();
}

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.