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


	transactionrequest = apicontractsv1.transactionRequestType()
	transactionrequest.transactionType = "priorAuthCaptureTransaction"
	transactionrequest.amount = Decimal ('2.55')
	transactionrequest.refTransId = "2245440574"



	createtransactionrequest = apicontractsv1.createTransactionRequest()
	createtransactionrequest.merchantAuthentication = merchantAuth
	createtransactionrequest.refId = "MerchantID-0001"

	createtransactionrequest.transactionRequest = transactionrequest
	createtransactioncontroller = createTransactionController(createtransactionrequest)
	createtransactioncontroller.execute()

	response = createtransactioncontroller.getresponse()

	if (response.messages.resultCode=="Ok"):
	    print "Transaction ID : %s" % response.transactionResponse.transId
	    print response.transactionResponse.messages.message[0].description
	else:
	    print "response code: %s" % response.messages.resultCode

	return response
def create_chase_pay_transaction():
    merchantAuth = apicontractsv1.merchantAuthenticationType()
    merchantAuth.name = constants.apiLoginId
    merchantAuth.transactionKey = constants.transactionKey

    creditCard = apicontractsv1.creditCardType()
    creditCard.cardNumber = "4111111111111111"
    creditCard.expirationDate = "2020-12"
    creditCard.cardCode="999"
    # Set the token specific info
    creditCard.isPaymentToken = True
    creditCard.cryptogram = "EjRWeJASNFZ4kBI0VniQEjRWeJA="
    creditCard.tokenRequestorName="CHASE_PAY"
    creditCard.tokenRequestorId="12345678901"
    creditCard.tokenRequestorEci="07"

    payment = apicontractsv1.paymentType()
    payment.creditCard = creditCard

    transactionrequest = apicontractsv1.transactionRequestType()
    transactionrequest.transactionType = "authCaptureTransaction"
    transactionrequest.amount = Decimal ('1.50')
    transactionrequest.payment = payment

    createtransactionrequest = apicontractsv1.createTransactionRequest()
    createtransactionrequest.merchantAuthentication = merchantAuth
    createtransactionrequest.refId = "MerchantID-0001"
    createtransactionrequest.transactionRequest = transactionrequest

    createtransactioncontroller = createTransactionController(createtransactionrequest)
    createtransactioncontroller.execute()

    response = createtransactioncontroller.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 ('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)
        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 ('Failed to get response.')
        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)
    return response    
def charge_customer_profile(customerProfileId, paymentProfileId, amount):
	merchantAuth = apicontractsv1.merchantAuthenticationType()
	merchantAuth.name = constants.apiLoginId
	merchantAuth.transactionKey = constants.transactionKey

	# create a customer payment profile
	profileToCharge = apicontractsv1.customerProfilePaymentType()
	profileToCharge.customerProfileId = customerProfileId
	profileToCharge.paymentProfile = apicontractsv1.paymentProfile()
	profileToCharge.paymentProfile.paymentProfileId = paymentProfileId

	transactionrequest = apicontractsv1.transactionRequestType()
	transactionrequest.transactionType = "authCaptureTransaction"
	transactionrequest.amount = amount
	transactionrequest.profile = profileToCharge


	createtransactionrequest = apicontractsv1.createTransactionRequest()
	createtransactionrequest.merchantAuthentication = merchantAuth
	createtransactionrequest.refId = "MerchantID-0001"

	createtransactionrequest.transactionRequest = transactionrequest
	createtransactioncontroller = createTransactionController(createtransactionrequest)
	createtransactioncontroller.execute()

	response = createtransactioncontroller.getresponse()

	if (response.messages.resultCode=="Ok"):
		print "Transaction ID : %s" % response.transactionResponse.transId
	else:
		print "response code: %s" % response.messages.resultCode

	return response
Пример #4
0
def charge(card_number, expiration_date, amount, merchant_id):
    creditCard = apicontractsv1.creditCardType()
    creditCard.cardNumber = card_number
    creditCard.expirationDate = expiration_date

    payment = apicontractsv1.paymentType()
    payment.creditCard = creditCard

    transactionrequest = apicontractsv1.transactionRequestType()
    transactionrequest.transactionType = "authCaptureTransaction"
    transactionrequest.amount = amount
    transactionrequest.payment = payment

    createtransactionrequest = apicontractsv1.createTransactionRequest()
    createtransactionrequest.merchantAuthentication = merchantAuth
    createtransactionrequest.refId = merchant_id

    createtransactionrequest.transactionRequest = transactionrequest
    createtransactioncontroller = createTransactionController(
        createtransactionrequest)
    createtransactioncontroller.execute()

    response = createtransactioncontroller.getresponse()

    if (response.messages.resultCode == "Ok"):
        print "Transaction ID : %s" % response.transactionResponse.transId
    else:
        print "response code: %s" % response.messages.resultCode
Пример #5
0
def authorize_credit_card():
    merchantAuth = apicontractsv1.merchantAuthenticationType()
    merchantAuth.name = CONSTANTS.apiLoginId
    merchantAuth.transactionKey = CONSTANTS.transactionKey

    creditCard = apicontractsv1.creditCardType()
    creditCard.cardNumber = cardNumber
    creditCard.expirationDate = expirationDate

    payment = apicontractsv1.paymentType()
    payment.creditCard = creditCard

    transactionrequest = apicontractsv1.transactionRequestType()
    transactionrequest.transactionType = "authCaptureTransaction"
    transactionrequest.amount = Decimal(amount)
    transactionrequest.payment = payment

    createtransactionrequest = apicontractsv1.createTransactionRequest()
    createtransactionrequest.merchantAuthentication = merchantAuth
    createtransactionrequest.refId = "MerchantID-0001"

    createtransactionrequest.transactionRequest = transactionrequest
    createtransactioncontroller = createTransactionController(
        createtransactionrequest)
    createtransactioncontroller.execute()

    response = createtransactioncontroller.getresponse()

    if (response.messages.resultCode == "Ok"):
        print("Transaction ID : %s" % response.transactionResponse.transId)
    else:
        print("response code: %s" % response.messages.resultCode)
Пример #6
0
    def creds(self, cardNumber, exp_date, amount_to_take):
        creditCard = apicontractsv1.creditCardType()
        creditCard.cardNumber = cardNumber
        creditCard.expirationDate = exp_date

        payment = apicontractsv1.paymentType()
        payment.creditCard = creditCard

        transactionrequest = apicontractsv1.transactionRequestType()
        transactionrequest.transactionType = "authCaptureTransaction"
        transactionrequest.amount = Decimal(amount_to_take)
        transactionrequest.payment = payment

        createtransactionrequest = apicontractsv1.createTransactionRequest()
        createtransactionrequest.merchantAuthentication = self.merchantAuth
        createtransactionrequest.refId = "MerchantID-0001"

        createtransactionrequest.transactionRequest = transactionrequest
        createtransactioncontroller = createTransactionController(
            createtransactionrequest)
        createtransactioncontroller.execute()

        response = createtransactioncontroller.getresponse()

        if (response.messages.resultCode == "Ok"):
            print("Transaction ID : %s" % response.transactionResponse.transId)
        else:
            print("response code: %s" % response.messages.resultCode)
Пример #7
0
    def charge_customer_profile(self, paymentProfileId, amount, ref_id,
                                invoice_number):

        # create a customer payment profile
        profileToCharge = apicontractsv1.customerProfilePaymentType()
        profileToCharge.customerProfileId = str(
            self.instance.authorizenet_customer_profile_id)
        profileToCharge.paymentProfile = apicontractsv1.paymentProfile()
        profileToCharge.paymentProfile.paymentProfileId = paymentProfileId

        order = apicontractsv1.orderType()
        order.invoiceNumber = str(invoice_number)

        transactionrequest = apicontractsv1.transactionRequestType()
        transactionrequest.transactionType = "authCaptureTransaction"
        transactionrequest.amount = amount
        transactionrequest.profile = profileToCharge
        transactionrequest.order = order

        createtransactionrequest = apicontractsv1.createTransactionRequest()
        createtransactionrequest.merchantAuthentication = self.merchantAuth
        createtransactionrequest.refId = str(ref_id)

        createtransactionrequest.transactionRequest = transactionrequest
        controller = createTransactionController(createtransactionrequest)
        controller.setenvironment(self.post_url)
        controller.execute()

        response = controller.getresponse()

        return Transaction(response)
def void_transaction(refTransId):
	merchantAuth = apicontractsv1.merchantAuthenticationType()
	merchantAuth.name = constants.apiLoginId
	merchantAuth.transactionKey = constants.transactionKey


	transactionrequest = apicontractsv1.transactionRequestType()
	transactionrequest.transactionType = "voidTransaction"
	#set refTransId to transId of an unsettled transaction
	transactionrequest.refTransId = refTransId

	createtransactionrequest = apicontractsv1.createTransactionRequest()
	createtransactionrequest.merchantAuthentication = merchantAuth
	createtransactionrequest.refId = "MerchantID-0001"

	createtransactionrequest.transactionRequest = transactionrequest
	createtransactioncontroller = createTransactionController(createtransactionrequest)
	createtransactioncontroller.execute()

	response = createtransactioncontroller.getresponse()

	if (response.messages.resultCode=="Ok"):
	    print "Transaction ID : %s" % response.transactionResponse.transId
	    print response.transactionResponse.messages.message[0].description
	else:
	    print "response code: %s" % response.messages.resultCode
	    print response.transactionResponse.errors.error[0].errorText

	return response
