Skip to content

AttributeError: no such child: {AnetApi/xml/v1/schema/AnetApiSchema.xsd}response #155

Description

@smithaldon1

Related to Issue #85. Any help is appreciated!

The code I am using:

defcreate_pay_transaction(amount, form_data):
merchantAuth=apicontractsv1.merchantAuthenticationType()
merchantAuth.name=config['authnet']['apiLoginId']
merchantAuth.transactionKey=config['authnet']['transactionKey']
refId="ref {}".format(format_server_time())
opaqueData=apicontractsv1.opaqueDataType()
opaqueData.dataDescriptor=form_data['dataDescriptor']
opaqueData.dataValue=form_data['dataValue']
paymentOne=apicontractsv1.paymentType()
paymentOne.opaqueData=opaqueDataorder=apicontractsv1.orderType()
order.description="GUFC Donation"customerData=apicontractsv1.customerDataType()
customerData.type="individual"customerData.firstName=form_data['fName']
customerData.lastName=form_data['lName']
customerData.email=form_data['email']
customerData.phone=form_data['phone']
duplicateWindowSetting=apicontractsv1.settingType()
duplicateWindowSetting.settingName="duplicateWindow"duplicateWindowSetting.settingValue="600"settings=apicontractsv1.ArrayOfSetting()
settings.setting.append(duplicateWindowSetting)
transactRequest=apicontractsv1.transactionRequestType()
transactRequest.transactionType="authCaptureTransaction"transactRequest.amount=amounttransactRequest.order=ordertransactRequest.payment=paymentOnetransactRequest.customer=customerDatatransactRequest.transactionSettings=settingscreateTransReq=apicontractsv1.createTransactionRequest()
createTransReq.merchantAuthentication=merchantAuthcreateTransReq.refId=refIdcreateTransReq.transactionRequest=transactRequestcreateTransCont=createTransactionController(createTransReq)
createTransCont.execute()
response=createTransCont.getresponse()
ifresponseisnotNone:
ifresponse.messages.resultCode=="Ok":
ifhasattr(response.transactionResponse, 'messages') ==True:
print ('Successfully created transaction with Transaction ID: %s'%response.transactionResponse.transId)
print ('Transaction Response Code: %s'%response.transactionResponse.responseCode)
print ('Message Code: %s'%response.transactionResponse.messages.message[0].code)
print ('Auth Code: %s'%response.transactionResponse.authCode)
print ('Description: %s'%response.transactionResponse.messages.message[0].description)
else:
print ('Failed Transaction.')
ifhasattr(response.transactionResponse, 'errors') ==True:
print ('Error Code: %s'%str(response.transactionResponse.errors.error[0].errorCode))
print ('Error Message: %s'%response.transactionResponse.errors.error[0].errorText)
# Or, print errors if the API request wasn't successfulelse:
print ('Failed Transaction.')
ifhasattr(response, 'transactionResponse') ==Trueandhasattr(response.transactionResponse, 'errors') ==True:
print ('Error Code: %s'%str(response.transactionResponse.errors.error[0].errorCode))
print ('Error Message: %s'%response.transactionResponse.errors.error[0].errorText)
else:
print ('Error Code: %s'%response.messages.message[0]['code'].text)
print ('Error Message: %s'%response.messages.message[0]['text'].text)
else:
print ('Null Response.')
returnresponse

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