forked from Vantiv/vantiv-sdk-for-python
-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.py
276 lines (225 loc) · 9.78 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
# -*- coding: utf-8 -*-
import sys
from setuptools import setup
# Require Python 2.7.9 or higher or Python 3.4 or higher
if (sys.version_info[:3] < (2, 7, 9)) or ((sys.version_info[0] == 3) and sys.version_info[:2] < (3, 4)):
raise ValueError('''PyXB requires:
Python2 version 2.7.9 or later; or
Python3 version 3.4 or later
(You have %s.)''' % (sys.version,))
setup(
name='VantiveCommerceSDK',
version='12.22.0',
description='Vantiv eCommerce Python SDK',
author='Vantiv eCommerce',
author_email='[email protected]',
url='https://developer.vantiv.com/community/ecommerce',
packages=['vantivsdk', 'scripts'],
install_requires=[
'PyXB==1.2.6',
'paramiko>=1.14.0',
'requests>=2.13.0',
'six>=1.10.0',
'xmltodict>=0.10.2'
],
license='MIT',
classifiers=[
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'Intended Audience :: System Administrators',
'Intended Audience :: Information Technology',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Topic :: Office/Business :: Financial',
'Topic :: Software Development :: Libraries',
'Topic :: Software Development :: Libraries :: Python Modules'
],
entry_points={
'console_scripts': [
'vantiv_python_sdk_setup = scripts.vantiv_python_sdk_setup:main',
],
},
long_description='''Vantiv eCommerce Python SDK
=============================
.. _`Vantiv eCommerce`: https://developer.vantiv.com/community/ecommerce
About Vantiv eCommerce
----------------------
`Vantiv eCommerce`_ powers the payment processing engines for leading companies that sell directly to consumers through internet retail, direct response marketing (TV, radio and telephone), and online services. Vantiv eCommerce is the leading authority in card-not-present (CNP) commerce, transaction processing and merchant services.
About this SDK
--------------
The Vantiv eCommerce Python SDKt is a Python implementation of the `Vantiv eCommerce`_ XML API. This SDK was created to make it as easy as possible to connect to and process payments through Vantiv eCommerce. This SDK utilizes the HTTPS protocol to securely connect to Vantiv eCommerce. Using the SDK requires coordination with the Vantiv eCommerce team to obtain credentials for accessing our systems.
Each Python SDK release supports all of the functionality present in the associated Vantiv eCommerce XML version (e.g., 11.0.x supports Vantiv eCommerce XML v11.0). Please see the online copy of our XSD for Vantiv eCommerce XML to get more details on what the Vantiv eCommerce payments engine supports .
This SDK was implemented to support the Python2 version 2.7.9 and later, Python3 version 3.4 and later, and was created by Vantiv eCommerce. Its intended use is for online transaction processing utilizing your account on the Vantiv eCommerce payments engine.
See LICENSE file for details on using this software.
Source Code available from : https://github.com/Vantiv/vantiv-sdk-for-python
Examples can be found here https://github.com/Vantiv/vantiv-sdk-for-python/tree/master/samples
Detail documents can be found here http://vantivecommercepythonsdk.readthedocs.io/en/latest/
Please contact `Vantiv eCommerce`_ to receive valid merchant credentials and determine which version of the SDK is right for your business requirements or if you require assistance in any other way. You can reach us at [email protected]
Dependencies
------------
* pyxb v1.2.5 : http://pyxb.sourceforge.net/
* paramiko v1.14.0: http://www.paramiko.org/
* requests v2.13.0: http://docs.python-requests.org/en/master/
* six v1.10.0: https://github.com/benjaminp/six
* xmltodict 0.10.2: https://github.com/martinblech/xmltodict
Setup
-----
* Run vantiv_python_sdk_setup and answer the questions.
.. code:: bash
vantiv_python_sdk_setup
EXAMPLE
-------
Using dict
..........
.. code-block:: python
#Example for SDK
from __future__ import print_function, unicode_literals
from vantivsdk import *
# Initial Configuration object. If you have saved configuration in '.vantiv_python_sdk.conf' at system environment
# variable: VANTIV_SDK_CONFIG or user home directory, the saved configuration will be automatically load.
conf = utils.Configuration()
# Configuration need following attributes for online request:
# attributes = default value
# user = ''
# password = ''
# merchantId = ''
# reportGroup = 'Default Report Group'
# url = 'https://www.testlitle.com/sandbox/communicator/online'
# proxy = ''
# print_xml = False
# Transaction presented by dict
txn_dict ={
'authorization':{
'orderId': '1',
'amount': 10010,
'orderSource': 'ecommerce',
'id': 'ThisIsRequiredby11',
'billToAddress': {
'name': 'John & Mary Smith',
'addressLine1': '1 Main St.',
'city': 'Burlington',
'state': 'MA',
'zip': '01803-3747',
'country': 'USA'
},
'card': {
'number': '4100000000000000',
'expDate': '1215',
'cardValidationNum' : '349',
'type': 'VI'
},
'enhancedData':{
'detailTax': [
{'taxAmount':100},
{'taxAmount':200},
],
}
}
}
# Send request to server and get response as dict
response = online.request(txn_dict, conf)
print('Message: %s' % response['authorizationResponse']['message'])
print('CNPTransaction ID: %s' % response['authorizationResponse']['cnpTxnId'])
# Configuration need following attributes for batch request:
# attributes = default value
# sftp_username = ''
# sftp_password = ''
# sftp_url = ''
# batch_requests_path = '/tmp/vantiv_sdk_batch_request'
# batch_response_path = '/tmp/vantiv_sdk_batch_response'
# fast_url = ''
# fast_ssl = True
# fast_port = ''
# id = ''
# Initial batch transactions container class
transactions = batch.Transactions()
# Add transaction to batch transactions container
transactions.add(txn_dict)
# Sent batch to server via socket and get response as dict
response = batch.stream(transactions, conf)
print('Message: %s' % response['batchResponse']['authorizationResponse']['message'])
print('CNPTransaction ID: %s' % response['batchResponse']['authorizationResponse']['cnpTxnId'])
Using object
............
.. code-block:: python
#Example for SDK
from __future__ import print_function, unicode_literals
from vantivsdk import *
# Initial Configuration object. If you have saved configuration in '.vantiv_python_sdk.conf' at system environment
# variable: VANTIV_SDK_CONFIG or user home directory, the saved configuration will be automatically load.
conf = utils.Configuration()
# Configuration need following attributes for online request:
# attributes = default value
# user = ''
# password = ''
# merchantId = ''
# reportGroup = 'Default Report Group'
# url = 'https://www.testlitle.com/sandbox/communicator/online'
# proxy = ''
# print_xml = False
# Initial Transaction.
transaction = fields.authorization()
transaction.orderId = '1'
transaction.amount = 10010
transaction.orderSource = 'ecommerce'
transaction.id = 'ThisIsRequiredby11'
# Create contact object
contact = fields.contact()
contact.name = 'John & Mary Smith'
contact.addressLine1 = '1 Main St.'
contact.city = 'Burlington'
contact.state = 'MA'
contact.zip = '01803-3747'
contact.country = 'USA'
# The type of billToAddress is contact
transaction.billToAddress = contact
# Create cardType object
card = fields.cardType()
card.number = '4100000000000000'
card.expDate = '1215'
card.cardValidationNum = '349'
card.type = 'VI'
# The type of card is cardType
transaction.card = card
# detail tax
detailTaxList = list()
detailTax = fields.detailTax()
detailTax.taxAmount = 100
detailTaxList.append(detailTax)
detailTax2 = fields.detailTax()
detailTax2.taxAmount = 200
detailTaxList.append(detailTax2)
enhancedData = fields.enhancedData()
enhancedData.detailTax = detailTaxList
# Send request to server and get response as dict
response = online.request(transaction, conf)
print('Message: %s' % response['authorizationResponse']['message'])
print('CNPTransaction ID: %s' % response['authorizationResponse']['cnpTxnId'])
# Configuration need following attributes for batch request:
# attributes = default value
# sftp_username = ''
# sftp_password = ''
# sftp_url = ''
# batch_requests_path = '/tmp/vantiv_sdk_batch_request'
# batch_response_path = '/tmp/vantiv_sdk_batch_response'
# fast_url = ''
# fast_ssl = True
# fast_port = ''
# id = ''
# Initial batch transactions container class
transactions = batch.Transactions()
# Add transaction to batch transactions container
transactions.add(transaction)
# Sent batch to server via socket and get response as dict
response = batch.stream(transactions, conf)
print('Message: %s' % response['batchResponse']['authorizationResponse']['message'])
print('CNPTransaction ID: %s' % response['batchResponse']['authorizationResponse']['cnpTxnId'])
''',
)