sdk-python icon indicating copy to clipboard operation
sdk-python copied to clipboard

createTransactionRequest with Tax

Open yousifa opened this issue 6 years ago • 8 comments

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"`

yousifa avatar Jan 08 '19 03:01 yousifa

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 avatar Jan 22 '19 07:01 gnongsie

@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."

sampocs avatar Mar 07 '19 09:03 sampocs

Hi, Can you try the following instead?

tip = apicontractsv1.extendedAmountType()
tip.amount = "2.00"
transactionrequest.tip = tip

gnongsie avatar Mar 07 '19 11:03 gnongsie

It gives me the same error

sampocs avatar Mar 07 '19 19:03 sampocs

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?

gnongsie avatar Mar 14 '19 06:03 gnongsie

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.

sampocs avatar Mar 14 '19 08:03 sampocs

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.

gnongsie avatar Mar 14 '19 18:03 gnongsie

Any updates on this?

ghost avatar May 22 '20 02:05 ghost

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

dhanashreeyadav1 avatar Sep 30 '24 11:09 dhanashreeyadav1