Skip to content

Commit 8fe9601

Browse files
committed
Update README.md
1 parent 55dd715 commit 8fe9601

File tree

1 file changed

+46
-96
lines changed

1 file changed

+46
-96
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-pyhton.png?branch=master)]
4+
(https://travis-ci.org/AuthorizeNet/sdk-pyhton)
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 = '5KP3u95bQpv'
29+
merchantAuth.transactionKey = '4Ktq966gC55GAX7S'
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

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