Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Copy link
Copy link
@smithaldon1

Description

@smithaldon1
Issue body actions

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
Reactions are currently unavailable

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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.