This library provides basic functionality for the Fat Zebra Payment Gateway.
Currently the only features supported are:
- Creating Purchases
- Tokenizing Cards
- Purchasing with a tokenized card
- Creating Refunds
Further support for additional functionality will be added as time permits, however if you require this funcitonality and are not able to add it yourself please contact support@fatzebra.com.au and request the changes.
Purchases
importfatzebragw=fatzebra.gateway.Gateway("your username", "your token", True) # The final param indicates whether or not to use the sandboxtry:
result=gw.purchase(100, "Jim Smith", "5123456789012346", "05/2014", "123", "122.99.99.111")
ifresult.successful:
print"Purchase approved - ID: "+result.idelse:
print"Purchase declined. Message: "+result.messageexceptfatzebra.errors.GatewayError, e:
print"Gateway error: "+str(e.errors) # <-- e.errors is an array.exceptfatzebra.errors.AuthenticationError:
print"Authentication error - please check your username and token"Tokenization
importfatzebragw=fatzebra.gateway.Gateway("your username", "your token", True) # The final param indicates whether or not to use the sandboxtry:
card=gw.tokenize("Jim Smith", "5123456789012346", "05/2014", "123")
print"Card Tokenized - token: "+card.tokenexceptfatzebra.errors.GatewayError, e:
print"Gateway error: "+str(e.errors) # <-- e.errors is an array.exceptfatzebra.errors.AuthenticationError:
print"Authentication error - please check your username and token"Purchase with Token
importfatzebragw=fatzebra.gateway.Gateway("your username", "your token", True) # The final param indicates whether or not to use the sandboxtry:
token="abc12345"result=gw.purchase(100, token, "122.99.99.111")
ifresult.successful:
print"Purchase approved - ID: "+result.idelse:
print"Purchase declined. Message: "+result.messageexceptfatzebra.errors.GatewayError, e:
print"Gateway error: "+str(e.errors) # <-- e.errors is an array.exceptfatzebra.errors.AuthenticationError:
print"Authentication error - please check your username and token"Refund
importfatzebragw=fatzebra.gateway.Gateway("your username", "your token", True) # The final param indicates whether or not to use the sandboxtry:
original_transaction="013-P-ABJU879H"result=gw.refund(original_transaction, 100, "my refund reference")
ifresult.successful:
print"Refund approved - ID: "+result.idelse:
print"Refund declined. Message: "+result.messageexceptfatzebra.errors.GatewayError, e:
print"Gateway error: "+str(e.errors) # <-- e.errors is an array.exceptfatzebra.errors.AuthenticationError:
print"Authentication error - please check your username and token"The gateway class utilizes 3 error classes:
fatzebra.errors.GatewayError- this represents an unsuccessful response from the gateway (invalid card number, expiry etc). Check theerrorsattribute for messages (array)fatzebra.errors.GatewayUnknownError- this represents an unknown error. Check thecodeandresponseattributes for detailsfatzebra.errors.AuthenticationError- this indicates your username and token are incorrect. Confirm that you have the right details and you are using the right gateway. Sandbox credentials will begin with TEST
This library was developed by Matthew Savage (Fat Zebra) with the assistance of Simon Meers (Digital Eskimo). It there are any questions or problems with this library please contact Fat Zebra (support@fatzebra.com.au) or open an issue.