def get_transaction_list():
	merchantAuth = apicontractsv1.merchantAuthenticationType()
	merchantAuth.name = constants.apiLoginId
	merchantAuth.transactionKey = constants.transactionKey

	transactionListRequest = apicontractsv1.getTransactionListRequest()
	transactionListRequest.merchantAuthentication = merchantAuth
	transactionListRequest.batchId = "4551107"

	transactionListController = getTransactionListController(transactionListRequest)

	transactionListController.execute()

	transactionListResponse = transactionListController.getresponse()

	if transactionListResponse is not None:
		if transactionListResponse.messages.resultCode == apicontractsv1.messageTypeEnum.Ok:
			print('Successfully got transaction list!')

			for transaction in transactionListResponse.transactions.transaction:
				print('Transaction Id : %s' % transaction.transId)
				print('Transaction Status : %s' % transaction.transactionStatus)
				print('Amount Type : %s' % transaction.accountType)
				print('Settle Amount : %s' % transaction.settleAmount)

			if transactionListResponse.messages:
				print('Message Code : %s' % transactionListResponse.messages.message[0].code)
				print('Message Text : %s' % transactionListResponse.messages.message[0].text)
		else:
			if transactionListResponse.messages:
				print('Failed to get transaction list.\nCode:%s \nText:%s' % (transactionListResponse.messages.message[0].code,transactionListResponse.messages.message[0].text))

	return transactionListResponse
def get_transaction_list():
	merchantAuth = apicontractsv1.merchantAuthenticationType()
	merchantAuth.name = constants.apiLoginId
	merchantAuth.transactionKey = constants.transactionKey

	transactionListRequest = apicontractsv1.getTransactionListRequest()
	transactionListRequest.merchantAuthentication = merchantAuth
	transactionListRequest.batchId = "4551107"

	transactionListController = getTransactionListController(transactionListRequest)

	transactionListController.execute()

	transactionListResponse = transactionListController.getresponse()

	if transactionListResponse is not None:
		if transactionListResponse.messages.resultCode == apicontractsv1.messageTypeEnum.Ok:
			print('Successfully got transaction list!')

			for transaction in transactionListResponse.transactions.transaction:
				print('Transaction Id : %s' % transaction.transId)
				print('Transaction Status : %s' % transaction.transactionStatus)
				print('Amount Type : %s' % transaction.accountType)
				print('Settle Amount : %s' % transaction.settleAmount)

			if transactionListResponse.messages:
				print('Message Code : %s' % transactionListResponse.messages.message[0]['code'].text)
				print('Message Text : %s' % transactionListResponse.messages.message[0]['text'].text)
		else:
			if transactionListResponse.messages:
				print('Failed to get transaction list.\nCode:%s \nText:%s' % (transactionListResponse.messages.message[0]['code'].text,transactionListResponse.messages.message[0]['text'].text))

	return transactionListResponse
Example #3
0
    def get_transaction_batch_list(self, batch_id):
        """
        Gets the list of settled transaction in a batch. There are sorting and paging option
        that are not currently implemented. It will get the last 1k transactions.
        """
        self.transaction = apicontractsv1.getTransactionListRequest()
        self.transaction.merchantAuthentication = self.merchant_auth
        self.transaction.batchId = batch_id

        self.controller = getTransactionListController(self.transaction)
        self.controller.execute()

        response = self.controller.getresponse()

        if response.messages.resultCode == apicontractsv1.messageTypeEnum.Ok and hasattr(response, 'transactions'):
            return [transaction for transaction in response.transactions.transaction]
def query_successful_authnet_transaction(request):
	merchantAuth = request.merchant_auth or None
	order_ref = request.reference_doc.name
	amount = request.amount

	if merchantAuth is None:
		merchantAuth = apicontractsv1.merchantAuthenticationType()
		merchantAuth.name = frappe.db.get_single_value("Authorizenet Settings", "api_login_id")
		merchantAuth.transactionKey = get_decrypted_password('Authorizenet Settings', 'Authorizenet Settings',
			fieldname='api_transaction_key', raise_exception=False)

	# set sorting parameters
	sorting = apicontractsv1.TransactionListSorting()
	sorting.orderBy = apicontractsv1.TransactionListOrderFieldEnum.id
	sorting.orderDescending = True

	# set paging and offset parameters
	paging = apicontractsv1.Paging()
	# Paging limit can be up to 1000 for this request
	paging.limit = 20
	paging.offset = 1

	transactionListRequest = apicontractsv1.getTransactionListRequest()
	transactionListRequest.merchantAuthentication = merchantAuth
	transactionListRequest.refId = order_ref
	transactionListRequest.sorting = sorting
	transactionListRequest.paging = paging

	unsettledTransactionListController = getUnsettledTransactionListController(transactionListRequest)
	if not frappe.db.get_single_value("Authorizenet Settings", "sandbox_mode"):
		unsettledTransactionListController.setenvironment(constants.PRODUCTION)

	unsettledTransactionListController.execute()

	# Work on the response
	response = unsettledTransactionListController.getresponse()

	if response is not None and \
		response.messages.resultCode == apicontractsv1.messageTypeEnum.Ok and \
		hasattr(response, 'transactions'):
				for transaction in response.transactions.transaction:
					if (transaction.transactionStatus == "capturedPendingSettlement" or \
						transaction.transactionStatus == "authorizedPendingCapture") and \
						transaction.invoiceNumber == order_ref and transaction.amount == amount:
						return transaction
	return False
