loganhenson/firstdata

FirstData API Wrapper

v2.0.0 2015-05-06 13:06 UTC

This package is auto-updated.

Last update: 2024-11-17 05:57:09 UTC


README

Build Status

Code Climate

First Data API v14

Install

composer require loganhenson/firstdata

Info/API

Transaction API Reference

Search API Reference

Transaction List

Demo Transaction List

Requires .env file (see .env.example)

Purchase

<?php

$Transaction = new Transaction(getenv('fd_gateway_id'), getenv('fd_gateway_password'), getenv('fd_key_id'), getenv('fd_key'));
try{
	$response = $Transaction->Purchase('Mastercard', 'Logan Henson', 5500000000000004, 1216, 123, 120);
}catch(FirstDataException $e){
	echo $e->getMessage();
}

Pre Authenticate

<?php

$Transaction = new Transaction(getenv('fd_gateway_id'), getenv('fd_gateway_password'), getenv('fd_key_id'), getenv('fd_key'));
try{
	$response = $Transaction->PreAuth('Mastercard', 'Logan Henson', 5500000000000004, 123, 1216);
	// store the $response['transarmor_token']
}catch(FirstDataException $e){
	echo $e->getMessage();
}

Late Purchase (requires transarmor_token from pre authentication)

<?php

// get the transarmor_token from data storage

$Transaction = new Transaction(getenv('fd_gateway_id'), getenv('fd_gateway_password'), getenv('fd_key_id'), getenv('fd_key'));
try{
	$latePurchaseResponse = $Transaction->LatePurchase('Mastercard', 'Logan Henson', $response['transarmor_token'], 1216, 123, 120);
}catch(FirstDataException $e){
	echo $e->getMessage();
}

## Refund

```php
<?php

$Transaction = new Transaction(getenv('fd_gateway_id'), getenv('fd_gateway_password'), getenv('fd_key_id'), getenv('fd_key'));
try{
	$response = $Transaction->Refund('Mastercard', 'Logan Henson', $transarmor_token, 1216, 123, 120);
}catch(FirstDataException $e){
	echo $e->getMessage();
}

Changing Currency Type

Can be used before Purchase and LatePurchase

'EUR', 'GBP', 'CHF', 'CZK', 'DKK', 'JPY', 'ZAR', 'SEK', 'CAD'

<?php

$Transaction = new Transaction(getenv('fd_gateway_id'), getenv('fd_gateway_password'), getenv('fd_key_id'), getenv('fd_key'));
try{
    $Transaction->setCurrency('CAD');
	$response = $Transaction->Purchase('Mastercard', 'Logan Henson', 5500000000000004, 1216, 123, 120);
}catch(FirstDataException $e){
	echo $e->getMessage();
}

Get All Transactions

$Search = new Search(getenv('fd_username'), getenv('fd_password'));
try{
	$transactions = $Search->getTransactions();
}catch(FirstDataException $e){
	echo $e->getMessage();
}

Test Data

Visa 4111111111111111 Expiry Date: Any future date.

Mastercard 5500000000000004 Expiry Date: Any future date.

American Express 340000000000009 Note: Amex is 15 characters Expiry Date: Any future date.

JCB 3566002020140006 Expiry Date: Any future date.

Discover 6011000000000004 Expiry Date: Any future date.

Diners Club 36438999960016 Expiry Date: Any future date.om