Created
July 26, 2012 00:10
-
-
Save amasses/3179487 to your computer and use it in GitHub Desktop.
PHP Standard Payments example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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"; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note: this code is untested and is for example purposes only.