Example #5
0
def get_transaction_list(ds, **kwargs):
    batch_ids = kwargs['ti'].xcom_pull(task_ids='get_batch_ids')

    transaction_ids = []
    transaction_unsettled_ids = []
    for b in batch_ids:
        transactionListRequest = apicontractsv1.getTransactionListRequest()
        transactionListRequest.merchantAuthentication = merchantAuth
        transactionListRequest.batchId = str(b)
        paging = apicontractsv1.Paging()
        paging.limit = '1000'
        paging.offset = '1'
        transactionListRequest.paging = paging

        transactionListController = getTransactionListController(transactionListRequest)
        transactionListController.setenvironment(ENV)

        transactionListController.execute()

        transactionListResponse = transactionListController.getresponse()

        if transactionListResponse is not None:
            if transactionListResponse.messages.resultCode == apicontractsv1.messageTypeEnum.Ok:
                if hasattr(transactionListResponse, 'transactions'):
                    print('Successfully got transaction list!')
                    try:

                        for transaction in transactionListResponse.transactions.transaction:
                            transaction_ids.append(transaction.transId)

                    except:
                        print('No records in batch id')

                if transactionListResponse.messages is not None:
                    print('Message Code : %s' % transactionListResponse.messages.message[0].code)
                    print('Message Text : %s' % transactionListResponse.messages.message[0].text)
            else:
                if transactionListResponse.messages is not None:
                    print('Failed to get transaction list.\nCode:%s \nText:%s' % (
                        transactionListResponse.messages.message[0].code,
                        transactionListResponse.messages.message[0].text))

    unsettledTransactionListRequest = apicontractsv1.getUnsettledTransactionListRequest()
    unsettledTransactionListRequest.merchantAuthentication = merchantAuth
    paging = apicontractsv1.Paging()
    paging.limit = '1000'
    paging.offset = '1'
    unsettledTransactionListRequest.paging = paging

    unsettledTransactionListController = getUnsettledTransactionListController(unsettledTransactionListRequest)
    unsettledTransactionListController.setenvironment(ENV)

    unsettledTransactionListController.execute()

    unsettledTransactionListResponse = unsettledTransactionListController.getresponse()

    if unsettledTransactionListResponse is not None:
        if unsettledTransactionListResponse.messages.resultCode == apicontractsv1.messageTypeEnum.Ok:
            if hasattr(unsettledTransactionListResponse, 'transactions'):
                print('Successfully gotten unsettled transaction list!')
                try:

                    for transaction in unsettledTransactionListResponse.transactions.transaction:
                        transaction_unsettled_ids.append(transaction.transId)

                except:
                    print('No unsettled transaction ids')

            if unsettledTransactionListResponse.messages is not None:
                print('Message Code : %s' % unsettledTransactionListResponse.messages.message[0].code)
                print('Message Text : %s' % unsettledTransactionListResponse.messages.message[0].text)
        else:
            if unsettledTransactionListResponse.messages is not None:
                print('Failed to get unsettled transaction list.\nCode:%s \nText:%s' % (
                    unsettledTransactionListResponse.messages.message[0].code,
                    unsettledTransactionListResponse.messages.message[0].text))

    return {'transaction_ids': transaction_ids, 'transaction_unsettled_ids': transaction_unsettled_ids}
