Skip to content

standardize readme format and info across repos #81

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Jul 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
104 changes: 44 additions & 60 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,101 +5,85 @@
[![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)
[![PyPI](https://img.shields.io/pypi/v/authorizenet.svg)](https://badge.fury.io/py/authorizenet)

`pip install authorizenet`

## Requirements
* Python 2.7 or greater
* OpenSSL 1.0.2 or greater
* An Authorize.Net account (see _Registration & Configuration_ section below)

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

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.
### TLS 1.2
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.


## Installation
To install AuthorizeNet
To install the AuthorizeNet Python SDK:

`pip install authorizenet`


## Registration & Configuration
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.
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/).

### Authentication
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).

Get a sandbox account at https://developer.authorize.net/sandbox
Set your API credentials:
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.

````python
#### To set your API credentials for an API request:
```python
merchantAuth = apicontractsv1.merchantAuthenticationType()
merchantAuth.name = 'YOUR_API_LOGIN_ID'
merchantAuth.transactionKey = 'YOUR_TRANSACTION_KEY'
````


## Usage
See our sample code repository at https://github.com/AuthorizeNet/sample-code-python

For the simplest "Hello World" example, paste this into a file called charge-credit-card.py and run:

````python
from authorizenet import apicontractsv1
from authorizenet.apicontrollers import *
from decimal import *
```

merchantAuth = apicontractsv1.merchantAuthenticationType()
merchantAuth.name = 'YOUR_LOGIN_ID'
merchantAuth.transactionKey = 'YOUR_TRANSACTION_KEY'
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.

creditCard = apicontractsv1.creditCardType()
creditCard.cardNumber = "4111111111111111"
creditCard.expirationDate = "2020-12"
### Switching between the sandbox environment and the production environment
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:
```python
# For PRODUCTION use
createtransactioncontroller.setenvironment(constants.PRODUCTION)
```

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

transactionrequest = apicontractsv1.transactionRequestType()
transactionrequest.transactionType = "authCaptureTransaction"
transactionrequest.amount = Decimal ('1.55')
transactionrequest.payment = payment

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

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

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

response = createtransactioncontroller.getresponse()
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.

if (response.messages.resultCode=="Ok"):
print "Transaction ID : %s" % response.transactionResponse.transId
else:
print "response code: %s" % response.messages.resultCode

````
### Setting Production or Sandbox Environments
To set the environment use the setenvironment method on the controller before executing. E.g. for the example above:
````python
# Defaults to constants.SANDBOX for sandbox testing
createtransactioncontroller.setenvironment(constants.PRODUCTION)
````
## Building & Testing the SDK

## Building and Testing Source Code

Requirements
--------------------------------------
### Requirements
- python 2.7
- pyxb 1.2.4


Run the following to get pyxb and nosetests:
- pip install pyxb
- pip install unittest2
- pip install nose
- pip install lxml

Testing
--------------------------------------
### Running the SDK Tests
- Tests available are: unit tests, mock tests, sample code
- use nosetests to run all unittests
`
>nosetests
`
- use nosetests to run all unittests

`>nosetests`

### Testing Guide
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.


## License
This repository is distributed under a proprietary license. See the provided [`LICENSE.txt`](/license.txt) file.
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