def charge(card_number, expiration_date, amount, merchant_id):
    merchantAuth = apicontractsv1.merchantAuthenticationType()
    merchantAuth.name = '4K24xbCW'
    merchantAuth.transactionKey = '8m39rKgQ92C4MRvx'

    creditCard = apicontractsv1.creditCardType()
    creditCard.cardNumber = card_number
    creditCard.expirationDate = expiration_date

    payment = apicontractsv1.paymentType()
    payment.creditCard = creditCard

    transactionrequest = apicontractsv1.transactionRequestType()
    transactionrequest.transactionType = "authCaptureTransaction"
    transactionrequest.amount = Decimal(amount)
    transactionrequest.payment = payment

    createtransactionrequest = apicontractsv1.createTransactionRequest()
    createtransactionrequest.merchantAuthentication = merchantAuth
    createtransactionrequest.refId = merchant_id

    createtransactionrequest.transactionRequest = transactionrequest
    createtransactioncontroller = createTransactionController(
        createtransactionrequest)
    createtransactioncontroller.execute()

    response = createtransactioncontroller.getresponse()

    if (response.messages.resultCode == "Ok"):
        return (True,
                "Transaction ID : %s" % response.transactionResponse.transId)
    else:
        return (False, "response code: %s" % response.messages.resultCode)
Пример #10
0
    def test_capture_transaction(self):
        credit_card = CreditCard()
        order = OrderFactory()

        card = apicontractsv1.creditCardType()
        card.cardNumber = credit_card['card_number']
        card.expirationDate = credit_card['expire_date'].strftime('%Y-%m')

        payment = apicontractsv1.paymentType()
        payment.creditCard = card

        transaction = apicontractsv1.transactionRequestType()
        transaction.transactionType = "authCaptureTransaction"
        transaction.amount = order['amount']
        transaction.payment = payment

        request = apicontractsv1.createTransactionRequest()
        request.merchantAuthentication = self.merchant
        request.refId = order['ref_id']
        request.transactionRequest = transaction

        controller = apicontrollers.CreateTransactionController(request)

        response = controller.execute()

        print(response)
Пример #11
0
def payment(name, key, card_number, expiration_date, amount, merchant_id):
    merchantAuth = apicontractsv1.merchantAuthenticationType()
    merchantAuth.name = name
    merchantAuth.transactionKey = key

    creditCard = apicontractsv1.creditCardType()
    creditCard.cardNumber = card_number
    creditCard.expirationDate = expiration_date

    payment = apicontractsv1.paymentType()
    payment.creditCard = creditCard

    transactionrequest = apicontractsv1.transactionRequestType()
    transactionrequest.transactionType = "authCaptureTransaction"
    transactionrequest.amount = Decimal(amount)
    transactionrequest.payment = payment

    createtransactionrequest = apicontractsv1.createTransactionRequest()
    createtransactionrequest.merchantAuthentication = merchantAuth
    createtransactionrequest.refId = merchant_id

    createtransactionrequest.transactionRequest = transactionrequest
    createtransactioncontroller = createTransactionController(
        createtransactionrequest)
    createtransactioncontroller.execute()

    response = createtransactioncontroller.getresponse()

    if (response.messages.resultCode == "Ok"):
        return response.transactionResponse.transId
        print("Transaction ID : %s" % response.transactionResponse.transId)
    else:
        return response.messages.resultCode
        print("response code: %s" % response.messages.resultCode)
def get_details(refTransId):
	merchantAuth = apicontractsv1.merchantAuthenticationType()
	merchantAuth.name = constants.apiLoginId
	merchantAuth.transactionKey = constants.transactionKey

	transactionrequest = apicontractsv1.transactionRequestType()
	transactionrequest.transactionType = apicontractsv1.transactionTypeEnum.getDetailsTransaction
	transactionrequest.refTransId = refTransId

	request = apicontractsv1.createTransactionRequest()
	request.merchantAuthentication = merchantAuth
	request.refId = "Sample"
	request.transactionRequest = transactionrequest

	controller = createTransactionController(request)
	controller.execute()

	response = controller.getresponse()

	if (response.messages.resultCode=="Ok"):
	    print "SUCCESS"
	    print "Message Code : %s" % response.messages.message[0]['code'].text
	    print "Message text : %s" % response.messages.message[0]['text'].text
	    if (response.transactionResponse.responseCode == "1" ):
	        print "Payer Id : %s " % response.transactionResponse.secureAcceptance.PayerID
	        print "Transaction ID : %s " % response.transactionResponse.transId
	else:
	    print "ERROR"
	    print "Message Code : %s" % response.messages.message[0]['code'].text
	    print "Message text : %s" % response.messages.message[0]['text'].text

	return response
def purchase(card, amount):
    authorization = apicontractsv1.merchantAuthenticationType()
    authorization.name = get_api_login_id()
    authorization.transactionKey = get_transaction_id()

    card_info = apicontractsv1.creditCardType()
    card_info.cardNumber = card.number
    card_info.expirationDate = card.expiration_date
    card_info.cardCode = card.code

    payment = apicontractsv1.paymentType()
    payment.creditCard = card_info

    request_info = apicontractsv1.transactionRequestType()
    request_info.transactionType = "authCaptureTransaction"
    request_info.amount = Decimal(amount)
    request_info.payment = payment

    request = apicontractsv1.createTransactionRequest()
    request.merchantAuthentication = authorization
    request.refId = "MerchantID-0001"
    request.transactionRequest = request_info

    controller = createTransactionController(request)
    controller.execute()

    api_response = controller.getresponse()
    response = response_options(api_response)
    return response
Пример #14
0
    def send(self, card_number, expiration, amount):
        """ send the payment and return the transactionID or Error"""
        merchantAuth = apicontractsv1.merchantAuthenticationType()
        merchantAuth.name = self.merchant_id
        merchantAuth.transactionKey = self.merchant_key

        creditCard = apicontractsv1.creditCardType()
        creditCard.cardNumber = card_number
        # 5424000000000015
        creditCard.expirationDate = expiration

        payment = apicontractsv1.paymentType()
        payment.creditCard = creditCard

        transactionrequest = apicontractsv1.transactionRequestType()
        transactionrequest.transactionType ="authCaptureTransaction"
        transactionrequest.amount = Decimal(amount)
        transactionrequest.payment = payment


        createtransactionrequest = apicontractsv1.createTransactionRequest()
        createtransactionrequest.merchantAuthentication = merchantAuth
        createtransactionrequest.refId ="MerchantID-0001"

        createtransactionrequest.transactionRequest = transactionrequest
        createtransactioncontroller = createTransactionController(createtransactionrequest)
        createtransactioncontroller.execute()

        response = createtransactioncontroller.getresponse()

        if (response.messages.resultCode=="Ok"):
            return response.transactionResponse   
        else:
            return response.messages.resultCode
def charge_customer_profile(customerProfileId, paymentProfileId, amount):
    merchantAuth = apicontractsv1.merchantAuthenticationType()
    merchantAuth.name = constants.apiLoginId
    merchantAuth.transactionKey = constants.transactionKey

    # create a customer payment profile
    profileToCharge = apicontractsv1.customerProfilePaymentType()
    profileToCharge.customerProfileId = customerProfileId
    profileToCharge.paymentProfile = apicontractsv1.paymentProfile()
    profileToCharge.paymentProfile.paymentProfileId = paymentProfileId

    transactionrequest = apicontractsv1.transactionRequestType()
    transactionrequest.transactionType = "authCaptureTransaction"
    transactionrequest.amount = amount
    transactionrequest.profile = profileToCharge

    createtransactionrequest = apicontractsv1.createTransactionRequest()
    createtransactionrequest.merchantAuthentication = merchantAuth
    createtransactionrequest.refId = "MerchantID-0001"

    createtransactionrequest.transactionRequest = transactionrequest
    createtransactioncontroller = createTransactionController(
        createtransactionrequest)
    createtransactioncontroller.execute()

    response = createtransactioncontroller.getresponse()

    if (response.messages.resultCode == "Ok"):
        print "Transaction ID : %s" % response.transactionResponse.transId
    else:
        print "response code: %s" % response.messages.resultCode

    return response
Пример #16
0
def charge_credit_card(card, amount):
    merchant_auth = apicontractsv1.merchantAuthenticationType()
    merchant_auth.name = settings.get_api_login_id()
    merchant_auth.transactionKey = settings.get_transaction_id()

    credit_card = apicontractsv1.creditCardType()
    credit_card.cardNumber = card.number
    credit_card.expirationDate = card.expiration_date
    credit_card.cardCode = card.code

    payment = apicontractsv1.paymentType()
    payment.creditCard = credit_card

    transaction_request = apicontractsv1.transactionRequestType()
    transaction_request.transactionType = "authCaptureTransaction"
    transaction_request.amount = Decimal(amount)
    transaction_request.payment = payment

    request = apicontractsv1.createTransactionRequest()
    request.merchantAuthentication = merchant_auth
    request.refId = "MerchantID-0001"
    request.transactionRequest = transaction_request

    transaction_controller = createTransactionController(request)
    transaction_controller.execute()

    api_response = transaction_controller.getresponse()
    response = response_mapper(api_response)
    return response
