sdk-python
sdk-python copied to clipboard
createTransactionRequest with Tax
I am trying to add tax via the SDK in the "charge-credit-card.py" file, but it seems that the sdk does not support this function. Is there a fix for this?
` # Create a transactionRequestType object and add the previous objects to it.
transactionrequest = apicontractsv1.transactionRequestType()
transactionrequest.transactionType = "authCaptureTransaction"
transactionrequest.amount = amount
transactionrequest.payment = payment
transactionrequest.order = order
transactionrequest.billTo = customerAddress
transactionrequest.customer = customerData
transactionrequest.transactionSettings = settings
transactionrequest.lineItems = line_items
transactionrequest.tax.amount = "1.99"
transactionrequest.tax.name = "test tax"
transactionrequest.tax.description = "this is a tax for level 2"`
Hi,
Can you try the following lines?
transactionrequest.tax = apicontractsv1.extendedAmountType()
transactionrequest.tax.amount = "1.99"
transactionrequest.tax.name = "test tax"
transactionrequest.tax.description = "this is a tax for level 2"
@gnongsie The above worked for me with the tax field but I am unable to include the Tip field.
tip = apicontractsv1.extendedAmountType()
tip.amount = Decimal('2.00')
transactionrequest.tip = tip
It is giving me the error "The Tip amount is Invalid."
Hi, Can you try the following instead?
tip = apicontractsv1.extendedAmountType()
tip.amount = "2.00"
transactionrequest.tip = tip
It gives me the same error
Hi, I apologize for the inconvenience.
But I have tested this and I am getting a proper response. I can even access the tip amount from the Get Transaction Details API.
Can you help me by providing me the code you are using? And the version of the SDK?
I'm using SDK version 1.1.2 on Python 2.7
Here's my full 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
order_type = apicontractsv1.orderType()
order_type.description = XXX
tip = apicontractsv1.extendedAmountType()
tip.amount = "2.00"
tax = apicontractsv1.extendedAmountType()
tax.amount = "1.00"
transactionrequest = apicontractsv1.transactionRequestType()
transactionrequest.transactionType = 'authOnlyTransaction'
transactionrequest.amount = "14.01"
transactionrequest.profile = profileToCharge
transactionrequest.customer = customer
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()
Once again, the error I'm receiving is "The Tip amount is invalid."
If I comment out the line: transactionrequest.tip = tip Then the code executes without a problem.
Hi, I see your issue now. Unfortunately, this needs further investigation and I will need to get back to you on this. Please be patient and I'll get the answer for you.
Any updates on this?
TCS-Dev Dhanashree- If you try adding below lines in the "charge-credit-card.py" file to add tax, you will get the required output.
tax = apicontractsv1.extendedAmountType() tax.amount = "1.99" transactionrequest.tax = tax OR from decimal import Decimal tax = apicontractsv1.extendedAmountType() tax.amount = Decimal('1.99') transactionrequest.tax = tax