Example #6
0
def get_transaction_list():
    """get transaction list for a specific batch"""
    merchantAuth = apicontractsv1.merchantAuthenticationType()
    merchantAuth.name = CONSTANTS.apiLoginId
    merchantAuth.transactionKey = CONSTANTS.transactionKey

    # set sorting parameters
    sorting = apicontractsv1.TransactionListSorting()
    sorting.orderBy = apicontractsv1.TransactionListOrderFieldEnum.id
    sorting.orderDescending = True

    # set paging and offset parameters
    paging = apicontractsv1.Paging()
    # Paging limit can be up to 1000 for this request
    paging.limit = 1000
    paging.offset = 1

    transactionListRequest = apicontractsv1.getTransactionListRequest()
    transactionListRequest.merchantAuthentication = merchantAuth
    transactionListRequest.refId = "Sample"
    transactionListRequest.batchId = "10728865"  #Batch from 07/22/2020
    transactionListRequest.sorting = sorting
    transactionListRequest.paging = paging

    transactionListController = getTransactionListController(
        transactionListRequest)
    transactionListController.execute()

    # Work on the response
    response = transactionListController.getresponse()

    if response is not None:
        if response.messages.resultCode == apicontractsv1.messageTypeEnum.Ok:
            if hasattr(response, 'transactions'):
                print('Successfully retrieved transaction list.')
                if response.messages is not None:
                    print('Message Code: %s' %
                          response.messages.message[0]['code'].text)
                    print('Message Text: %s' %
                          response.messages.message[0]['text'].text)
                    print('Total Number In Results: %s' %
                          response.totalNumInResultSet)
                    print()
                for transaction in response.transactions.transaction:
                    print('Transaction Id: %s' % transaction.transId)
                    print('Transaction Status: %s' %
                          transaction.transactionStatus)
                    if hasattr(transaction, 'accountType'):
                        print('Account Type: %s' % transaction.accountType)
                    print('Settle Amount: %.2f' % transaction.settleAmount)
                    if hasattr(transaction, 'profile'):
                        print('Customer Profile ID: %s' %
                              transaction.profile.customerProfileId)
                    print()
            else:
                if response.messages is not None:
                    print('Failed to get transaction list.')
                    print('Code: %s' %
                          (response.messages.message[0]['code'].text))
                    print('Text: %s' %
                          (response.messages.message[0]['text'].text))
        else:
            if response.messages is not None:
                print('Failed to get transaction list.')
                print('Code: %s' % (response.messages.message[0]['code'].text))
                print('Text: %s' % (response.messages.message[0]['text'].text))
    else:
        print('Error. No response received.')

    return response
from authorizenet import apicontractsv1
from authorizenet.apicontrollers import *
from decimal import *

merchantAuth = apicontractsv1.merchantAuthenticationType()
merchantAuth.name = '5KP3u95bQpv'
merchantAuth.transactionKey = '4Ktq966gC55GAX7S'

transactionListRequest = apicontractsv1.getTransactionListRequest()
transactionListRequest.merchantAuthentication = merchantAuth
transactionListRequest.batchId = "4551107"

transactionListController = getTransactionListController(transactionListRequest)

transactionListController.execute()

transactionListResponse = transactionListController.getresponse()

if transactionListResponse is not None:
	if transactionListResponse.messages.resultCode == apicontractsv1.messageTypeEnum.Ok:
		print('Successfully got transaction list!')

		for transaction in transactionListResponse.transactions.transaction:
			print('Transaction Id : %s' % transaction.transId)
			print('Transaction Status : %s' % transaction.transactionStatus)
			print('Amount Type : %s' % transaction.accountType)
			print('Settle Amount : %s' % transaction.settleAmount)

		if transactionListResponse.messages:
			print('Message Code : %s' % transactionListResponse.messages.message[0].code)
			print('Message Text : %s' % transactionListResponse.messages.message[0].text)
from authorizenet import apicontractsv1
from authorizenet.apicontrollers import *
from decimal import *

merchantAuth = apicontractsv1.merchantAuthenticationType()
merchantAuth.name = '5KP3u95bQpv'
merchantAuth.transactionKey = '4Ktq966gC55GAX7S'

transactionListRequest = apicontractsv1.getTransactionListRequest()
transactionListRequest.merchantAuthentication = merchantAuth
transactionListRequest.batchId = "4551107"

transactionListController = getTransactionListController(
    transactionListRequest)

transactionListController.execute()

transactionListResponse = transactionListController.getresponse()

if transactionListResponse is not None:
    if transactionListResponse.messages.resultCode == apicontractsv1.messageTypeEnum.Ok:
        print('Successfully got transaction list!')

        for transaction in transactionListResponse.transactions.transaction:
            print('Transaction Id : %s' % transaction.transId)
            print('Transaction Status : %s' % transaction.transactionStatus)
            print('Amount Type : %s' % transaction.accountType)
            print('Settle Amount : %s' % transaction.settleAmount)

        if transactionListResponse.messages:
            print('Message Code : %s' %