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

Adding a Tip to a transaction #51

Open
sampocs opened this issue Mar 7, 2019 · 1 comment
Open

Adding a Tip to a transaction #51

sampocs opened this issue Mar 7, 2019 · 1 comment

Comments

@sampocs
Copy link

sampocs commented Mar 7, 2019

In the documentation, it shows that there is a Tip field of type Decimal that can be included in a transaction (https://developer.authorize.net/api/reference/index.html#payment-transactions-charge-a-credit-card).

I have been unable to include this field in my code when using the python SDK. It runs successfully if I get rid of the following lines:

tip = apicontractsv1.extendedAmountType()
tip.amount = Decimal('2.00')
...
transactionrequest.tip = tip 

However, when I try to include a tip, I receive the error message is: "The Tip amount is invalid." How should I format this field?

I've included all my code for reference but the 3 lines above should really be the only lines of any importance.

Thanks!

Code:

merchantAuth = apicontractsv1.merchantAuthenticationType()
merchantAuth.name = API_LOGIN_ID
merchantAuth.transactionKey = TRANSACTION_KEY

profileToCharge = apicontractsv1.customerProfilePaymentType()
profileToCharge.customerProfileId = 'XXX'
profileToCharge.paymentProfile = apicontractsv1.paymentProfile()
profileToCharge.paymentProfile.paymentProfileId = 'XXX'

customer = apicontractsv1.customerDataType()
customer.id = 'XXX'

line_items = apicontractsv1.ArrayOfLineItem()

line_item = apicontractsv1.lineItemType()
line_item.itemId = 'XXX'
line_item.name = 'XXX'
line_item.quantity = 'XXX'
line_item.unitPrice = 'XXX'
line_items.lineItem.append(line_item)

order_type = apicontractsv1.orderType()
order_type.description = 'XXX'

tip = apicontractsv1.extendedAmountType()
tip.amount = Decimal('2.00')

tax = apicontractsv1.extendedAmountType()
tax.amount = 'XXX'

transactionrequest = apicontractsv1.transactionRequestType()
transactionrequest.transactionType = 'authOnlyTransaction'
transactionrequest.amount = 'XXX'
transactionrequest.profile = profileToCharge
transactionrequest.customer = customer
transactionrequest.lineItems = line_items
transactionrequest.order = order_type
transactionrequest.tip = tip
transactionrequest.tax = tax

createtransactionrequest = apicontractsv1.createTransactionRequest()
createtransactionrequest.merchantAuthentication = merchantAuth
createtransactionrequest.transactionRequest = transactionrequest
createtransactionrequest.refId = 'XXX'

createtransactioncontroller = createTransactionController(createtransactionrequest)
createtransactioncontroller.execute()

auth_response = createtransactioncontroller.getresponse()
@PRERNA1829
Copy link

Added these code imported the library :_ from decimal import Decimal
Below code give the output after adding tip to the code

from decimal import Decimal
tip = apicontractsv1.extendedAmountType()
tip.amount = Decimal('2.00')
transactionrequest.tip = tip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants