-
Notifications
You must be signed in to change notification settings - Fork 8
License
ianhalpern/python-payment-processor
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Python Payment Processor - (c) RentShare Inc 2012, Author: Ian Halpern Python Payment Processor is a library for python providing a simple abstraction around various payment methods and payment gateways. It includes support for standard gateways such as Authorize.net and is always working to expand it's supported gateway repertoire. Python Payment is currently being used in production systems transferring hundreds of thousands of dollars a month. Python Payment Processor is released under the MIT license. *A special thanks to Brandon Stoner for collaborating on the initial concept design. INSTALL: To install python-payment-processor run: $ sudo ./setup.py install HOW TO: Here is a simple example using the authroize.net payment gateway. This example creates a authorize.net payment gateway and a credit card transaction and processes the transaction. ---------------------------------------------------- import payment_processor from payment_processor.exceptions import * # the authorize.net gateway requires valid authorize.net 'login' and 'trans_key' variables gateway = payment_processor.Gateway( 'authorize.net', login='XXX', trans_key='XXX' ) # other authroize.net variables include 'use_test_url' which, if set, # will use https://test.authorize.net/ instead of https://secure.authorize.net # if you are using a developer account card = payment_processor.methods.CreditCard( card_number=4011111111111111, expiration_date=datetime.datetime( 2014, 1, 1 ), first_name='First', last_name='Last', zip_code='10001', address='1 Somewhere Ave', city='New York', state='NY' ) payment = payment_processor.PaymentInfo( amount = 20, customer_id = 1, order_number = '43DJ-7203-D897-SS97', ship_first_name = 'First', ship_last_name = 'Last', ship_address = '1 Somewhere Ave', ship_city = 'New York', ship_state = 'NY', ship_email = '[email protected]', ship_phone = '222-333-4444', ip = '65.192.14.10', description = 'Some Order' ) t = payment_processor.Transaction( payment=payment, method=card, gateway=gateway ) try: t.process() except TransactionDeclined: # The transaction requested was declined for such reasons as insufficient funds or flagged for fraud. raise except InvalidCardNumber: # The credit card number provided was invalid. raise except InvalidCardExpirationDate: # The credit card expiration date provided was invalid. raise except InvalidCardCode: # The credit card code provided was invalid. raise except InvalidRoutingNumber: # The routing number provided was invalid (only applicable to Check methods). raise except InvalidAccountNumber: # The account number provided was invalid (only applicable to Check methods). raise except InvalidBillingAddress: # The billing address provided was invalid. raise except InvalidBillingZipcode: # The billing zipcode provided was invalid. raise except TransactionAmountLimitExceeded: # The per-transaction limit was exceeded. raise except TransactionFailed: # The transaction failed for other reasons usually relating using python-payment in ways unsupported by the gateway. raise ---------------------------------------------------- Using payment_processor.Gateway always take a string as the first argument which is used as a simple way to dynamically load a specific gateway found in payment.gateways. You can easily create a gateway outside of the python-payment-processor module, just create a class that overloads payment.gateways.GenericGateway. ---------------------------------------------------- from payment_processor.gateways import GenericGateway class MyGateway( GenericGateway ) ...
About
No description, website, or topics provided.
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published