Skip to content

Commit 6a16e3a

Browse files
author
Sunny Raj Rathod
authored
Merge pull request #89 from AuthorizeNet/master
Sync future with master
2 parents 0205e10 + 9771572 commit 6a16e3a

File tree

7 files changed

+104
-91
lines changed

7 files changed

+104
-91
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,6 @@ docs/_build/
5656

5757
# PyBuilder
5858
target/
59+
60+
# Operating system files
61+
.DS_Store

.travis.yml

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,50 @@
11
language: python
2+
23
sudo: false
34

5+
env:
6+
- TEST_SUITE=samples
7+
- TEST_SUITE=coverage
48
python:
59
- "2.7"
610
- "3.4"
711
- "3.5"
8-
# - "pypy" Disabling pypy until travis moves to newer version, known issue with lxml crashing pypy
12+
- "3.6"
13+
- "3.7-dev"
14+
- "pypy"
15+
- "pypy3"
16+
17+
matrix:
18+
fast_finish: true
19+
allow_failures:
20+
- python: "3.7-dev"
21+
# 3.7-dev started crashing when building lxml although the neither the python version nor the lxml version seemed to change.
22+
# Will have to investigate further.
23+
- python: "pypy"
24+
- python: "pypy3"
25+
# pypy will just crash due to an incompatibility with lxml.
26+
# Newer versions of pypy seem to crash also, so we probably have to fix with a newer version of lxml
27+
28+
before_install:
29+
# execute all of the commands which need to be executed
30+
# before installing dependencies
931

1032
install:
11-
- pip install unittest2
12-
- pip install nose
13-
- pip install pyxb
14-
- pip install lxml
15-
- pip install coveralls
33+
# install all of the dependencies we need here
34+
- pip install nose
35+
- pip install pyxb==1.2.5
36+
# can't change the pyxb version without changing the version in setup.py
37+
# and regenerating the bindings in apicontractsv1.py
38+
- pip install lxml
39+
- if [[ "$TEST_SUITE" == "coverage" ]]; then pip install coveralls; fi
1640

1741
before_script:
18-
- git submodule update --remote --recursive
42+
# execute all of the commands which need to be executed
43+
# before running actual tests
44+
- if [[ "$TEST_SUITE" == "samples" ]]; then git submodule update --remote --recursive; fi
1945

2046
script:
21-
- nosetests --with-coverage -cover-package=authorizenet
22-
- coveralls
23-
- python setup.py install
24-
- cd sample-code-python
25-
- python ./test-runner.py
47+
# execute all of the tests or other commands to determine
48+
# whether the build will pass or fail
49+
- if [[ "$TEST_SUITE" == "coverage" ]]; then nosetests --with-coverage -cover-package=authorizenet; coveralls; fi
50+
- if [[ "$TEST_SUITE" == "samples" ]]; then python setup.py install; cd sample-code-python; python ./test-runner.py; fi

DESCRIPTION.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Python - demo version commit
77
Installations
88
--------------------------------------
99
- python 2.7
10-
- pyxb 1.2.4
10+
- pyxb 1.2.5
1111
*install python before pyxb
1212
1313

License.md renamed to LICENSE.txt

File renamed without changes.

README.md

Lines changed: 48 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,105 +1,89 @@
11
# Authorize.Net Python SDK
22

