Skip to content
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

Updated Sample code for validating the new fields added #47

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
17 changes: 11 additions & 6 deletions PaymentTransactions/authorize-credit-card.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@

from authorizenet import apicontractsv1
from authorizenet.apicontrollers import createTransactionController

CONSTANTS = imp.load_source('modulename', 'constants.py')

from authorizenet.constants import constants

def authorize_credit_card(amount):
"""
Expand All @@ -20,8 +18,8 @@ def authorize_credit_card(amount):
# Create a merchantAuthenticationType object with authentication details
# retrieved from the constants file
merchantAuth = apicontractsv1.merchantAuthenticationType()
merchantAuth.name = CONSTANTS.apiLoginId
merchantAuth.transactionKey = CONSTANTS.transactionKey
merchantAuth.name = constants.apiLoginId
merchantAuth.transactionKey = constants.transactionKey

# Create the payment data for a credit card
creditCard = apicontractsv1.creditCardType()
Expand All @@ -37,6 +35,7 @@ def authorize_credit_card(amount):
order = apicontractsv1.orderType()
order.invoiceNumber = "10101"
order.description = "Golf Shirts"
order.discountAmount = "10"

# Set the customer's Bill To address
customerAddress = apicontractsv1.customerAddressType()
Expand Down Expand Up @@ -75,12 +74,17 @@ def authorize_credit_card(amount):
line_item_2.description = "Here's the second line item"
line_item_2.quantity = "3"
line_item_2.unitPrice = "7.95"
line_item_2.unitOfMeasure = "2"

# build the array of line items
line_items = apicontractsv1.ArrayOfLineItem()
line_items.lineItem.append(line_item_1)
line_items.lineItem.append(line_item_2)

otherTax = apicontractsv1.otherTaxType()
otherTax.localTaxAmount="5"


# Create a transactionRequestType object and add the previous objects to it.
transactionrequest = apicontractsv1.transactionRequestType()
transactionrequest.transactionType = "authOnlyTransaction"
Expand All @@ -89,6 +93,7 @@ def authorize_credit_card(amount):
transactionrequest.order = order
transactionrequest.billTo = customerAddress
transactionrequest.customer = customerData
transactionrequest.otherTax = otherTax
transactionrequest.transactionSettings = settings
transactionrequest.lineItems = line_items

Expand Down Expand Up @@ -148,4 +153,4 @@ def authorize_credit_card(amount):


if (os.path.basename(__file__) == os.path.basename(sys.argv[0])):
authorize_credit_card(CONSTANTS.amount)
authorize_credit_card(constants.amount)