EXAMPLES¶
Using dict¶
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 | #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('LitleTransaction ID: %s' % response['authorizationResponse']['litleTxnId'])
# 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('LitleTransaction ID: %s' % response['batchResponse']['authorizationResponse']['litleTxnId'])
|
Using object¶
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 | #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('LitleTransaction ID: %s' % response['authorizationResponse']['litleTxnId'])
# 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('LitleTransaction ID: %s' % response['batchResponse']['authorizationResponse']['litleTxnId'])
|