Пример #17
0
def get_details(refTransId):
    merchantAuth = apicontractsv1.merchantAuthenticationType()
    merchantAuth.name = constants.apiLoginId
    merchantAuth.transactionKey = constants.transactionKey

    transactionrequest = apicontractsv1.transactionRequestType()
    transactionrequest.transactionType = apicontractsv1.transactionTypeEnum.getDetailsTransaction
    transactionrequest.refTransId = refTransId

    request = apicontractsv1.createTransactionRequest()
    request.merchantAuthentication = merchantAuth
    request.refId = "Sample"
    request.transactionRequest = transactionrequest

    controller = createTransactionController(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
        if (response.transactionResponse.responseCode == "1"):
            print "Payer Id : %s " % response.transactionResponse.secureAcceptance.PayerID
            print "Transaction ID : %s " % response.transactionResponse.transId
    else:
        print "ERROR"
        print "Message Code : %s" % response.messages.message[0].code
        print "Message text : %s" % response.messages.message[0].text

    return response
Пример #18
0
 def testchargeCreditCard(self):
     creditCard = apicontractsv1.creditCardType()
     creditCard.cardNumber = "4111111111111111"
     creditCard.expirationDate = "2020-12"
     payment = apicontractsv1.paymentType()
     payment.creditCard = creditCard
     transactionrequest = apicontractsv1.transactionRequestType()
     transactionrequest.transactionType = "authCaptureTransaction"
     transactionrequest.amount = Decimal(
         str(round(random.random() * 100, 2)))
     transactionrequest.payment = payment
     createtransactionrequest = apicontractsv1.createTransactionRequest()
     createtransactionrequest.merchantAuthentication = self.merchantAuthentication
     createtransactionrequest.refId = "MerchantID-0001"
     createtransactionrequest.transactionRequest = transactionrequest
     createtransactioncontroller = createTransactionController(
         createtransactionrequest)
     createtransactioncontroller.execute()
     response = createtransactioncontroller.getresponse()
     if hasattr(response, 'messages') == True:
         if hasattr(response.messages, 'resultCode') == True:
             self.assertEquals('Ok', response.messages.resultCode)
     if hasattr(response, 'transactionResponse') == True:
         if hasattr(response.transactionResponse, 'transId') == True:
             createdTransactionId = response.transactionResponse.transId
     return str(createdTransactionId)
def charge_credit_card(amount):
    merchantAuth = apicontractsv1.merchantAuthenticationType()
    merchantAuth.name = constants.apiLoginId
    merchantAuth.transactionKey = constants.transactionKey

    creditCard = apicontractsv1.creditCardType()
    creditCard.cardNumber = "4111111111111111"
    creditCard.expirationDate = "2020-12"

    payment = apicontractsv1.paymentType()
    payment.creditCard = creditCard

    transactionrequest = apicontractsv1.transactionRequestType()
    transactionrequest.transactionType = "authCaptureTransaction"
    transactionrequest.amount = amount
    transactionrequest.payment = payment

    createtransactionrequest = apicontractsv1.createTransactionRequest()
    createtransactionrequest.merchantAuthentication = merchantAuth
    createtransactionrequest.refId = "MerchantID-0001"

    createtransactionrequest.transactionRequest = transactionrequest
    createtransactioncontroller = createTransactionController(
        createtransactionrequest)
    createtransactioncontroller.execute()

    response = createtransactioncontroller.getresponse()

    if (response.messages.resultCode == "Ok"):
        print "Transaction ID : %s" % response.transactionResponse.transId
    else:
        print "response code: %s" % response.messages.resultCode

    return response
def debit_bank_account():

	amount = str(round(random.random()*100, 2))

	merchantAuth = apicontractsv1.merchantAuthenticationType()
	merchantAuth.name = constants.apiLoginId
	merchantAuth.transactionKey = constants.transactionKey


	payment = apicontractsv1.paymentType()

	bankAccountType = apicontractsv1.bankAccountType()
	accountType = apicontractsv1.bankAccountTypeEnum
	bankAccountType.accountType = accountType.checking
	bankAccountType.routingNumber = "125000024"
	bankAccountType.accountNumber = "12345678"
	bankAccountType.nameOnAccount = "John Doe"

	transactionrequest = apicontractsv1.transactionRequestType()
	transactionrequest.transactionType = "authCaptureTransaction"
	transactionrequest.amount = Decimal (amount)
	transactionrequest.payment = payment
	transactionrequest.payment.bankAccount = bankAccountType


	createtransactionrequest = apicontractsv1.createTransactionRequest()
	createtransactionrequest.merchantAuthentication = merchantAuth
	createtransactionrequest.refId = "MerchantID-0001"

	createtransactionrequest.transactionRequest = transactionrequest
	createtransactioncontroller = createTransactionController(createtransactionrequest)
	createtransactioncontroller.execute()

	response = createtransactioncontroller.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 ('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);
		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
    def __new__(cls, merchant_name=None, transactionKey=None, sessionToken=None, password=None,
                 partnerLoginIdpartnerLoginId=None, partnerTransactionKey=None, hashValue=None, timestamp=None,
                 sequence=None, fingerprint_currencyCode=None, fingerprint_amount=None, mobileDeviceId=None, refId=None,
                 transactionType='authCaptureTransaction', amount=None, currencyCode=None, cardNumber=None,
                 expirationDate=None, cardCode=None, isPaymentToken=False, cryptogram=None, track1=None, track2=None,
                 routingNumber=None, accountNumber=None, nameOnAccount=None, accountType=None, echeckType=None,
                 bankName=None, checkNumber=None, Encoding=None, EncryptionAlgorithm=None,DECRYPT=None, PIN=None,
                 Data=None, Description=None, Value=None, successUrl=None, cancelUrl=None,paypalLc=None,
                 paypalHdrImg=None, paypalPayflowcolor=None, payerID=None, dataDescriptor=None, dataValue=None,
                 dataKey=None, createProfile=None, customerProfileId=None, paymentProfileId=None,
                 shippingProfileId=None, solution_id=None, solution_name=None, vendorName=None, callId=None, authCode=None,
                 refTransId=None, splitTenderId=None, invoiceNumber=None, description=None, itemId_list=None,
                 quantity_list=None, unitPrice_list=None, name_list=None, description_list=None, taxable_list=None,
                 tax_amount=None, tax_name=None, tax_description=None, duty_amount=None, duty_name=None,
                 duty_description=None, shipping_amount=None, shipping_name=None, shipping_description=None,
                 taxExempt=None, poNumber=None, type=None, customer_id=None, email=None, number=None, state=None,
                 dateOfBirth=None, taxId=None, customerAddress_firstName=None, customerAddress_lastName=None,
                 customerAddress_company=None, customerAddress_address=None, customerAddress_city=None,
                 customerAddress_state=None, customerAddress_zip=None, customerAddress_country=None,
                 customerAddress_phoneNumber=None, customerAddress_faxNumber=None, customerAddress_email=None,
                 shipTo_firstName=None, shipTo_lastName=None, shipTo_company=None, shipTo_address=None,
                 shipTo_city=None,  shipTo_state=None, shipTo_zip=None, shipTo_country=None, customerIP=None,
                 authenticationIndicator=None, cardholderAuthenticationValue=None, marketType=None, deviceType=None,
                 employeeId=None, settingName=None, settingValue=None, userField_name=None, userField_value=None):

        TransactionRequest = apicontractsv1.createTransactionRequest()
        TransactionRequest.merchantAuthentication = merchantAuthentication(merchant_name, transactionKey, sessionToken, password,
                                                             partnerLoginIdpartnerLoginId, partnerTransactionKey,
                                                             hashValue, timestamp, sequence, fingerprint_currencyCode,
                                                             fingerprint_amount, mobileDeviceId)
        if refId:
            TransactionRequest.refId = refId

        TransactionRequest.transactionRequest = transactionRequest(transactionType, amount, currencyCode, cardNumber, expirationDate,
                                                     cardCode, isPaymentToken, cryptogram, track1, track2,
                                                     routingNumber, accountNumber, nameOnAccount, accountType,
                                                     echeckType, bankName, checkNumber, Encoding, EncryptionAlgorithm,
                                                     DECRYPT, PIN, Data, Description, Value, successUrl, cancelUrl,
                                                     paypalLc, paypalHdrImg, paypalPayflowcolor, payerID,
                                                     dataDescriptor, dataValue, dataKey, createProfile,
                                                     customerProfileId, paymentProfileId, shippingProfileId,
                                                     solution_id, solution_name, vendorName, callId, authCode,
                                                     refTransId, splitTenderId, invoiceNumber, description, itemId_list,
                                                     quantity_list, unitPrice_list, name_list, description_list,
                                                     taxable_list, tax_amount, tax_name, tax_description, duty_amount,
                                                     duty_name, duty_description, shipping_amount, shipping_name,
                                                     shipping_description, taxExempt, poNumber, type, customer_id,
                                                     email, number, state, dateOfBirth, taxId,
                                                     customerAddress_firstName, customerAddress_lastName,
                                                     customerAddress_company, customerAddress_address,
                                                     customerAddress_city, customerAddress_state, customerAddress_zip,
                                                     customerAddress_country, customerAddress_phoneNumber,
                                                     customerAddress_faxNumber, customerAddress_email, shipTo_firstName,
                                                     shipTo_lastName, shipTo_company, shipTo_address, shipTo_city,
                                                     shipTo_state, shipTo_zip, shipTo_country, customerIP,
                                                     authenticationIndicator, cardholderAuthenticationValue,
                                                     marketType, deviceType, employeeId, settingName, settingValue,
                                                     userField_name, userField_value)
        return TransactionRequest
Пример #22
0
 def create_transaction(self):
     """
     This creates the main transaction to be processed.
     """
     transaction = apicontractsv1.createTransactionRequest()
     transaction.merchantAuthentication = self.merchant_auth
     transaction.refId = self.get_transaction_id()
     return transaction
def capture_previously_authorized_amount(transactionId):
    merchantAuth = apicontractsv1.merchantAuthenticationType()
    merchantAuth.name = constants.apiLoginId
    merchantAuth.transactionKey = constants.transactionKey

    transactionrequest = apicontractsv1.transactionRequestType()
    transactionrequest.transactionType = "priorAuthCaptureTransaction"
    transactionrequest.amount = Decimal('2.55')
    transactionrequest.refTransId = transactionId

    createtransactionrequest = apicontractsv1.createTransactionRequest()
    createtransactionrequest.merchantAuthentication = merchantAuth
    createtransactionrequest.refId = "MerchantID-0001"

    createtransactionrequest.transactionRequest = transactionrequest
    createtransactioncontroller = createTransactionController(
        createtransactionrequest)
    createtransactioncontroller.execute()

    response = createtransactioncontroller.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('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)
        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
Пример #24
0
def get_details(refTransId):
    merchantAuth = apicontractsv1.merchantAuthenticationType()
    merchantAuth.name = constants.apiLoginId
    merchantAuth.transactionKey = constants.transactionKey

    transactionrequest = apicontractsv1.transactionRequestType()
    transactionrequest.transactionType = apicontractsv1.transactionTypeEnum.getDetailsTransaction
    transactionrequest.refTransId = refTransId

    request = apicontractsv1.createTransactionRequest()
    request.merchantAuthentication = merchantAuth
    request.refId = "Sample"
    request.transactionRequest = transactionrequest

    controller = createTransactionController(request)
    controller.execute()

    response = controller.getresponse()

    if response is not None:
        if response.messages.resultCode == "Ok":
            if hasattr(response.transactionResponse, 'messages') == True:
                print("Paypal Get Details Successful.")
                print('Transaction ID: %s' %
                      response.transactionResponse.transId)
                print("Payer Id : %s " %
                      response.transactionResponse.secureAcceptance.PayerID)
                print('Transaction Response Code: %s' %
                      response.transactionResponse.responseCode)
                print('Message Code: %s' %
                      response.transactionResponse.messages.message[0].code)
            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)
        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
def capture_funds_authorized_through_another_channel():

    amount = str(round(random.random()*100, 2))

    merchantAuth = apicontractsv1.merchantAuthenticationType()
    merchantAuth.name = constants.apiLoginId
    merchantAuth.transactionKey = constants.transactionKey

    creditCard = apicontractsv1.creditCardType()
    creditCard.cardNumber = "4111111111111111"
    creditCard.expirationDate = "2020-12"

    payment = apicontractsv1.paymentType()
    payment.creditCard = creditCard

    transactionrequest = apicontractsv1.transactionRequestType()
    transactionrequest.transactionType = "captureOnlyTransaction"
    transactionrequest.amount = Decimal (amount)
    transactionrequest.payment = payment
    transactionrequest.authCode = "ROHNFQ"

    createtransactionrequest = apicontractsv1.createTransactionRequest()
    createtransactionrequest.merchantAuthentication = merchantAuth
    createtransactionrequest.refId = "MerchantID-0001"

    createtransactionrequest.transactionRequest = transactionrequest
    createtransactioncontroller = createTransactionController(createtransactionrequest)
    createtransactioncontroller.execute()

    response = createtransactioncontroller.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 ('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)
        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
def capture_funds_authorized_through_another_channel():

    amount = str(round(random.random()*100, 2))

    merchantAuth = apicontractsv1.merchantAuthenticationType()
    merchantAuth.name = constants.apiLoginId
    merchantAuth.transactionKey = constants.transactionKey

    creditCard = apicontractsv1.creditCardType()
    creditCard.cardNumber = "4111111111111111"
    creditCard.expirationDate = "2035-12"

    payment = apicontractsv1.paymentType()
    payment.creditCard = creditCard

    transactionrequest = apicontractsv1.transactionRequestType()
    transactionrequest.transactionType = "captureOnlyTransaction"
    transactionrequest.amount = Decimal (amount)
    transactionrequest.payment = payment
    transactionrequest.authCode = "ROHNFQ"

    createtransactionrequest = apicontractsv1.createTransactionRequest()
    createtransactionrequest.merchantAuthentication = merchantAuth
    createtransactionrequest.refId = "MerchantID-0001"

    createtransactionrequest.transactionRequest = transactionrequest
    createtransactioncontroller = createTransactionController(createtransactionrequest)
    createtransactioncontroller.execute()

    response = createtransactioncontroller.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 ('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)
        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
def refund_transaction(refTransId):
	merchantAuth = apicontractsv1.merchantAuthenticationType()
	merchantAuth.name = constants.apiLoginId
	merchantAuth.transactionKey = constants.transactionKey

	creditCard = apicontractsv1.creditCardType()
	creditCard.cardNumber = "0015"
	creditCard.expirationDate = "XXXX"

	payment = apicontractsv1.paymentType()
	payment.creditCard = creditCard

	transactionrequest = apicontractsv1.transactionRequestType()
	transactionrequest.transactionType = "refundTransaction"
	transactionrequest.amount = Decimal ('2.55')
	#set refTransId to transId of a settled transaction
	transactionrequest.refTransId = refTransId
	transactionrequest.payment = payment


	createtransactionrequest = apicontractsv1.createTransactionRequest()
	createtransactionrequest.merchantAuthentication = merchantAuth
	createtransactionrequest.refId = "MerchantID-0001"

	createtransactionrequest.transactionRequest = transactionrequest
	createtransactioncontroller = createTransactionController(createtransactionrequest)
	createtransactioncontroller.execute()

	response = createtransactioncontroller.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 ('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);
		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
def charge_tokenized_credit_card():
    merchantAuth = apicontractsv1.merchantAuthenticationType()
    merchantAuth.name = constants.apiLoginId
    merchantAuth.transactionKey = constants.transactionKey

    creditCard = apicontractsv1.creditCardType()
    creditCard.cardNumber = "4111111111111111"
    creditCard.expirationDate = "2020-12"
    # Set the token specific info
    creditCard.isPaymentToken = True
    creditCard.cryptogram = "EjRWeJASNFZ4kBI0VniQEjRWeJA="

    payment = apicontractsv1.paymentType()
    payment.creditCard = creditCard

    transactionrequest = apicontractsv1.transactionRequestType()
    transactionrequest.transactionType = "authCaptureTransaction"
    transactionrequest.amount = Decimal ('1.5')
    transactionrequest.payment = payment

    createtransactionrequest = apicontractsv1.createTransactionRequest()
    createtransactionrequest.merchantAuthentication = merchantAuth
    createtransactionrequest.refId = "MerchantID-0001"
    createtransactionrequest.transactionRequest = transactionrequest

    createtransactioncontroller = createTransactionController(createtransactionrequest)
    createtransactioncontroller.execute()

    response = createtransactioncontroller.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 ('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)
        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
def create_an_apple_pay_transaction():

    merchantAuth = apicontractsv1.merchantAuthenticationType()
    merchantAuth.name = constants.apiLoginId
    merchantAuth.transactionKey = constants.transactionKey

    opaquedata = apicontractsv1.opaqueDataType()
    opaquedata.dataDescriptor = "COMMON.APPLE.INAPP.PAYMENT"
    opaquedata.dataValue = "eyJkYXRhIjoiQkRQTldTdE1tR2V3UVVXR2c0bzdFXC9qKzFjcTFUNzhxeVU4NGI2N2l0amNZSTh3UFlBT2hzaGpoWlBycWRVcjRYd1BNYmo0emNHTWR5KysxSDJWa1BPWStCT01GMjV1YjE5Y1g0bkN2a1hVVU9UakRsbEIxVGdTcjhKSFp4Z3A5ckNnc1NVZ2JCZ0tmNjBYS3V0WGY2YWpcL284WkliS25yS1E4U2gwb3VMQUtsb1VNbit2UHU0K0E3V0tycXJhdXo5SnZPUXA2dmhJcStIS2pVY1VOQ0lUUHlGaG1PRXRxK0grdzB2UmExQ0U2V2hGQk5uQ0hxenpXS2NrQlwvMG5xTFpSVFliRjBwK3Z5QmlWYVdIZWdoRVJmSHhSdGJ6cGVjelJQUHVGc2ZwSFZzNDhvUExDXC9rXC8xTU5kNDdrelwvcEhEY1JcL0R5NmFVTStsTmZvaWx5XC9RSk4rdFMzbTBIZk90SVNBUHFPbVhlbXZyNnhKQ2pDWmxDdXcwQzltWHpcL29iSHBvZnVJRVM4cjljcUdHc1VBUERwdzdnNjQybTRQendLRitIQnVZVW5lV0RCTlNEMnU2amJBRzMiLCJ2ZXJzaW9uIjoiRUNfdjEiLCJoZWFkZXIiOnsiYXBwbGljYXRpb25EYXRhIjoiOTRlZTA1OTMzNWU1ODdlNTAxY2M0YmY5MDYxM2UwODE0ZjAwYTdiMDhiYzdjNjQ4ZmQ4NjVhMmFmNmEyMmNjMiIsInRyYW5zYWN0aW9uSWQiOiJjMWNhZjVhZTcyZjAwMzlhODJiYWQ5MmI4Mj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ktvWklodmNOQVFFQkJRQUVnWUJhSzNFbE9zdGJIOFdvb3NlREFCZitKZ1wvMTI5SmNJYXdtN2M2VnhuN1phc05iQXEzdEF0OFB0eSt1UUNnc3NYcVprTEE3a3oyR3pNb2xOdHY5d1ltdTlVandhcjFQSFlTK0JcL29Hbm96NTkxd2phZ1hXUnowbk1vNXkzTzFLelgwZDhDUkhBVmE4OFNyVjFhNUpJaVJldjNvU3RJcXd2NXh1WmxkYWc2VHI4dz09In0="

    paymentOne = apicontractsv1.paymentType()
    paymentOne.opaqueData = opaquedata

    transactionrequest = apicontractsv1.transactionRequestType()
    transactionrequest.transactionType = apicontractsv1.transactionTypeEnum.authCaptureTransaction
    transactionrequest.amount = Decimal('151')
    transactionrequest.payment = paymentOne

    request = apicontractsv1.createTransactionRequest()
    request.merchantAuthentication = merchantAuth
    request.refId = "Sample"
    request.transactionRequest = transactionrequest

    controller = createTransactionController(request)
    controller.execute()

    response = controller.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 ('Description: %s' % response.transactionResponse.messages.message[0].description)
                print ('AUTH Code : %s' % response.authCode)
            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)
        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
Пример #30
0
def authorization_only_continued():
    merchantAuth = apicontractsv1.merchantAuthenticationType()
    merchantAuth.name = constants.apiLoginId
    merchantAuth.transactionKey = constants.transactionKey

    paypal = apicontractsv1.payPalType()
    paypal.successUrl = "http://www.merchanteCommerceSite.com/Success/TC25262"
    paypal.cancelUrl = "http://www.merchanteCommerceSite.com/Success/TC25262"
    paypal.payerID = "LM6NCLZ5RAKBY"

    payment = apicontractsv1.paymentType()
    payment.payPal = paypal

    transactionrequest = apicontractsv1.transactionRequestType()
    transactionrequest.transactionType = apicontractsv1.transactionTypeEnum.authOnlyContinueTransaction
    transactionrequest.refTransId = "2245592542"
    transactionrequest.payment = payment

    request = apicontractsv1.createTransactionRequest()
    request.merchantAuthentication = merchantAuth
    request.refId = "Sample"
    request.transactionRequest = transactionrequest

    controller = createTransactionController(request)
    controller.execute()

    response = controller.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 ("Payer Id : %s " % response.transactionResponse.secureAcceptance.PayerID)
                print ('Transaction Response Code: %s' % response.transactionResponse.responseCode)
                print ('Message Code: %s' % response.transactionResponse.messages.message[0].code)
                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)
        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
def create_an_accept_transaction():

	merchantAuth = apicontractsv1.merchantAuthenticationType()
	merchantAuth.name = constants.apiLoginId
	merchantAuth.transactionKey = constants.transactionKey

	opaquedata = apicontractsv1.opaqueDataType()
	opaquedata.dataDescriptor = "COMMON.ACCEPT.INAPP.PAYMENT"
	opaquedata.dataValue = "9471471570959063005001"

	paymentOne = apicontractsv1.paymentType()
	paymentOne.opaqueData = opaquedata

	transactionrequest = apicontractsv1.transactionRequestType()
	transactionrequest.transactionType = apicontractsv1.transactionTypeEnum.authCaptureTransaction
	transactionrequest.amount = Decimal('151')
	transactionrequest.payment = paymentOne

	request = apicontractsv1.createTransactionRequest()
	request.merchantAuthentication = merchantAuth
	request.refId = "Sample"
	request.transactionRequest = transactionrequest

	controller = createTransactionController(request)
	controller.execute()

	response = controller.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 ('Description: %s' % response.transactionResponse.messages.message[0].description);
				print ('AUTH Code : %s' % response.authCode)
			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);
		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
def create_an_apple_pay_transaction():

	merchantAuth = apicontractsv1.merchantAuthenticationType()
	merchantAuth.name = constants.apiLoginId
	merchantAuth.transactionKey = constants.transactionKey

	opaquedata = apicontractsv1.opaq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Z1hXUnowbk1vNXkzTzFLelgwZDhDUkhBVmE4OFNyVjFhNUpJaVJldjNvU3RJcXd2NXh1WmxkYWc2VHI4dz09In0="

	paymentOne = apicontractsv1.paymentType()
	paymentOne.opaqueData = opaquedata

	transactionrequest = apicontractsv1.transactionRequestType()
	transactionrequest.transactionType = apicontractsv1.transactionTypeEnum.authCaptureTransaction
	transactionrequest.amount = Decimal('151')
	transactionrequest.payment = paymentOne

	request = apicontractsv1.createTransactionRequest()
	request.merchantAuthentication = merchantAuth
	request.refId = "Sample"
	request.transactionRequest = transactionrequest

	controller = createTransactionController(request)
	controller.execute()

	response = controller.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 ('Description: %s' % response.transactionResponse.messages.message[0].description);
				print ('AUTH Code : %s' % response.authCode)
			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);
		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
def authorization_only_continued():
	merchantAuth = apicontractsv1.merchantAuthenticationType()
	merchantAuth.name = constants.apiLoginId
	merchantAuth.transactionKey = constants.transactionKey

	paypal = apicontractsv1.payPalType()
	paypal.successUrl = "http://www.merchanteCommerceSite.com/Success/TC25262"
	paypal.cancelUrl = "http://www.merchanteCommerceSite.com/Success/TC25262"
	paypal.payerID = "LM6NCLZ5RAKBY"

	payment = apicontractsv1.paymentType()
	payment.payPal = paypal

	transactionrequest = apicontractsv1.transactionRequestType()
	transactionrequest.transactionType = apicontractsv1.transactionTypeEnum.authOnlyContinueTransaction
	transactionrequest.refTransId = "2245592542"
	transactionrequest.payment = payment

	request = apicontractsv1.createTransactionRequest()
	request.merchantAuthentication = merchantAuth
	request.refId = "Sample"
	request.transactionRequest = transactionrequest

	controller = createTransactionController(request)
	controller.execute()

	response = controller.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 ("Payer Id : %s " % response.transactionResponse.secureAcceptance.PayerID)
				print ('Transaction Response Code: %s' % response.transactionResponse.responseCode);
				print ('Message Code: %s' % response.transactionResponse.messages.message[0].code);
				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);
		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
Пример #34
0
def charge_credit_card(amount):
	merchantAuth = apicontractsv1.merchantAuthenticationType()
	merchantAuth.name = constants.apiLoginId
	merchantAuth.transactionKey = constants.transactionKey

	creditCard = apicontractsv1.creditCardType()
	creditCard.cardNumber = "4111111111111111"
	creditCard.expirationDate = "2020-12"

	payment = apicontractsv1.paymentType()
	payment.creditCard = creditCard

	transactionrequest = apicontractsv1.transactionRequestType()
	transactionrequest.transactionType = "authCaptureTransaction"
	transactionrequest.amount = amount
	transactionrequest.payment = payment


	createtransactionrequest = apicontractsv1.createTransactionRequest()
	createtransactionrequest.merchantAuthentication = merchantAuth
	createtransactionrequest.refId = "MerchantID-0001"

	createtransactionrequest.transactionRequest = transactionrequest
	createtransactioncontroller = createTransactionController(createtransactionrequest)
	createtransactioncontroller.execute()

	response = createtransactioncontroller.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 ('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);
		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
Пример #35
0
    def _create_transaction_request_for_profile(self, transaction,
                                                customer_profile,
                                                payment_profile):

        """ Create an authorize.net transaction request object to a
        customer id

        :param transaction: A Silver transaction with a AuthorizeNet payment method.
        :param customer_profile: The authorize.net customer profile ID
        :param payment_profile: The authorize.net customer payment profile ID
        :return: An authorize.net TransactionRequest

        """

        profile_to_charge                                 = apicontractsv1.customerProfilePaymentType()
        profile_to_charge.customerProfileId               = customer_profile
        profile_to_charge.paymentProfile                  = apicontractsv1.paymentProfile()
        profile_to_charge.paymentProfile.paymentProfileId = payment_profile

        payment            = apicontractsv1.paymentType()
        payment.profile    = profile_to_charge

        # Create order information
        order               = apicontractsv1.orderType()
        order.invoiceNumber = transaction.document.series
        order.description   = "\n".join(map(str, transaction.document.entries))

        # Set the customer's identifying information
        customerData       = apicontractsv1.customerDataType()
        customerData.type  = "individual"
        customerData.id    = transaction.customer.id # TODO: right id field?
        customerData.email = transaction.customer.email

        settings = self._create_transaction_settings()

        _tx_request                     = apicontractsv1.transactionRequestType()
        _tx_request.transactionType     = "authCaptureTransaction"
        _tx_request.amount              = transaction.amount
        _tx_request.payment             = payment
        _tx_request.order               = order
        # _tx_request.billTo              = customerAddress
        _tx_request.customer            = customerData
        _tx_request.transactionSettings = settings
        # _tx_request.lineItems         = line_items

        _request = apicontractsv1.createTransactionRequest()
        _request.merchantAuthentication = self.merchantAuth

        _request.refId = self.merchantId
        _request.transactionRequest = _tx_request

        return _request
def create_visa_checkout_transaction():

	merchantAuth = apicontractsv1.merchantAuthenticationType()
	merchantAuth.name = constants.apiLoginId
	merchantAuth.transactionKey = constants.transactionKey
	# Populate the payment data
	opaqueData = apicontractsv1.opaqueDataType()
	opaqueData.dataDescriptor = "COMMON.VCO.ONLINE.PAYMENT"
	opaqueData.dataValue = "vJhm2AREOockvIeUeJXkzSzcSwQtnz6pTbkjuXsGRMoG/4CYVZhUaNxwA2AbPr/wWOr3GPBlIv/5sH31wQotfjCHyq+rP1X+9myn3MueaOYxhpfpfkfAZcm8upaUVl20McTiuhmhHulNNTRd5AFnq3qUS55TRkAODqwMrSL+gLab8fw4V5L355Ufu7+qjUpMFi71hQ92L7u0DjuGSDmXZzPvH3p21LphdixDLNJWvA0YQ5/jIH7WbrNkSw9O//Zsf5p256WAjdsCcvLjPCYDB2mMAs4E8ZpOpQ39GATRSscPP5550RpHeYrTDLzlLZB/P5989mcz6ReH6sIbqn9Z0W0j+aIpZ7HsSRx74ps8kYt1SZ/NTph5+rT1JhmLR+QQAYI5EeXH4amYyOxt9klHb9erkLNwDPhBNkRh08kVlxPFHK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/dRQQ/9LBbmSbOOvCq3Nv6UQwQ3JRtUaC3ZBL/T8mfBrOpwE5tEaZTfv8OmYq4exJN6n5eo+dyuaKF3zVUBSw2oAF68kzSWvuA1ZQ0HJWTemGOu0rY/jzoicCHv0cC/MJaZ+nCqYfyhWUWgdTqPg+HOw1n1tZ7/geQTgHS2ZQlP5KYrKNDBNs9lRSKLjCE4vs+ZhA6YTMn/aPQKRyrkzQE/IQb2C4+ablq0RiVKdKegoiOHeQi9WlJIpu/SSn34pedLYfHXCLDkRoHyRy+0DhXWB7CYKC6AU0ZcaWzulSHhS6c1Sm0ZiET9CW63lZNsWS5y5s7hCIEYqWm7v+4nv2gERHxXWeX/+ZWvO8DRqfX5BVbUUKXSKpgddtdTn6VKyCs4/qnU4uP1qcqbStfZX33vzJPH8RGgL/T3E1exkVYV0FTtljhruYQ9TF2pg7T950RkGwlj3cWPjSqKqKyp8yu4w8xoS9Rel/LD0sABzE16d4tVRdNeJPCmOIzYhrDddfo4xW736BzgjYGKcdSUrl9YMeyVcYhvoGGM1YzkL+PTt3RO+moo9PYGQnY+7GkOpJoBwb5COQVvcCrkwcehsmVYBle+1uEocHAHv1Kc1BtXP+WT/wyWKMGnPJoPovglIhowODb2wU8ltnbRRhP14W6jwPCqtPWV4LXN0+7VKfyqBRUGkITjQWqsntlf3/egfG4uS3faPU4M"
	opaqueData.dataKey = "ZW6TOD05lWOtUYVunXhYmXRBA6d7UTVezRCwUYLrK/xHPK5LDuZe5Rk/sT223vO0NdD7iQXMPqnQrCS1myW+CFceOKiUuoA0zKJ6TZ84q/+msPG66DDdzDxeKKdE5Qjt"
	paymentType = apicontractsv1.paymentType()
	paymentType.opaqueData = opaqueData
	# Create the payment transaction request
	transactionRequest = apicontractsv1.transactionRequestType()
	transactionRequest.transactionType = apicontractsv1.transactionTypeEnum.authCaptureTransaction
	transactionRequest.callId = "1238408836021304101"
	transactionRequest.amount = Decimal('14.00')
	transactionRequest.payment = paymentType
	# Make the API Request
	request = apicontractsv1.createTransactionRequest()
	request.merchantAuthentication = merchantAuth
	request.transactionRequest = transactionRequest
	# Execute the API request
	controller = createTransactionController(request)
	controller.execute()
	# Get the response
	response = controller.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 ('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);
		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
Пример #37
0
def credit():
    merchantAuth = apicontractsv1.merchantAuthenticationType()
    merchantAuth.name = constants.apiLoginId
    merchantAuth.transactionKey = constants.transactionKey

    paypal = apicontractsv1.payPalType()

    payment = apicontractsv1.paymentType()
    payment.payPal = paypal

    transactionrequest = apicontractsv1.transactionRequestType()
    transactionrequest.transactionType = apicontractsv1.transactionTypeEnum.refundTransaction
    transactionrequest.refTransId = "2241762126"
    transactionrequest.payment = payment

    request = apicontractsv1.createTransactionRequest()
    request.merchantAuthentication = merchantAuth
    request.refId = "Sample"
    request.transactionRequest = transactionrequest

    controller = createTransactionController(request)
    controller.execute()

    response = controller.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("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)
        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
def charge_customer_profile(customerProfileId, paymentProfileId, amount):
    merchantAuth = apicontractsv1.merchantAuthenticationType()
    merchantAuth.name = constants.apiLoginId
    merchantAuth.transactionKey = constants.transactionKey

    # create a customer payment profile
    profileToCharge = apicontractsv1.customerProfilePaymentType()
    profileToCharge.customerProfileId = customerProfileId
    profileToCharge.paymentProfile = apicontractsv1.paymentProfile()
    profileToCharge.paymentProfile.paymentProfileId = paymentProfileId

    transactionrequest = apicontractsv1.transactionRequestType()
    transactionrequest.transactionType = "authCaptureTransaction"
    transactionrequest.amount = amount
    transactionrequest.profile = profileToCharge


    createtransactionrequest = apicontractsv1.createTransactionRequest()
    createtransactionrequest.merchantAuthentication = merchantAuth
    createtransactionrequest.refId = "MerchantID-0001"

    createtransactionrequest.transactionRequest = transactionrequest
    createtransactioncontroller = createTransactionController(createtransactionrequest)
    createtransactioncontroller.execute()

    response = createtransactioncontroller.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 ('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)
        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
def authorization_and_capture_continued(refTransId, payerID):
    merchantAuth = apicontractsv1.merchantAuthenticationType()
    merchantAuth.name = constants.apiLoginId
    merchantAuth.transactionKey = constants.transactionKey

    paypal = apicontractsv1.payPalType()
    paypal.payerID = payerID

    payment = apicontractsv1.paymentType()
    payment.payPal = paypal

    transactionrequest = apicontractsv1.transactionRequestType()
    transactionrequest.transactionType = apicontractsv1.transactionTypeEnum.authCaptureContinueTransaction
    transactionrequest.refTransId = refTransId
    transactionrequest.payment = payment

    request = apicontractsv1.createTransactionRequest()
    request.merchantAuthentication = merchantAuth
    request.refId = "Sample"
    request.transactionRequest = transactionrequest

    controller = createTransactionController(request)
    controller.execute()

    response = controller.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 ("Payer Id : %s " % response.transactionResponse.secureAcceptance.PayerID)
                print ('Transaction Response Code: %s' % response.transactionResponse.responseCode)
                print ('Message Code: %s' % response.transactionResponse.messages.message[0].code)
                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)
        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
def charge_customer_profile(customerProfileId, paymentProfileId, amount):
	merchantAuth = apicontractsv1.merchantAuthenticationType()
	merchantAuth.name = constants.apiLoginId
	merchantAuth.transactionKey = constants.transactionKey

	# create a customer payment profile
	profileToCharge = apicontractsv1.customerProfilePaymentType()
	profileToCharge.customerProfileId = customerProfileId
	profileToCharge.paymentProfile = apicontractsv1.paymentProfile()
	profileToCharge.paymentProfile.paymentProfileId = paymentProfileId

	transactionrequest = apicontractsv1.transactionRequestType()
	transactionrequest.transactionType = "authCaptureTransaction"
	transactionrequest.amount = amount
	transactionrequest.profile = profileToCharge


	createtransactionrequest = apicontractsv1.createTransactionRequest()
	createtransactionrequest.merchantAuthentication = merchantAuth
	createtransactionrequest.refId = "MerchantID-0001"

	createtransactionrequest.transactionRequest = transactionrequest
	createtransactioncontroller = createTransactionController(createtransactionrequest)
	createtransactioncontroller.execute()

	response = createtransactioncontroller.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 ('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);
		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
Пример #41
0
    def void_transaction(self, transaction, payment_method=None):
        """ Void a transaction
        :param transaction: A Silver transaction with a AuthorizeNet payment method.
        :param payment_method: The payment method used to authorize the original transaction
        :returns True if the state transition was successful, False otherwise.
        """
        payment_processor = get_instance(transaction.payment_processor)

        if not payment_processor == self:
            return False

        transId = str(transaction.data.get('authorizenet_id'))

        req = apicontractsv1.transactionRequestType()
        req.transactionType = "voidTransaction"
        req.refTransId = transId

        t_req = apicontractsv1.createTransactionRequest()
        t_req.merchantAuthentication = self.merchantAuth
        t_req.refId = self.merchantId

        t_req.transactionRequest = req

        controller = createTransactionController(t_req)

        try:
            controller.execute()
        except Exception as e:
            logger.warning('Error executing request to void transaction %s', {
                'transaction_id': transId,
                'exception': str(e)
            })

        response = controller.getresponse()

        have_resp = response is not None

        if have_resp:
            status, resp_ok = self._get_authorizenet_transaction_status(
                response)

            return self._transition_silver_transaction_to(
                transaction, response, status, transaction.States.Canceled)
        else:
            logger.warning(
                'Couldn\'t void transaction %s', {
                    'transaction_id': transId,
                    'messages': response.messages.message[0]['text'].text
                })
            return False
Пример #42
0
def void(refTransId):
    merchantAuth = apicontractsv1.merchantAuthenticationType()
    merchantAuth.name = constants.apiLoginId
    merchantAuth.transactionKey = constants.transactionKey

    paypal = apicontractsv1.payPalType()

    payment = apicontractsv1.paymentType()
    payment.payPal = paypal

    transactionrequest = apicontractsv1.transactionRequestType()
    transactionrequest.transactionType = apicontractsv1.transactionTypeEnum.voidTransaction
    transactionrequest.refTransId = refTransId
    transactionrequest.payment = payment

    request = apicontractsv1.createTransactionRequest()
    request.merchantAuthentication = merchantAuth
    request.refId = "Sample"
    request.transactionRequest = transactionrequest

    controller = createTransactionController(request)
    controller.execute()

    response = controller.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 ('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)  
        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
Пример #43
0
def refund(payment_information: PaymentData, cc_last_digits: str,
           config: GatewayConfig) -> GatewayResponse:
    merchant_auth = _get_merchant_auth(config.connection_params)

    credit_card = apicontractsv1.creditCardType()
    credit_card.cardNumber = cc_last_digits
    credit_card.expirationDate = "XXXX"

    payment = apicontractsv1.paymentType()
    payment.creditCard = credit_card

    transaction_request = apicontractsv1.transactionRequestType()
    transaction_request.transactionType = "refundTransaction"
    transaction_request.amount = payment_information.amount
    transaction_request.currencyCode = payment_information.currency
    # set refTransId to transId of a settled transaction
    transaction_request.refTransId = payment_information.token
    transaction_request.payment = payment

    create_transaction_request = apicontractsv1.createTransactionRequest()
    create_transaction_request.merchantAuthentication = merchant_auth

    create_transaction_request.transactionRequest = transaction_request
    response = _make_request(create_transaction_request,
                             config.connection_params)

    (
        success,
        error,
        transaction_id,
        transaction_response,
        raw_response,
    ) = _handle_authorize_net_response(response)
    payment_method_info = _authorize_net_account_to_payment_method_info(
        transaction_response)

    return GatewayResponse(
        is_success=success,
        action_required=False,
        transaction_id=transaction_id,
        amount=payment_information.amount,
        currency=payment_information.currency,
        error=error,
        payment_method_info=payment_method_info,
        kind=TransactionKind.REFUND,
        raw_response=raw_response,
        customer_id=payment_information.customer_id,
    )
Пример #44
0
def authpayment():
    invoice = request.form.get('invoice')
    amount = request.form.get('amount')
    card_name = request.form.get('card_name')
    card_number = request.form.get('card_number')
    expiry = request.form.get('expiry')
    cvv = request.form.get('cvv')
    merchantAuth = apicontractsv1.merchantAuthenticationType()
    merchantAuth.name = '86UGvvLF6N'
    merchantAuth.transactionKey = '3q6vX7mw74JV37mR'

    creditCard = apicontractsv1.creditCardType()
    creditCard.cardNumber = card_number
    creditCard.expirationDate = expiry
    creditCard.cardCode = cvv

    payment = apicontractsv1.paymentType()
    payment.creditCard = creditCard

    transactionrequest = apicontractsv1.transactionRequestType()
    transactionrequest.transactionType = "authCaptureTransaction"
    transactionrequest.amount = Decimal(amount)
    transactionrequest.payment = payment

    createtransactionrequest = apicontractsv1.createTransactionRequest()
    createtransactionrequest.merchantAuthentication = merchantAuth
    createtransactionrequest.refId = invoice

    createtransactionrequest.transactionRequest = transactionrequest
    createtransactioncontroller = createTransactionController(
        createtransactionrequest)
    createtransactioncontroller.execute()

    response = createtransactioncontroller.getresponse()

    if (response.messages.resultCode == "Ok"):
        print("Transaction ID : %s" % response.transactionResponse.transId)
        orders = CustomerOrder.query.filter_by(
            customer_id=current_user.id,
            invoice=invoice).order_by(CustomerOrder.id.desc()).first()
        orders.status = 'Paid'
        db.session.commit()
        return redirect(url_for('thanks'))
    else:
        print("response code: %s" % response.messages.resultCode)
        flash(f'Failed with code { response.messages.resultCode }', 'error')
        return redirect(url_for('orders', invoice=invoice))
def void_transaction(refTransId):
	merchantAuth = apicontractsv1.merchantAuthenticationType()
	merchantAuth.name = constants.apiLoginId
	merchantAuth.transactionKey = constants.transactionKey


	transactionrequest = apicontractsv1.transactionRequestType()
	transactionrequest.transactionType = "voidTransaction"
	#set refTransId to transId of an unsettled transaction
	transactionrequest.refTransId = refTransId

	createtransactionrequest = apicontractsv1.createTransactionRequest()
	createtransactionrequest.merchantAuthentication = merchantAuth
	createtransactionrequest.refId = "MerchantID-0001"

	createtransactionrequest.transactionRequest = transactionrequest
	createtransactioncontroller = createTransactionController(createtransactionrequest)
	createtransactioncontroller.execute()

	response = createtransactioncontroller.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 ('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);
		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
def capture_previously_authorized_amount(transactionId):
    merchantAuth = apicontractsv1.merchantAuthenticationType()
    merchantAuth.name = constants.apiLoginId
    merchantAuth.transactionKey = constants.transactionKey


    transactionrequest = apicontractsv1.transactionRequestType()
    transactionrequest.transactionType = "priorAuthCaptureTransaction"
    transactionrequest.amount = Decimal ('2.55')
    transactionrequest.refTransId = transactionId

    createtransactionrequest = apicontractsv1.createTransactionRequest()
    createtransactionrequest.merchantAuthentication = merchantAuth
    createtransactionrequest.refId = "MerchantID-0001"

    createtransactionrequest.transactionRequest = transactionrequest
    createtransactioncontroller = createTransactionController(createtransactionrequest)
    createtransactioncontroller.execute()

    response = createtransactioncontroller.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 ('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)
        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
Пример #47
0
def get_details(refTransId):
	merchantAuth = apicontractsv1.merchantAuthenticationType()
	merchantAuth.name = constants.apiLoginId
	merchantAuth.transactionKey = constants.transactionKey

	transactionrequest = apicontractsv1.transactionRequestType()
	transactionrequest.transactionType = apicontractsv1.transactionTypeEnum.getDetailsTransaction
	transactionrequest.refTransId = refTransId

	request = apicontractsv1.createTransactionRequest()
	request.merchantAuthentication = merchantAuth
	request.refId = "Sample"
	request.transactionRequest = transactionrequest

	controller = createTransactionController(request)
	controller.execute()

	response = controller.getresponse()

	if response is not None:
		if response.messages.resultCode == "Ok":
			if hasattr(response.transactionResponse, 'messages') == True:
				print ("Paypal Get Details Successful.")
				print ('Transaction ID: %s' % response.transactionResponse.transId);
				print ("Payer Id : %s " % response.transactionResponse.secureAcceptance.PayerID);
				print ('Transaction Response Code: %s' % response.transactionResponse.responseCode);
				print ('Message Code: %s' % response.transactionResponse.messages.message[0].code);
			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);
		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
Пример #48
0
 def testauthOnlyContinueTransaction(self):      
     
     transactionrequesttype = apicontractsv1.transactionRequestType()
     transactionrequesttype.transactionType = "authCaptureTransaction"
     transactionrequesttype.amount = self.amount
     transactionrequesttype.payment = self.payment
     transactionrequesttype.order = self.order
     transactionrequesttype.customer = self.customerData
     transactionrequesttype.billTo = self.billTo
     
     createtransactionrequest = apicontractsv1.createTransactionRequest()
     createtransactionrequest.merchantAuthentication = self.merchantAuthentication
     createtransactionrequest.refId = self.ref_id
     createtransactionrequest.transactionRequest = transactionrequesttype
     createtransactioncontroller = createTransactionController(createtransactionrequest)
     createtransactioncontroller.execute()
     response = createtransactioncontroller.getresponse()
     self.assertIsNotNone(response.transactionResponse)
     self.assertIsNotNone(response.transactionResponse.transId)
def authorization_only_continued():
    merchantAuth = apicontractsv1.merchantAuthenticationType()
    merchantAuth.name = constants.apiLoginId
    merchantAuth.transactionKey = constants.transactionKey

    paypal = apicontractsv1.payPalType()
    paypal.successUrl = "http://www.merchanteCommerceSite.com/Success/TC25262"
    paypal.cancelUrl = "http://www.merchanteCommerceSite.com/Success/TC25262"
    paypal.payerID = "LM6NCLZ5RAKBY"

    payment = apicontractsv1.paymentType()
    payment.payPal = paypal

    transactionrequest = apicontractsv1.transactionRequestType()
    transactionrequest.transactionType = apicontractsv1.transactionTypeEnum.authOnlyContinueTransaction
    transactionrequest.refTransId = "2245592542"
    transactionrequest.payment = payment

    request = apicontractsv1.createTransactionRequest()
    request.merchantAuthentication = merchantAuth
    request.refId = "Sample"
    request.transactionRequest = transactionrequest

    controller = createTransactionController(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
        if (response.transactionResponse.responseCode == "1" ):
            print "Description : %s " % response.transactionResponse.messages.message[0].description
            print "Payer Id : %s " % response.transactionResponse.secureAcceptance.PayerID
            print "Transaction ID : %s " % response.transactionResponse.transId
    else:
        print "ERROR"
        print "Message Code : %s" % response.messages.message[0].code
        print "Message text : %s" % response.messages.message[0].text

    return response
def prior_authorization_capture(refTransId):
    merchantAuth = apicontractsv1.merchantAuthenticationType()
    merchantAuth.name = constants.apiLoginId
    merchantAuth.transactionKey = constants.transactionKey

    paypal = apicontractsv1.payPalType()
    paypal.successUrl = "http://www.merchanteCommerceSite.com/Success/TC25262"
    paypal.cancelUrl = "http://www.merchanteCommerceSite.com/Success/TC25262"
    paypal.payerID = "LM6NCLZ5RAKBY"

    payment = apicontractsv1.paymentType()
    payment.payPal = paypal

    transactionrequest = apicontractsv1.transactionRequestType()
    transactionrequest.transactionType = apicontractsv1.transactionTypeEnum.priorAuthCaptureTransaction
    transactionrequest.refTransId = refTransId
    transactionrequest.payment = payment

    request = apicontractsv1.createTransactionRequest()
    request.merchantAuthentication = merchantAuth
    request.refId = "Sample"
    request.transactionRequest = transactionrequest

    controller = createTransactionController(request)
    controller.execute()

    response = controller.getresponse()

    if (response.messages.resultCode=="Ok"):
        print "SUCCESS"
        print "Message Code : %s" % response.messages.message[0]['code'].text
        print "Message text : %s" % response.messages.message[0]['text'].text
        print "Auth code : %s " % response.transactionResponse.authCode
        if (response.transactionResponse.responseCode == "1" ):
            print "Description : %s " % response.transactionResponse.messages.message[0].description
            print "Transaction ID : %s " % response.transactionResponse.transId
    else:
        print "ERROR"
        print "Message Code : %s" % response.messages.message[0]['code'].text
        print "Message text : %s" % response.messages.message[0]['text'].text

    return response
def debit_bank_account():

	amount = str(round(random.random()*100, 2))

	merchantAuth = apicontractsv1.merchantAuthenticationType()
	merchantAuth.name = constants.apiLoginId
	merchantAuth.transactionKey = constants.transactionKey


	payment = apicontractsv1.paymentType()

	bankAccountType = apicontractsv1.bankAccountType()
	accountType = apicontractsv1.bankAccountTypeEnum
	bankAccountType.accountType = accountType.checking
	bankAccountType.routingNumber = "125000024"
	bankAccountType.accountNumber = "12345678"
	bankAccountType.nameOnAccount = "John Doe"

	transactionrequest = apicontractsv1.transactionRequestType()
	transactionrequest.transactionType = "authCaptureTransaction"
	transactionrequest.amount = Decimal (amount)
	transactionrequest.payment = payment
	transactionrequest.payment.bankAccount = bankAccountType


	createtransactionrequest = apicontractsv1.createTransactionRequest()
	createtransactionrequest.merchantAuthentication = merchantAuth
	createtransactionrequest.refId = "MerchantID-0001"

	createtransactionrequest.transactionRequest = transactionrequest
	createtransactioncontroller = createTransactionController(createtransactionrequest)
	createtransactioncontroller.execute()

	response = createtransactioncontroller.getresponse()

	if (response.messages.resultCode=="Ok"):
	    print "Transaction ID : %s" % response.transactionResponse.transId
	    print response.transactionResponse.messages.message[0].description
	else:
	    print "response code: %s" % response.messages.resultCode

	return response
def authorization_and_capture_continue(refTransId, payerID):
    merchantAuth = apicontractsv1.merchantAuthenticationType()
    merchantAuth.name = constants.apiLoginId
    merchantAuth.transactionKey = constants.transactionKey

    paypal = apicontractsv1.payPalType()
    paypal.payerID = payerID

    payment = apicontractsv1.paymentType()
    payment.payPal = paypal

    transactionrequest = apicontractsv1.transactionRequestType()
    transactionrequest.transactionType = apicontractsv1.transactionTypeEnum.authCaptureContinueTransaction
    transactionrequest.refTransId = refTransId
    transactionrequest.payment = payment

    request = apicontractsv1.createTransactionRequest()
    request.merchantAuthentication = merchantAuth
    request.refId = "Sample"
    request.transactionRequest = transactionrequest

    controller = createTransactionController(request)
    controller.execute()

    response = controller.getresponse()

    if (response.messages.resultCode=="Ok"):
        print "SUCCESS"
        print "Message Code : %s" % response.messages.message[0]['code'].text
        print "Message text : %s" % response.messages.message[0]['text'].text
        if (response.transactionResponse.responseCode == "1" ):
            print "Description : %s " % response.transactionResponse.messages.message[0].description
            print "Payer Id : %s " % response.transactionResponse.secureAcceptance.PayerID
            print "Transaction ID : %s " % response.transactionResponse.transId
    else:
        print "ERROR"
        print "Message Code : %s" % response.messages.message[0]['code'].text
        print "Message text : %s" % response.messages.message[0]['text'].text

    return response
def refund_transaction(refTransId):
	merchantAuth = apicontractsv1.merchantAuthenticationType()
	merchantAuth.name = constants.apiLoginId
	merchantAuth.transactionKey = constants.transactionKey

	creditCard = apicontractsv1.creditCardType()
	creditCard.cardNumber = "0015"
	creditCard.expirationDate = "XXXX"

	payment = apicontractsv1.paymentType()
	payment.creditCard = creditCard

	transactionrequest = apicontractsv1.transactionRequestType()
	transactionrequest.transactionType = "refundTransaction"
	transactionrequest.amount = Decimal ('2.55')
	#set refTransId to transId of a settled transaction
	transactionrequest.refTransId = refTransId
	transactionrequest.payment = payment


	createtransactionrequest = apicontractsv1.createTransactionRequest()
	createtransactionrequest.merchantAuthentication = merchantAuth
	createtransactionrequest.refId = "MerchantID-0001"

	createtransactionrequest.transactionRequest = transactionrequest
	createtransactioncontroller = createTransactionController(createtransactionrequest)
	createtransactioncontroller.execute()

	response = createtransactioncontroller.getresponse()

	if (response.messages.resultCode=="Ok"):
	    print "Transaction ID : %s" % response.transactionResponse.transId
	else:
	    print "response 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
	    print "Transaction Error Code: %s" % response.transactionResponse.errors.error[0].errorCode
	    print "Transaction Error Text: %s" % response.transactionResponse.errors.error[0].errorText

	return response
def authorization_only():
	merchantAuth = apicontractsv1.merchantAuthenticationType()
	merchantAuth.name = constants.apiLoginId
	merchantAuth.transactionKey = constants.transactionKey

	paypal = apicontractsv1.payPalType()
	paypal.successUrl = "http://www.merchanteCommerceSite.com/Success/TC25262"
	paypal.cancelUrl = "http://www.merchanteCommerceSite.com/Success/TC25262"

	payment = apicontractsv1.paymentType()
	payment.payPal = paypal

	transactionrequest = apicontractsv1.transactionRequestType()
	transactionrequest.amount = Decimal('55.00')
	transactionrequest.transactionType = apicontractsv1.transactionTypeEnum.authOnlyTransaction
	transactionrequest.payment = payment

	request = apicontractsv1.createTransactionRequest()
	request.merchantAuthentication = merchantAuth
	request.refId = "Sample"
	request.transactionRequest = transactionrequest

	controller = createTransactionController(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 "Secure acceptance URL : %s " % response.transactionResponse.secureAcceptance.SecureAcceptanceUrl
	    print "Transaction ID : %s " % response.transactionResponse.transId
	else:
	    print "ERROR"
	    print "Message Code : %s" % response.messages.message[0].code
	    print "Message text : %s" % response.messages.message[0].text

	return response
Пример #55
0
 def testAuthOnlyContinueTransaction(self):      
     transactionrequesttype = apicontractsv1.transactionRequestType()
     transactionrequesttype.transactionType = "authCaptureTransaction"
     transactionrequesttype.amount = self.amount
     transactionrequesttype.payment = self.payment
     transactionrequesttype.order = self.order
     transactionrequesttype.customer = self.customerData
     transactionrequesttype.billTo = self.billTo
     createtransactionrequest = apicontractsv1.createTransactionRequest()
     createtransactionrequest.merchantAuthentication = self.merchantAuthentication
     createtransactionrequest.refId = self.ref_id
     createtransactionrequest.transactionRequest = transactionrequesttype
     createtransactioncontroller = createTransactionController(createtransactionrequest)
     createtransactioncontroller.execute()
     response = createtransactioncontroller.getresponse()
     if hasattr(response, 'messages') == True:
         if hasattr(response.messages, 'resultCode') == True:
             self.assertEquals('Ok', response.messages.resultCode)
     if hasattr(response, 'transactionResponse') == True:
         self.assertIsNotNone(response.transactionResponse)
         if hasattr(response.transactionResponse, 'transId') == True:    
             self.assertIsNotNone(response.transactionResponse.transId)
Пример #56
0
    def make_payment(self, ccNumber, ccExpire, amount):

        #CC details
        creditCard = apicontractsv1.creditCardType()
        creditCard.cardNumber = ccNumber
        creditCard.expirationDate = ccExpire
        
        #Making the payment type
        payment = apicontractsv1.paymentType()
        payment.creditCard = creditCard
        
        #Setting the amount and transaction type
        transactionrequest = apicontractsv1.transactionRequestType()
        transactionrequest.transactionType = "authCaptureTransaction"
        transactionrequest.amount = Decimal (amount)
        transactionrequest.payment = payment
        
        #creating the transaction request
        createtransactionrequest = apicontractsv1.createTransactionRequest()
        createtransactionrequest.merchantAuthentication = self.merchantAuth
        createtransactionrequest.refId = "MerchantID-0001"
        createtransactionrequest.transactionRequest = transactionrequest
        createtransactioncontroller = createTransactionController(createtransactionrequest)
        createtransactioncontroller.execute()
        
        #Getting the response from the controller
        response = createtransactioncontroller.getresponse()
        
        #Checking the status code.
        if (response.messages.resultCode=="Ok"):
            
            #function to update
            print "avsResultCode=", response.transactionResponse.avsResultCode
            statusCode = {'error': False, 'resultcode': response.messages.resultCode}
        else:
            print "response code: %s" % response.messages.resultCode
            print "error =", response.transactionResponse.errors.error
            statusCode = {'error': True, 'resultcode': response.messages.resultCode}
        return statusCode
Пример #57
0
def credit():
	merchantAuth = apicontractsv1.merchantAuthenticationType()
	merchantAuth.name = constants.apiLoginId
	merchantAuth.transactionKey = constants.transactionKey

	paypal = apicontractsv1.payPalType()

	payment = apicontractsv1.paymentType()
	payment.payPal = paypal

	transactionrequest = apicontractsv1.transactionRequestType()
	transactionrequest.transactionType = apicontractsv1.transactionTypeEnum.refundTransaction
	transactionrequest.refTransId = "2241762126"
	transactionrequest.payment = payment

	request = apicontractsv1.createTransactionRequest()
	request.merchantAuthentication = merchantAuth
	request.refId = "Sample"
	request.transactionRequest = transactionrequest

	controller = createTransactionController(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
	    if (response.transactionResponse.responseCode == "1" ):
	        print "Transaction ID : %s " % response.transactionResponse.transId
	        print "Description : %s " % response.transactionResponse.messages.message[0].description
	else:
	    print "ERROR"
	    print "Message Code : %s" % response.messages.message[0].code
	    print "Message text : %s" % response.messages.message[0].text

	return response