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
def get_list_of_subscription():
    merchantAuth = apicontractsv1.merchantAuthenticationType()
    merchantAuth.name = constants.apiLoginId
    merchantAuth.transactionKey = constants.transactionKey

    sorting = apicontractsv1.ARBGetSubscriptionListSorting()
    sorting.orderBy = apicontractsv1.ARBGetSubscriptionListOrderFieldEnum.id
    sorting.orderDescending = "false"

    paging = apicontractsv1.Paging()
    paging.limit = 100
    paging.offset = 1

    request = apicontractsv1.ARBGetSubscriptionListRequest()
    request.merchantAuthentication = merchantAuth
    request.refId = "Sample"
    request.searchType = apicontractsv1.ARBGetSubscriptionListSearchTypeEnum.subscriptionInactive
    request.sorting = sorting
    request.paging = paging

    controller = ARBGetSubscriptionListController(request)
    controller.execute()

    response = controller.getresponse()

    if (response.messages.resultCode == "Ok"):
        print "SUCCESS"
        print "Message Code : %s" % response.messages.message[0].code
        print "Message text : %s" % response.messages.message[0].text
        print "Total Number In Results : %s" % response.totalNumInResultSet
    else:
        print "ERROR"
        print "Message Code : %s" % response.messages.message[0].code
        print "Message text : %s" % response.messages.message[0].text

    return response
Example #3
0
def get_account_updater_job_details():
    merchantAuth = apicontractsv1.merchantAuthenticationType()
    merchantAuth.name = constants.apiLoginId
    merchantAuth.transactionKey = constants.transactionKey

    paging = apicontractsv1.Paging()
    # Paging limit can be up to 1000 for this request
    paging.limit = 1000
    paging.offset = 2
    request = apicontractsv1.getAUJobDetailsRequest()
    request.merchantAuthentication = merchantAuth
    request.paging = paging
    request.month = "2018-08"
    request.modifiedTypeFilter = "all"
    request.refId = "123456"
    controller = getAUJobDetailsController(request)
    controller.execute()
    response = controller.getresponse()

    if response is not None:
        if response.messages.resultCode == apicontractsv1.messageTypeEnum.Ok:

                if hasattr(response, 'auDetails'):
                    print('SUCCESS: Get Account Updater job details for Month :' + request.month)
                    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('\n')

                        for details in response.auDetails.auDelete:
                            print('Deleted Profile:')
                            # auDelete Start
							print('Customer Profile ID: %s' % details.customerProfileID)
                            print('Customer Payment Profile ID: %s' % details.customerPaymentProfileID)                            
                            print('First Name: %s' % details.firstName)
                            print('Last Name: %s' % details.lastName)
                            print('AU Reason Code: %s' % details.auReasonCode)
                            print('Reason Description: %s' % details.reasonDescription)
                            print('Update Time UTC: %s' % details.updateTimeUTC)
                            print(' ')
                            # fetching card details:
                            print('Card Details:')
                            print('Card Number: %s' % details.creditCard.cardNumber)
                            print('Card Type: %s' % details.creditCard.cardType)
                            print('Expiration Date: %s' % details.creditCard.expirationDate)                            
                            # auDelete End
                        print('\n')

                        for details in response.auDetails.auUpdate:

                                # auUpdate Start
                                print('Updated Profile:')
								print('Customer Profile ID: %s' % details.customerProfileID)
                                print('Customer Payment Profile ID: %s' % details.customerPaymentProfileID)                                
                                print('First Name: %s' % details.firstName)
                                print('Last Name: %s' % details.lastName)
                                print('AU Reason Code: %s' % details.auReasonCode)
                                print('Reason Description: %s' % details.reasonDescription)
                                print('Update Time UTC: %s' % details.updateTimeUTC)
                                # fetching Old card details:
                                print('Old Card details:')
                                print('old Card Number: %s' % details.oldCreditCard.cardNumber)
                                print('old Card Type: %s' % details.oldCreditCard.cardType)
                                print('old Expiration Date: %s' % details.oldCreditCard.expirationDate)
                                # fetching New  card details:
                                print('Old Card details:')
                                print('new Card Number: %s' % details.newCreditCard.cardNumber)
                                print('new Card Type: %s' % details.newCreditCard.cardType)
                                print('new Expiration Date: %s' % details.newCreditCard.expirationDate)                                

                else:
                        print('Failed to get Get Account Updater job details for Month :' + request.month)
                        print('Message Code: %s' % response.messages.message[0]['code'].text)
                        print('Message Text: %s' % response.messages.message[0]['text'].text)
