Skip to content

Adding a Tip to a transaction #51

Open
@sampocs

Description

@sampocs

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()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions