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

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

Open smithaldon1 opened this issue 3 years ago • 1 comments

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

smithaldon1 avatar Nov 02 '22 00:11 smithaldon1

TCS-Dev Dhanashree- Please be informed that our API currently does not support creating a customer profile and Payment Profile using opaque data.

dhanashreeyadav1 avatar Sep 30 '24 10:09 dhanashreeyadav1