def get_customer_payment_profile_list():
    """Retrieve a list of customer payment profiles matching the specific search parameters"""

    # Create a merchantAuthenticationType object with authentication details
    # retrieved from the constants file
    merchant_auth = apicontractsv1.merchantAuthenticationType()
    merchant_auth.name = constants.apiLoginId
    merchant_auth.transactionKey = constants.transactionKey

    # Set the transaction's refId
    ref_id = "ref{}".format(int(time.time()) * 1000)

    # Set the paging (this particular API call will only return up to 10 results at a time)
    paging = apicontractsv1.Paging()
    paging.limit = 10
    paging.offset = 1

    # Set the sorting
    sorting = apicontractsv1.CustomerPaymentProfileSorting()
    sorting.orderBy = apicontractsv1.CustomerPaymentProfileOrderFieldEnum.id
    sorting.orderDescending = "false"

    # Set search parameters
    search = apicontractsv1.CustomerPaymentProfileSearchTypeEnum.cardsExpiringInMonth
    month = "2020-12"

    # Creating the request with the required parameters
    request = apicontractsv1.getCustomerPaymentProfileListRequest()
    request.merchantAuthentication = merchant_auth
    request.refId = ref_id
    request.paging = paging
    request.sorting = sorting
    request.searchType = search
    request.month = month

    controller = getCustomerPaymentProfileListController(request)
    controller.execute()

    response = controller.getresponse()

    if response is not None:
        if response.messages.resultCode == apicontractsv1.messageTypeEnum.Ok:
            print("SUCCESS")
            print("Total Num in Result Set: %s" % response.totalNumInResultSet)
            for profile in response.paymentProfiles.paymentProfile:
                print("Profile ID: %s" % profile.customerProfileId)
                print("Payment Profile ID: %s" %
                      profile.customerPaymentProfileId)
                try:
                    print("Card: %s" % profile.payment.creditCard.cardNumber)
                except AttributeError:
                    print("Bank account: %s" %
                          profile.payment.bankAccount.accountNumber)
                print()

        else:
            print("ERROR")
            if response.messages is not None:
                print("Result code: %s" % response.messages.resultCode)
                print("Message code: %s" %
                      response.messages.message[0]['code'].text)
                print("Message text: %s" %
                      response.messages.message[0]['text'].text)
    return response
Example #5
0
def get_unsettled_transaction_list():
    """get unsettled transaction list"""
    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 = 20
    paging.offset = 1

    request = apicontractsv1.getUnsettledTransactionListRequest()
    request.merchantAuthentication = merchantAuth
    request.refId = "Sample"
    request.sorting = sorting
    request.paging = paging

    unsettledTransactionListController = getUnsettledTransactionListController(
        request)
    unsettledTransactionListController.execute()

    # Work on the response
    response = unsettledTransactionListController.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
Example #6
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 #7
0
def get_list_of_subscriptions():
    """get list of subscriptions"""
    merchantAuth = apicontractsv1.merchantAuthenticationType()
    merchantAuth.name = constants.apiLoginId
    merchantAuth.transactionKey = constants.transactionKey

    # set sorting parameters
    sorting = apicontractsv1.ARBGetSubscriptionListSorting()
    sorting.orderBy = apicontractsv1.ARBGetSubscriptionListOrderFieldEnum.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

    request = apicontractsv1.ARBGetSubscriptionListRequest()
    request.merchantAuthentication = merchantAuth
    request.refId = "Sample"
    request.searchType = apicontractsv1.ARBGetSubscriptionListSearchTypeEnum.subscriptionInactive
    request.sorting = sorting
    request.paging = paging

    controller = ARBGetSubscriptionListController(request)
    controller.execute()

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

    if response is not None:
        if response.messages.resultCode == apicontractsv1.messageTypeEnum.Ok:
            if hasattr(response, 'subscriptionDetails'):
                print('Successfully retrieved subscription 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 subscription in response.subscriptionDetails.subscriptionDetail:
                    print('Subscription Id: %s' % subscription.id)
                    print('Subscription Name: %s' % subscription.name)
                    print('Subscription Status: %s' % subscription.status)
                    print('Customer Profile Id: %s' %
                          subscription.customerProfileId)
                    print()
            else:
                if response.messages is not None:
                    print('Failed to get subscription 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 *

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

sorting = apicontractsv1.ARBGetSubscriptionListSorting()
sorting.orderBy = apicontractsv1.ARBGetSubscriptionListOrderFieldEnum.id
sorting.orderDescending = "false"

paging = apicontractsv1.Paging()
paging.limit = 1000
paging.offset = 1

request = apicontractsv1.ARBGetSubscriptionListRequest()
request.merchantAuthentication = merchantAuth
request.refId = "Sample"
request.searchType = apicontractsv1.ARBGetSubscriptionListSearchTypeEnum.subscriptionInactive
request.sorting = sorting
request.paging = paging

controller = ARBGetSubscriptionListController(request)
controller.execute()

response = controller.getresponse()

if (response.messages.resultCode == "Ok"):
    print "SUCCESS"
    print "Message Code : %s" % response.messages.message[0].code
    print "Message text : %s" % response.messages.message[0].text