Need help with Paython?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

abunsen
200 Stars 39 Forks MIT License 120 Commits 5 Opened issues

Description

ActiveMerchant rip off in Python created by Auston Bunsen, with help from Igor Guerrero & a handful of others. Fork me & improve me!

Services available

!
?

Need anything else?

Contributors list

# 181,715
Objecti...
e2e-tes...
Android
C
41 commits
# 340,257
Shell
C
Objecti...
28 commits
# 161,001
HTML
Shell
Vue.js
CSS
11 commits
# 94,427
Redis
spring-...
fish-sh...
music-s...
6 commits
# 277,684
Shell
jdbc
Databas...
SQLite
2 commits
# 324,291
Shell
HTML
pdf-con...
PHP
2 commits
# 183,422
HTML
trading...
Shell
golang
2 commits
# 117,414
Shell
Less
tagging
Go
1 commit
# 681,287
Python
1 commit
# 742,337
Python
1 commit
# 21,151
CSS
JavaScr...
anti-sp...
meteor
1 commit
# 584,635
Python
1 commit
# 728,938
Python
1 commit

Paython

Build Status

Trying to make it easy to accept payments in Python. So far, we're Paython - a library in python for payment gateways like Stripe, ePay, Authorize.net, PlugNPay, First Data & more.

Currently - you can just import the gateway needed from gateways & auth/settle/capture (sale)/void/credit once you instantiate with the proper credentials.

IMPORTANT: If you fork & make a cool or useful change, we'd really love it if you wrote some associated tests & issued a pull request that way we can keep this repo up to date ;)

Supported Gateways

  • Stripe
  • Authorize.net
  • Innovative Gateway Solutions (Intuit)
  • First Data Global Gateway (formerly Linkpoint?)
  • PlugnPay
  • Samurai
  • ePay (untested)

Usage

It's super simple to start:

Importing what you need

from paython import CreditCard, AuthorizeNet

Setting up a credit card

credit_card = CreditCard(
    number = '4111111111111111',
    exp_mo = '02',
    exp_yr = '2012',
    first_name = 'John',
    last_name = 'Doe',
    cvv = '911',
    strict = False
)

Checking to see if it's valid

 if not credit_card.is_valid(): return 'houston, we have a problem' # checks card number + expiration date

Setting up customer data to charge, not all fields are required.

customer_data = dict(
    address='123 Main St', 
    address2='Apt 1', 
    city='Pleasantville', 
    state='IA', 
    zipcode='54321', 
    country='US', 
    phone='654-369-9589', 
    email='[email protected]', 
    ip='127.0.0.1')

Trying to authorize against gateway, options include debug output or test credentials

api = AuthorizeNet(username='test', password='testpassword', debug=True, test=True)
gateway_response = api.auth(amount='0.05', credit_card=credit_card, billing_info=customer_data, shipping_info=None)

Keep in mind, if you authorize, you need to settle

api = AuthorizeNet(username='test', password='testpassword', debug=True, test=True)
gateway_response = api.settle(amount='0.05', trans_id='2156729380')

OR, you can capture instead

api = AuthorizeNet(username='test', password='testpassword', debug=True, test=True)
gateway_response = api.capture(amount='0.05', credit_card=credit_card, billing_info=customer_data, shipping_info=None)

This is a typical paython response.

    gateway_response = {
        'response_text': 'This transaction has been approved.',
        'cvv_response': 'P',
        'response_code': '1',
        'trans_type': 'auth_only',
        'amount': '0.05',
        'avs_response': 'Y',
        'response_reason_code': '1',
        'trans_id': '2156729380',
        'alt_trans_id': '',
        'auth_code': 'IL2UW7',
        'approved': True,
        'response_time': '0.55'
    }

Install

You can use pip to install Paython::

pip install paython

Run Tests

Just run::

nosetests

Or with stats::

nosetests --quiet --with-coverage --cover-package paython

When initializing a gateway, debug will output request params, xml & response text or xml. test will use the test gateway endpoint, if there is one & will raise an error otherwise (NoTestEndpointError).

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.