1. Go to this page and download the library: Download vinceg/firstdataapi 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/ */
vinceg / firstdataapi example snippets
use VinceG\FirstDataApi\FirstData;
//
// 3rd Parameter sets debug mode on.
// In debug mode, the demo gateway is used.
// You will need to create a demo gateway account with First Data
//
$firstData = new FirstData(API_LOGIN, API_KEY, true);
// Pre Auth Transaction Type
$firstData = new FirstData(API_LOGIN, API_KEY, true);
// Charge
$firstData->setTransactionType(FirstData::TRAN_PREAUTH);
$firstData->setCreditCardType($data['type'])
->setCreditCardNumber($data['number'])
->setCreditCardName($data['name'])
->setCreditCardExpiration($data['exp'])
->setAmount($data['amount'])
->setReferenceNumber($orderId);
if($data['zip']) {
$firstData->setCreditCardZipCode($data['zip']);
}
if($data['cvv']) {
$firstData->setCreditCardVerification($data['cvv']);
}
if($data['address']) {
$firstData->setCreditCardAddress($data['address']);
}
$firstData->process();
// Check
if($firstData->isError()) {
// there was an error
} else {
// transaction passed
}
// Purchase Transaction type
$firstData = new FirstData(API_LOGIN, API_KEY, true);
// Charge
$firstData->setTransactionType(FirstData::TRAN_PURCHASE);
$firstData->setCreditCardType($data['type'])
->setCreditCardNumber($data['number'])
->setCreditCardName($data['name'])
->setCreditCardExpiration($data['exp'])
->setAmount($data['amount'])
->setReferenceNumber($orderId);
if($data['zip']) {
$firstData->setCreditCardZipCode($data['zip']);
}
if($data['cvv']) {
$firstData->setCreditCardVerification($data['cvv']);
}
if($data['address']) {
$firstData->setCreditCardAddress($data['address']);
}
$firstData->process();
// Check
if($firstData->isError()) {
// there was an error
} else {
// transaction passed
}
// Purchase Transaction type
$firstData = new FirstData(API_LOGIN, API_KEY, true);
// Charge
$firstData->setTransactionType(FirstData::TRAN_PURCHASE);
$firstData->setCreditCardType($data['number'])
->setTransArmorToken($data['token'])
->setCreditCardName($data['name'])
->setCreditCardExpiration($data['exp'])
->setAmount($data['amount'])
->setReferenceNumber($orderId);
$firstData->process();
// Check
if($firstData->isError()) {
// there was an error
} else {
// transaction passed
}
// Purchase Transaction type
$firstData = new FirstData(API_LOGIN, API_KEY, true);
// Charge
$firstData->setTransactionType(FirstData::TRAN_PREAUTHCOMPLETE);
$firstData->setCreditCardType($data['number'])
->setTransArmorToken($data['token'])
->setCreditCardName($data['name'])
->setCreditCardExpiration($data['exp'])
->setAuthNumber($dat['auth_number'])
->setAmount($data['amount'])
->setReferenceNumber($orderId);
$firstData->process();
// Check
if($firstData->isError()) {
// there was an error
} else {
// transaction passed
}
// Purchase Transaction type
$firstData = new FirstData(API_LOGIN, API_KEY, true);
// Charge
$firstData->setTransactionType(FirstData::TRAN_REFUND);
$firstData->setCreditCardNumber($data['number'])
->setTransArmorToken($data['token'])
->setCreditCardName($data['name'])
->setCreditCardExpiration($data['exp'])
->setAmount($data['amount'])
->setReferenceNumber($orderId);
$firstData->process();
// Check
if($firstData->isError()) {
// there was an error
} else {
// transaction passed
}
// Purchase Transaction type
$firstData = new FirstData(API_LOGIN, API_KEY, true);
// Charge
$firstData->setTransactionType(FirstData::TRAN_VOID);
$firstData->setCreditCardType($data['number'])
->setTransArmorToken($data['token'])
->setCreditCardName($data['name'])
->setCreditCardExpiration($data['exp'])
->setAmount($data['amount'])
->setReferenceNumber($orderId);
$firstData->process();
// Check
if($firstData->isError()) {
// there was an error
} else {
// transaction passed
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.