Skip to content

Instantly share code, notes, and snippets.

@amasses
Created July 26, 2012 00:10
Show Gist options
  • Save amasses/3179487 to your computer and use it in GitHub Desktop.
Save amasses/3179487 to your computer and use it in GitHub Desktop.
PHP Standard Payments example
<?php
include_once("FatZebra.class.php");
define("FATZEBRA_USERNAME", "TEST");
define("FATZEBRA_TOKEN", "TEST");
define("FATZEBRA_GATEWAY", "gateway.sandbox.fatzebra.com.au"); // Live: gateway.fatzebra.com.au
define("FATZEBRA_TEST_MODE", true);
$gateway = new FatZebra\Gateway(FATZEBRA_USERNAME, FATZEBRA_TOKEN, FATZEBRA_TEST_MODE, FATZEBRA_GATEWAY); // The last option can be omitted to use the live gateway
$amount = 10.00;
$reference = "TEST" . rand(); // Unique reference
$card_holder = "Mark Smith";
$card_number = "5123456789012346";
$expiry = "05/2013";
$cvv = "123";
$request = new FatZebra\PurchaseRequest($amount, $reference, $card_holder, $card_number, $expiry, $cvv);
$result = $gateway->purchase($request);
if ($result->successful && $result->response->successful) {
echo "Your transaction was successful. Authorization: " . $result->response->authorization . ", Transaction ID: . " $result->response->id;
} else if($result->successful) {
// Declined or otherwise
echo "Your transaction was not successful: " . $result->response->message);
} else {
// Error in data etc
echo "Errors processing transaction: ";
foreach($result->errors as $error) {
echo " - " . $error . "\r\n";
}
}
?>
@amasses
Copy link
Author

amasses commented Jul 26, 2012

Note: this code is untested and is for example purposes only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment