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

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

Open
smithaldon1 opened this issue Nov 2, 2022 · 0 comments

Comments

@smithaldon1
Copy link

Related to Issue #85. Any help is appreciated!

The code I am using:

def create_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 = opaqueData
    
    order = 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 = amount
    transactRequest.order = order
    transactRequest.payment = paymentOne
    transactRequest.customer = customerData
    transactRequest.transactionSettings = settings
    
    createTransReq = apicontractsv1.createTransactionRequest()
    createTransReq.merchantAuthentication = merchantAuth
    createTransReq.refId = refId
    createTransReq.transactionRequest = transactRequest
    
    createTransCont = createTransactionController(createTransReq)
    createTransCont.execute()
    
    response = createTransCont.getresponse()
    
    if response is not None:
        if response.messages.resultCode == "Ok":
            if hasattr(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.')
                if hasattr(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 successful
        else:
            print ('Failed Transaction.')
            if hasattr(response, 'transactionResponse') == True and hasattr(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.')

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

No branches or pull requests

1 participant