Skip to content

Commit c894765

Browse files
author
krgupta
committed
merged conflicts
2 parents 3c5d437 + 6ff6ec5 commit c894765

File tree

7 files changed

+60
-111
lines changed

7 files changed

+60
-111
lines changed

README.md

Lines changed: 46 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,53 @@
1-
# sdk-python [![Build Status](https://magnum.travis-ci.com/egodolja/sdk-python.svg?token=9z5hnp59uHpbBpKa445s&branch=master)](https://magnum.travis-ci.com/egodolja/sdk-python)
2-
Python SDK for the Authorize.Net API
1+
# Authorize.Net Python SDK
32

4-
Installations
3+
[![Build Status](https://travis-ci.org/AuthorizeNet/sdk-python.png?branch=master)]
4+
(https://travis-ci.org/AuthorizeNet/sdk-python)
5+
6+
`pip install AuthorizeNet`
7+
8+
*** The Python SDK is still in limited Beta testing, please contact developer@authorize.net for more information ***
9+
10+
## Prerequisites
11+
12+
Requires
13+
14+
15+
## Installation
16+
To install AuthorizeNet
17+
18+
`pip install AuthorizeNet`
19+
20+
21+
## Registration & Configuration
22+
23+
Get a sandbox account at https://developer.authorize.net/sandbox
24+
Set your API credentials:
25+
26+
````python
27+
merchantAuth = apicontractsv1.merchantAuthenticationType()
28+
merchantAuth.name = 'YOUR_API_LOGIN_ID'
29+
merchantAuth.transactionKey = 'YOUR_TRANSACTION_KEY'
30+
````
31+
32+
For reporting tests, go to https://sandbox.authorize.net/ under Account tab->Transaction Details API and enable it.
33+
34+
35+
## Usage
36+
See our sample code repository at https://github.com/AuthorizeNet/sample-code-python
37+
38+
For the simplest "Hello World" example, use paste this into a file called charge-credit-card.py and run:
39+
40+
````python
41+
42+
````
43+
44+
## Building and Testing Source Code
45+
46+
Requirements
547
--------------------------------------
648
- python 2.7
7-
- Editor of your choice (I used PyDev for Eclipse)
849
- pyxb 1.2.4
9-
*install python before pyxb
50+
1051

1152
Run the following to get pyxb and nosetests:
1253
- pip install pyxb
@@ -18,95 +59,4 @@ Testing
1859
- Tests available are: unit tests, mock tests, sample code
1960
- use nosetests to run all unittests
2061

21-
How to Use
22-
--------------------------------------
23-
You need to set your credentials.
24-
Refer to template given in anet_python_sdk_properties_template.ini
25-
Either copy it to your root directory or make a new one similar to this. Whatever you opt, name file anet_python_sdk_properties.ini
26-
27-
The following is a sample which shows how to create a transaction request
28-
and execute it using the create transaction controller.
29-
30-
from authorizenet import apicontractsv1
31-
from decimal import *
32-
from authorizenet.apicontrollers import CreateTransactionController
33-
34-
class paymentTransaction(object):
35-
36-
#set sandbox credentials and refid
37-
api_login_id = "your api login id"
38-
transaction_key = "your transaction key"
39-
ref_id = "your ref id"
40-
41-
#create merchant authentication using sandbox credentials
42-
merchantAuthenticationOne = binding.merchantAuthenticationOne
43-
merchantAuthenticationOne.name = api_login_id
44-
merchantAuthenticationOne.transactionKey = transaction_key
45-
46-
#create credit card by filling out the following minimum requirements
47-
creditCardOne = binding.creditCardType()
48-
creditCardOne.cardNumber = "4111111111111111"
49-
creditCardOne.expirationDate = "2020-12"
50-
creditCardOne.cardCode = "999"
51-
paymentOne = binding.paymentType()
52-
paymentOne.creditCard = creditCardOne
53-
54-
#create order with details
55-
orderOne = binding.orderType()
56-
orderOne.invoiceNumber = "your invoice number"
57-
orderOne.description = "product description"
58-
59-
#create customer; the following are minimum requirements
60-
customerOne = binding.customerDataType()
61-
customerOne.id = "numeric customerOne id"
62-
63-
#create billTo information
64-
billToOne = binding.customerAddressType()
65-
billToOne.firstName = "first name"
66-
billToOne.lastName = "last name"
67-
billToOne.company = "company name"
68-
billToOne.address = "1 Main St"
69-
billToOne.city = "city name"
70-
billToOne.state = "state name"
71-
billToOne.zip = "numeric zipcode"
72-
billToOne.country = "country name"
73-
74-
#create transaction request
75-
transactionRequestOne = binding.transactionRequestType()
76-
transactionRequestOne.transactionType = "authCaptureTransaction"
77-
transactionRequestOne.amount = Decimal("6.25")
78-
transactionRequestOne.paymentOne = paymentOne
79-
transactionRequestOne.orderOne = orderOne
80-
transactionRequestOne.customerOne = customerOne
81-
transactionRequestOne.billToOne = billToOne
82-
83-
#build the createTransactionRequest
84-
createTransactionRequest = binding.createTransactionRequest()
85-
createTransactionRequest.merchantAuthenticationOne = merchantAuthenticationOne
86-
createTransactionRequest.refId = ref_id
87-
createTransactionRequest.transactionRequestOne = transactionRequestOne
88-
89-
#create the controller which is used to build xml and execute it
90-
createTransactionController = CreateTransactionController()
91-
createRequest = CreateTransactionController.CreateTransactionController(createTransactionRequest)
92-
CreateTransactionController.execute(createRequest, CreateTransactionController.getResponseClass())
93-
94-
#get the object from the response
95-
response = CreateTransactionController.getResponseObject()
96-
97-
#check the response for details
98-
if response:
99-
if response.messages.resultCode == 'OK':
100-
result = response.transactionResponse
101-
if result.responseCode == '1':
102-
print result.responseCode
103-
print 'Successful Credit Card Transaction'
104-
print ('authCode : %s' % result.authCode)
105-
print ('transId: %s' % result.transId)
106-
else:
107-
print ('Failed transaction %s' % result.responseCode)
108-
else:
109-
print ('Failed transaction %s' % response.messages.resultCode)
110-
111-
print '---------------------------------------------'
11262

anet_python_sdk_properties_template.ini

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@ md5.hash.key : MD5_HASH_KEY
99
logfilename : logFile.log
1010

1111
#proxy setup
12-
http://internet.visa.com:80
13-
https://internet.visa.com:443
12+
#http://proxy.yourcompany.com:80
13+
#https://proxy.yourcompany.com:443
1414

15-
#environments
16-
sandbox : https://apitest.authorize.net/xml/v1/request.api
17-
production : https://api.authorize.net/xml/v1/request.api
1815

authorizenet/utility.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
'''
66

77
from ConfigParser import SafeConfigParser
8+
from ConfigParser import NoSectionError
89
'''import ConfigParser'''
910
import os
1011
'''import logging'''

setup.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[metadata]
2+
description-file = DESCRIPTION.rst

setup.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,16 @@
1010

1111
here = path.abspath(path.dirname(__file__))
1212

13-
# Get the long description from the relevant file
14-
with open(path.join(here, 'DESCRIPTION.rst'), encoding='utf-8') as f:
15-
long_description = f.read()
1613

1714
setup(
18-
name='sdk-python',
15+
name='authorizenet',
1916

2017
# Versions should comply with PEP440. For a discussion on single-sourcing
2118
# the version across setup.py and the project code, see
2219
# https://packaging.python.org/en/latest/single_source_version.html
23-
version='1.0.0',
20+
version='1.0.2',
2421

25-
description='Authorize.Net Python project',
26-
long_description=long_description,
22+
description='Authorize.Net Python SDK',
2723

2824
# The project's main homepage.
2925
url='https://github.com/AuthorizeNet/sdk-python',
@@ -66,7 +62,7 @@
6662
# your project is installed. For an analysis of "install_requires" vs pip's
6763
# requirements files see:
6864
# https://packaging.python.org/en/latest/requirements.html
69-
install_requires=['pyxb', 'nose', 'nosetests', 'mock'],
65+
install_requires=['pyxb', 'nose', 'mock'],
7066
#install_requires=['nose'],
7167
#install_requires=['nosetests'],
7268
#install_requires=['mock'],

tests/apitestbase.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ def setUp(self):
2424
self.amount = str(round(random.random()*100, 2))
2525

2626
self.merchantAuthentication = apicontractsv1.merchantAuthenticationType()
27-
self.merchantAuthentication.name = helper.getproperty('api.login.id')
28-
self.merchantAuthentication.transactionKey = helper.getproperty('transaction.key')
27+
self.merchantAuthentication.name = helper.getproperty('api_login_id')
28+
self.merchantAuthentication.transactionKey = helper.getproperty('transaction_key')
2929
self.ref_id = 'Sample'
3030

3131
self.dateOne = datetime.date(2020, 8, 30)

tests/testsmock.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
Created on Jul 1, 2015
33
44
@author: egodolja
5+
6+
'''
57
'''
68
import unittest
79
@@ -12,6 +14,7 @@
1214
from authorizenet.apicontrollers import *
1315
import test
1416
'''
17+
'''
1518
class ARBCancelSubscriptionControllerTest(apitestbase.ApiTestBase):
1619
1720
def test_ARBCancelSubscriptionController(self):

0 commit comments

Comments
 (0)