Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython

fatzebra is unavailable in PyPM, because there aren't any builds for it in the package repositories. Click the linked icons to find out why.

 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
Windows (64-bit)
Mac OS X (10.5+)
Linux (32-bit)
Linux (64-bit)
 
Links
Author

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.

Usage

Purchases

import fatzebra

gw = fatzebra.gateway.Gateway("your username", "your token", True) # The final param indicates whether or not to use the sandbox try:

System Message: ERROR/3 (<string>, line 28)

Unexpected indentation.

result = gw.purchase(100, "Jim Smith", "5123456789012346", "05/2014", "123", "122.99.99.111") if result.successful:

System Message: ERROR/3 (<string>, line 30)

Unexpected indentation.
print "Purchase approved - ID: " + result.id

System Message: WARNING/2 (<string>, line 31)

Block quote ends without a blank line; unexpected unindent.
else:
print "Purchase declined. Message: " + result.message

System Message: WARNING/2 (<string>, line 33)

Block quote ends without a blank line; unexpected unindent.
except fatzebra.errors.GatewayError, e:
print "Gateway error: " + str(e.errors) # <-- e.errors is an array.
except fatzebra.errors.AuthenticationError:
print "Authentication error - please check your username and token"
Tokenization

import fatzebra

gw = fatzebra.gateway.Gateway("your username", "your token", True) # The final param indicates whether or not to use the sandbox try:

System Message: ERROR/3 (<string>, line 45)

Unexpected indentation.
card = gw.tokenize("Jim Smith", "5123456789012346", "05/2014", "123") print "Card Tokenized - token: " + card.token

System Message: WARNING/2 (<string>, line 47)

Block quote ends without a blank line; unexpected unindent.
except fatzebra.errors.GatewayError, e:
print "Gateway error: " + str(e.errors) # <-- e.errors is an array.
except fatzebra.errors.AuthenticationError:
print "Authentication error - please check your username and token"
Purchase with Token

import fatzebra

gw = fatzebra.gateway.Gateway("your username", "your token", True) # The final param indicates whether or not to use the sandbox try:

System Message: ERROR/3 (<string>, line 60)

Unexpected indentation.

token = "abc12345" result = gw.purchase(100, token, "122.99.99.111") if result.successful:

System Message: ERROR/3 (<string>, line 63)

Unexpected indentation.
print "Purchase approved - ID: " + result.id

System Message: WARNING/2 (<string>, line 64)

Block quote ends without a blank line; unexpected unindent.
else:
print "Purchase declined. Message: " + result.message

System Message: WARNING/2 (<string>, line 66)

Block quote ends without a blank line; unexpected unindent.
except fatzebra.errors.GatewayError, e:
print "Gateway error: " + str(e.errors) # <-- e.errors is an array.
except fatzebra.errors.AuthenticationError:
print "Authentication error - please check your username and token"
Refund

import fatzebra

gw = fatzebra.gateway.Gateway("your username", "your token", True) # The final param indicates whether or not to use the sandbox try:

System Message: ERROR/3 (<string>, line 79)

Unexpected indentation.

original_transaction = "013-P-ABJU879H" result = gw.refund(original_transaction, 100, "my refund reference") if result.successful:

System Message: ERROR/3 (<string>, line 82)

Unexpected indentation.
print "Refund approved - ID: " + result.id

System Message: WARNING/2 (<string>, line 83)

Block quote ends without a blank line; unexpected unindent.
else:
print "Refund declined. Message: " + result.message

System Message: WARNING/2 (<string>, line 85)

Block quote ends without a blank line; unexpected unindent.
except fatzebra.errors.GatewayError, e:
print "Gateway error: " + str(e.errors) # <-- e.errors is an array.
except fatzebra.errors.AuthenticationError:
print "Authentication error - please check your username and token"

Notes

The gateway class utilizes 3 error classes:

  • fatzebra.errors.GatewayError - this represents an unsuccessful response from the gateway (invalid card number, expiry etc). Check the errors attribute for messages (array)
  • fatzebra.errors.GatewayUnknownError - this represents an unknown error. Check the code and response attributes for details
  • fatzebra.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

Credits

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.

Subscribe to package updates

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.