3-
[![Travis](https://img.shields.io/travis/AuthorizeNet/sdk-python/master.svg)](https://travis-ci.org/AuthorizeNet/sdk-python)
3+
[![Travis CI Status](https://travis-ci.org/AuthorizeNet/sdk-python.svg?branch=master)](https://travis-ci.org/AuthorizeNet/sdk-python)
44
[![Coverage Status](https://coveralls.io/repos/github/AuthorizeNet/sdk-python/badge.svg?branch=master)](https://coveralls.io/github/AuthorizeNet/sdk-python?branch=master)
55
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/AuthorizeNet/sdk-python/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/AuthorizeNet/sdk-python/?branch=master)
66
[![PyPI](https://img.shields.io/pypi/v/authorizenet.svg)](https://badge.fury.io/py/authorizenet)
77

8-
`pip install authorizenet`
98

9+
## Requirements
10+
* For Python 2, Python 2.7 or greater
11+
* For Python 3, Python 3.4 or later
12+
* OpenSSL 1.0.2 or greater
13+
* An Authorize.Net account (see _Registration & Configuration_ section below)
1014

11-
## Prerequisites
15+
_Note: Our goal is ensuring this SDK is compatible with Python 2.7+, 3.4+ and PyPy, but at the moment we're primarily testing against Python 2.7._
1216

13-
We'll be ensuring this SDK is compatible with Python 2.6+, 3.2+ and PyPy but we're primarily testing against Python 2.7 so that's the current prerequisite.
17+
### TLS 1.2
18+
The Authorize.Net APIs only support connections using the TLS 1.2 security protocol. It's important to make sure you have new enough versions of all required components to support TLS 1.2. Additionally, it's very important to keep these components up to date going forward to mitigate the risk of any security flaws that may be discovered in your system or any libraries it uses.
1419

1520

1621
## Installation
17-
To install AuthorizeNet
22+
To install the AuthorizeNet Python SDK:
1823

1924
`pip install authorizenet`
2025

2126

2227
## Registration & Configuration
28+
Use of this SDK and the Authorize.Net APIs requires having an account on our system. You can find these details in the Settings section.
29+
If you don't currently have a production Authorize.Net account and need a sandbox account for testing, you can easily sign up for one [here](https://developer.authorize.net/sandbox/).
30+
31+
### Authentication
32+
To authenticate with the Authorize.Net API you will need to use your account's API Login ID and Transaction Key. If you don't have these values, you can obtain them from our Merchant Interface site. Access the Merchant Interface for production accounts at (https://account.authorize.net/) or sandbox accounts at (https://sandbox.authorize.net).
2333

24-
Get a sandbox account at https://developer.authorize.net/sandbox
25-
Set your API credentials:
34+
Once you have your keys simply load them into the appropriate variables in your code, as per the below sample code dealing with the authentication part of the API request.
2635

27-
````python
36+
#### To set your API credentials for an API request:
37+
```python
2838
merchantAuth = apicontractsv1.merchantAuthenticationType()
2939
merchantAuth.name = 'YOUR_API_LOGIN_ID'
3040
merchantAuth.transactionKey = 'YOUR_TRANSACTION_KEY'
31-
````
32-
33-
34-
## Usage
35-
See our sample code repository at https://github.com/AuthorizeNet/sample-code-python
36-
37-
For the simplest "Hello World" example, paste this into a file called charge-credit-card.py and run:
38-
39-
````python
40-
from authorizenet import apicontractsv1
41-
from authorizenet.apicontrollers import *
42-
from decimal import *
41+
```
4342

44-
merchantAuth = apicontractsv1.merchantAuthenticationType()
45-
merchantAuth.name = 'YOUR_LOGIN_ID'
46-
merchantAuth.transactionKey = 'YOUR_TRANSACTION_KEY'
43+
You should never include your Login ID and Transaction Key directly in a file that's in a publically accessible portion of your website. A better practice would be to define these in a constants file, and then reference those constants in the appropriate place in your code.
4744

48-
creditCard = apicontractsv1.creditCardType()
49-
creditCard.cardNumber = "4111111111111111"
50-
creditCard.expirationDate = "2020-12"
45+
### Switching between the sandbox environment and the production environment
46+
Authorize.Net maintains a complete sandbox environment for testing and development purposes. This sandbox environment is an exact duplicate of our production environment with the transaction authorization and settlement process simulated. By default, this SDK is configured to communicate with the sandbox environment. To switch to the production environment, use the `setenvironment` method on the controller before executing. For example:
47+
```python
48+
# For PRODUCTION use
49+
createtransactioncontroller.setenvironment(constants.PRODUCTION)
50+
```
5151

52-
payment = apicontractsv1.paymentType()
53-
payment.creditCard = creditCard
52+
API credentials are different for each environment, so be sure to switch to the appropriate credentials when switching environments.
5453

55-
transactionrequest = apicontractsv1.transactionRequestType()
56-
transactionrequest.transactionType = "authCaptureTransaction"
57-
transactionrequest.amount = Decimal ('1.55')
58-
transactionrequest.payment = payment
5954

55+
## SDK Usage Examples and Sample Code
56+
To get started using this SDK, it's highly recommended to download our sample code repository:
57+
* [Authorize.Net Python Sample Code Repository (on GitHub)](https://github.com/AuthorizeNet/sample-code-python)
6058

61-
createtransactionrequest = apicontractsv1.createTransactionRequest()
62-
createtransactionrequest.merchantAuthentication = merchantAuth
63-
createtransactionrequest.refId = "MerchantID-0001"
59+
In that respository, we have comprehensive sample code for all common uses of our API:
6460

65-
createtransactionrequest.transactionRequest = transactionrequest
66-
createtransactioncontroller = createTransactionController(createtransactionrequest)
67-
createtransactioncontroller.execute()
61+
Additionally, you can find details and examples of how our API is structured in our API Reference Guide:
62+
* [Developer Center API Reference](http://developer.authorize.net/api/reference/index.html)
6863

69-
response = createtransactioncontroller.getresponse()
64+
The API Reference Guide provides examples of what information is needed for a particular request and how that information would be formatted. Using those examples, you can easily determine what methods would be necessary to include that information in a request using this SDK.
7065

71-
if (response.messages.resultCode=="Ok"):
72-
print "Transaction ID : %s" % response.transactionResponse.transId
73-
else:
74-
print "response code: %s" % response.messages.resultCode
7566

76-
````
77-
### Setting Production or Sandbox Environments
78-
To set the environment use the setenvironment method on the controller before executing. E.g. for the example above:
79-
````python
80-
# Defaults to constants.SANDBOX for sandbox testing
81-
createtransactioncontroller.setenvironment(constants.PRODUCTION)
82-
````
67+
## Building & Testing the SDK
8368

84-
## Building and Testing Source Code
85-
86-
Requirements
87-
--------------------------------------
69+
### Requirements
8870
- python 2.7
89-
- pyxb 1.2.4
90-
71+
- pyxb 1.2.5
9172

9273
Run the following to get pyxb and nosetests:
93-
- pip install pyxb
94-
- pip install unittest2
74+
- pip install pyxb==1.2.5
9575
- pip install nose
9676
- pip install lxml
9777

98-
Testing
99-
--------------------------------------
78+
### Running the SDK Tests
10079
- Tests available are: unit tests, mock tests, sample code
101-
- use nosetests to run all unittests
102-
`
103-
>nosetests
104-
`
80+
- use nosetests to run all unittests
81+
82+
`>nosetests`
83+
84+
### Testing Guide
85+
For additional help in testing your own code, Authorize.Net maintains a [comprehensive testing guide](http://developer.authorize.net/hello_world/testing_guide/) that includes test credit card numbers to use and special triggers to generate certain responses from the sandbox environment.
86+
10587

88+
## License
89+
This repository is distributed under a proprietary license. See the provided [`LICENSE.txt`](/LICENSE.txt) file.

authorizenet/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class constants(object):
1616
PRODUCTION = 'https://api2.authorize.net/xml/v1/request.api'
1717

1818
'''clientId'''
19-
version = '1.0.13'
19+
version = '1.0.14'
2020
clientId = 'sdk-python-' + version
2121

2222
'''xml encoding'''

setup.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# Versions should comply with PEP440. For a discussion on single-sourcing
1818
# the version across setup.py and the project code, see
1919
# https://packaging.python.org/en/latest/single_source_version.html
20-
version='1.0.13',
20+
version='1.0.14',
2121

2222
description='Authorize.Net Python SDK',
2323

@@ -48,7 +48,8 @@
4848

4949
# Specify the Python versions you support here. In particular, ensure
5050
# that you indicate whether you support Python 2, Python 3 or both.
51-
'Programming Language :: Python :: 3.5'
51+
'Programming Language :: Python :: 2.7',
52+
'Programming Language :: Python :: 3.4'
5253
],
5354

5455
# What does your project relate to?
@@ -63,11 +64,11 @@
6364
# requirements files see:
6465
# https://packaging.python.org/en/latest/requirements.html
6566
install_requires=['pyxb==1.2.5', 'nose', 'mock', 'lxml'],
66-
#install_requires=['nose'],
67-
#install_requires=['nosetests'],
68-
#install_requires=['mock'],
69-
#install_requires=['lxml'],
70-
67+
#install_requires=['nose'],
68+
#install_requires=['nosetests'],
69+
#install_requires=['mock'],
70+
#install_requires=['lxml'],
71+
7172
# List additional groups of dependencies here (e.g. development
7273
# dependencies). You can install these using the following syntax,
7374
# for example:
@@ -80,22 +81,22 @@
8081
},
8182
environment_variables={
8283
#api.login.id : xyz
83-
#transaction.key : xyz
84+
#transaction.key : xyz
8485
#md5.hash.key : MD5_HASH_KEY
8586
},
8687

8788
# If there are data files included in your packages that need to be
8889
# installed, specify them here. If using Python 2.6 or less, then these
8990
# have to be included in MANIFEST.in as well.
90-
#package_data={
91+
#package_data={
9192
# 'sample': ['package_data.dat'],
92-
#},
93-
93+
#},
94+
9495
# Although 'package_data' is the preferred approach, in some case you may
9596
# need to place data files outside of your packages. See:
9697
# http://docs.python.org/3.4/distutils/setupscript.html#installing-additional-files # noqa
9798
# In this case, 'data_file' will be installed into '<sys.prefix>/my_data'
98-
# data_files=[('my_data', ['data/data_file'])],
99+
# data_files=[('my_data', ['data/data_file'])],
99100

100101
# To provide executable scripts, use entry points in preference to the
101102
# "scripts" keyword. Entry points provide cross-platform support and allow
@@ -104,5 +105,5 @@
104105
# 'console_scripts': [
105106
# 'sample=sample:main',
106107
# ],
107-
#},
108+
#},
108109
)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy