Python/Django: Which authorize.net library should I use?

前端 未结 6 1041
滥情空心
滥情空心 2021-01-30 04:29

I need authorize.net integration for subscription payments, likely using CIM. The requirements are simple - recurring monthly payments, with a few different price points. Custom

6条回答
  •  天命终不由人
    2021-01-30 05:14

    There is always Paython: https://github.com/abunsen/Paython

    Currently supports 5+ payment gateways:

    1. Authorize.net
    2. First Data/Linkpoint
    3. Innovative Gateway (from intuit)
    4. PlugnPay
    5. Stripe

    Here is an example:

    from paython import CreditCard, AuthorizeNet
    

    set up a card first:

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

    check if its valid:

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

    Set 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='john@localwoodshop.com', 
          ip='127.0.0.1')
    

    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)
    

    now you can settle:

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

提交回复
热议问题