Esempio n. 1
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
Esempio n. 2
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
Esempio n. 3
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)
Esempio n. 4
0
    def test_create_customer_profile(self):
        """ Create customer profile and payment methods
        """
        customer = CustomerFactory()
        credit_card = CreditCard()

        profile = apicontractsv1.customerProfileType()
        profile.merchantCustomerId = customer['ref_id']
        profile.description = '%s %s' % (customer['first_name'], customer['last_name'])
        profile.email = customer['email']

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

        payment_profile = apicontractsv1.customerPaymentProfileType()
        payment_profile.customerType = 'individual'
        payment = apicontractsv1.paymentType()
        payment.creditCard = card
        payment_profile.payment = payment

        profile.paymentProfiles = [payment_profile]

        create_profile_request = apicontractsv1.createCustomerProfileRequest()
        create_profile_request.merchantAuthentication = self.merchant
        create_profile_request.profile = profile

        controller = apicontrollers.CreateCustomerProfileController(create_profile_request)

        response = controller.execute()
        rc = etree.tostring(response.root)

        response.get_element_text('ns:customerProfileId')
        # response.customerPaymentProfileIdList.numericString[0]
        print(response)
Esempio n. 5
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)
Esempio n. 6
0
    def refund_payment(self, payment):
        # Init transaction
        self.transaction = self.create_transaction()
        self.transaction_type = self.create_transaction_type(
            self.transaction_types[TransactionTypes.REFUND])
        self.transaction_type.amount = self.to_valid_decimal(payment.amount)
        self.transaction_type.refTransId = payment.transaction

        creditCard = apicontractsv1.creditCardType()
        creditCard.cardNumber = ast.literal_eval(
            payment.result['raw']).get('accountNumber')[-4:]
        creditCard.expirationDate = "XXXX"

        payment_type = apicontractsv1.paymentType()
        payment_type.creditCard = creditCard
        self.transaction_type.payment = payment_type

        self.transaction.transactionRequest = self.transaction_type
        self.controller = createTransactionController(self.transaction)
        self.set_controller_api_endpoint()
        self.controller.execute()

        response = self.controller.getresponse()
        self.check_response(response)

        if self.transaction_submitted:
            self.update_invoice_status(Invoice.InvoiceStatus.REFUNDED)
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
Esempio n. 8
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)
Esempio n. 9
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)
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)
Esempio n. 11
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 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
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    
Esempio n. 14
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)
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
Esempio n. 16
0
def creditCardPayment(request):
    creditCard = apicontractsv1.creditCardType()
    form = CreditCardForm()

    if request.method == 'POST':
        form = CreditCardForm(request.POST)
        if form.is_valid():
            try:
                creditCard_num = form.cleaned_data['creditCard_num']
            except (ValidationError):
                return render(request, 'new/card.html', {
                    'error_message': "Invalid Card",
                })

            try:
                expirationDate = form.cleaned_data['expirationDate']
                amount = form.cleaned_data['amount']
                creditCard.cardNumber = str(creditCard_num)
                creditCard.expirationDate = str(expirationDate)
                payment = apicontractsv1.paymentType()
                payment.creditCard = creditCard

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

                transactionrequest.payment = payment

                #code from api
                createtransactionrequestapicontractsv1.createTransactionRequest(
                )
                createtransactionrequest.merchantAuthentication = merchantAuth
                createtransactionrequest.refId = "MerchantID01"

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

                response = createtransactioncontroller.getresponse()

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

                return render(
                    request,
                    'new/card.html',
                    {"message": message},
                )
            except (ValidationError):
                return render(request, 'new/card.html', {
                    'error_message': "Card Expired!",
                })
    return render(
        request,
        'new/card.html',
    )
Esempio n. 17
0
 def create_authorize_payment(self):
     """
     Creates a payment instance acording to the billing information captured
     """
     payment = apicontractsv1.paymentType()
     payment.creditCard = self.payment_type_switch[int(
         self.payment_info.data.get('payment_type'))]()
     return payment
Esempio n. 18
0
    def setUp(self):
        utility.helper.setpropertyfile('anet_python_sdk_properties.ini')

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

        self.merchantAuthentication = apicontractsv1.merchantAuthenticationType(
        )
        self.merchantAuthentication.name = utility.helper.getproperty(
            'api.login.id')
        self.merchantAuthentication.transactionKey = utility.helper.getproperty(
            'transaction.key')
        self.ref_id = 'Sample'

        self.dateOne = datetime.date(2020, 8, 30)
        self.interval = CTD_ANON()
        self.interval.length = 1
        self.interval.unit = 'months'
        self.paymentScheduleOne = apicontractsv1.paymentScheduleType()
        self.paymentScheduleOne.interval = self.interval
        self.paymentScheduleOne.startDate = self.dateOne
        self.paymentScheduleOne.totalOccurrences = 12
        self.paymentScheduleOne.trialOccurrences = 1

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

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

        self.customerOne = apicontractsv1.nameAndAddressType()
        self.customerOne.firstName = "John"
        self.customerOne.lastName = "Smith"

        self.customerData = apicontractsv1.customerDataType()
        self.customerData.id = "99999456654"

        self.subscriptionOne = apicontractsv1.ARBSubscriptionType()
        self.subscriptionOne.paymentSchedule = self.paymentScheduleOne
        self.subscriptionOne.amount = Decimal(
            str(round(random.random() * 100, 2)))
        self.subscriptionOne.trialAmount = Decimal('0.03')
        self.subscriptionOne.payment = self.payment
        self.subscriptionOne.billTo = self.customerOne

        self.order = apicontractsv1.orderType()
        self.order.invoiceNumber = "INV-21345"
        self.order.description = "Product description"

        self.billTo = apicontractsv1.customerAddressType()
        self.billTo.firstName = "Ellen"
        self.billTo.lastName = "Johnson"
        self.billTo.company = "Souveniropolis"
        self.billTo.address = "14 Main St"
        self.billTo.city = "Seattle"
        self.billTo.state = "WA"
        self.billTo.zip = "98122"
        self.billTo.country = "USA"
Esempio n. 19
0
 def setUp(self):
     utility.helper.setpropertyfile('anet_python_sdk_properties.ini')
     
     self.amount = str(round(random.random()*100, 2))
    
     self.merchantAuthentication = apicontractsv1.merchantAuthenticationType()       
     self.merchantAuthentication.name = helper.getproperty('api_login_id')
     self.merchantAuthentication.transactionKey = helper.getproperty('transaction_key')
     self.ref_id = 'Sample'
     
     self.dateOne = datetime.date(2020, 8, 30)
     self.interval = CTD_ANON()
     self.interval.length = 1
     self.interval.unit = 'months'
     self.paymentScheduleOne = apicontractsv1.paymentScheduleType()
     self.paymentScheduleOne.interval = self.interval
     self.paymentScheduleOne.startDate = self.dateOne
     self.paymentScheduleOne.totalOccurrences = 12
     self.paymentScheduleOne.trialOccurrences = 1
     
     self.creditCardOne = apicontractsv1.creditCardType()
     self.creditCardOne.cardNumber = "4111111111111111"
     self.creditCardOne.expirationDate = "2020-12"
     
     self.payment = apicontractsv1.paymentType()
     self.payment.creditCard = self.creditCardOne
     
     self.customerOne = apicontractsv1.nameAndAddressType()
     self.customerOne.firstName = "John"
     self.customerOne.lastName = "Smith"
     
     self.customerData = apicontractsv1.customerDataType()
     self.customerData.id = "99999456654"
     
     self.subscriptionOne = apicontractsv1.ARBSubscriptionType()
     self.subscriptionOne.paymentSchedule = self.paymentScheduleOne
     self.subscriptionOne.amount = Decimal(self.amount)
     self.subscriptionOne.trialAmount = Decimal ('0.03')
     self.subscriptionOne.payment = self.payment
     self.subscriptionOne.billTo = self.customerOne
     
     self.order = apicontractsv1.orderType()
     self.order.invoiceNumber = "INV-21345"
     self.order.description = "Product description"
     
     self.billTo = apicontractsv1.customerAddressType()
     self.billTo.firstName = "Ellen"
     self.billTo.lastName = "Johnson"
     self.billTo.company = "Souveniropolis"
     self.billTo.address = "14 Main St"
     self.billTo.city = "Seattle"
     self.billTo.state = "WA"
     self.billTo.zip = "98122"
     self.billTo.country = "USA"
    
 
     
Esempio n. 20
0
def _getPayment(opaque_data):
    # Create the payment object for a payment nonce
    opaqueData = apicontractsv1.opaqueDataType()
    opaqueData.dataDescriptor = opaque_data['dataDescriptor']
    opaqueData.dataValue = opaque_data['dataValue']

    # Add the payment data to a paymentType object
    payment = apicontractsv1.paymentType()
    payment.opaqueData = opaqueData
    return payment
Esempio n. 21
0
def _getPayment(opaque_data):
    # Create the payment object for a payment nonce
    opaqueData = apicontractsv1.opaqueDataType()
    opaqueData.dataDescriptor = opaque_data['dataDescriptor']
    opaqueData.dataValue = opaque_data['dataValue']

    # Add the payment data to a paymentType object
    payment = apicontractsv1.paymentType()
    payment.opaqueData = opaqueData
    return payment
Esempio n. 22
0
def create_subscription(amount, days):

    # Setting the merchant details
    merchantAuth = apicontractsv1.merchantAuthenticationType()
    merchantAuth.name = constants.apiLoginId
    merchantAuth.transactionKey = constants.transactionKey
    # Setting payment schedule
    paymentschedule = apicontractsv1.paymentScheduleType()
    paymentschedule.interval = apicontractsv1.paymentScheduleTypeInterval(
    )  #apicontractsv1.CTD_ANON() #modified by krgupta
    paymentschedule.interval.length = days
    paymentschedule.interval.unit = apicontractsv1.ARBSubscriptionUnitEnum.days
    paymentschedule.startDate = datetime(2021, 12, 30)
    paymentschedule.totalOccurrences = 12
    paymentschedule.trialOccurrences = 1
    # Giving the credit card info
    creditcard = apicontractsv1.creditCardType()
    creditcard.cardNumber = "4111111111111111"
    creditcard.expirationDate = "2035-12"
    payment = apicontractsv1.paymentType()
    payment.creditCard = creditcard
    # Setting billing information
    billto = apicontractsv1.nameAndAddressType()
    billto.firstName = "John"
    billto.lastName = "Smith"
    # Setting subscription details
    subscription = apicontractsv1.ARBSubscriptionType()
    subscription.name = "Sample Subscription"
    subscription.paymentSchedule = paymentschedule
    subscription.amount = amount
    subscription.trialAmount = Decimal('0.00')
    subscription.billTo = billto
    subscription.payment = payment
    # Creating the request
    request = apicontractsv1.ARBCreateSubscriptionRequest()
    request.merchantAuthentication = merchantAuth
    request.subscription = subscription
    # Creating and executing the controller
    controller = ARBCreateSubscriptionController(request)
    controller.execute()
    # Getting the response
    response = controller.getresponse()

    if (response.messages.resultCode == "Ok"):
        print("SUCCESS:")
        print("Message Code : %s" % response.messages.message[0]['code'].text)
        print("Message text : %s" %
              str(response.messages.message[0]['text'].text))
        print("Subscription ID : %s" % response.subscriptionId)
    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 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 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 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 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
Esempio n. 27
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_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 = "eyJkYXRhIjoiQkRQTldTdE1tR2V3UV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ymentOne = 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
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 = "eyJkYXRhIjoiQkRQTldTdE1tR2V3UVVXR2c0bzdFXC9qKzFjcTFUNzhxeVU4NGI2N2l0amNZSTh3UFlBT2hzaGpoWlBycWRVcjRYd1BNYmo0emNHTWR5KysxSDJWa1BPWStCT01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WtaTTYwVFoyaUkxcGo1NVVjOGZkNGZ6T3BrM2Z0WmFRR1hOTFlwdEcxZDlWN0lTODJPdXA5TU1vMUJQVnJYVFBITmNzTTk5RVBVblBxZGJlR2M4N20wckFnTUJBQUdqWERCYU1GZ0dBMVVkQVFSUk1FK0FFSFpXUHJXdEpkN1laNDMxaENnN1lGU2hLVEFuTVNVd0l3WURWUVFESGh3QVl3Qm9BRzBBWVFCcEFFQUFkZ0JwQUhNQVlRQXVBR01BYndCdGdoQmNsK1BmMytVNHBrMTNuVkQ5bndRUU1Ba0dCU3NPQXdJZEJRQURnWUVBYlVLWUNrdUlLUzlRUTJtRmNNWVJFSW0ybCtYZzhcL0pYditHQlZRSmtPS29zY1k0aU5ERkFcL2JRbG9nZjlMTFU4NFRId05SbnN2VjNQcnY3UlRZODFncTBkdEM4elljQWFBa0NISUkzeXFNbko0QU91NkVPVzlrSmsyMzJnU0U3V2xDdEhiZkxTS2Z1U2dRWDhLWFFZdVpMazJScjYzTjhBcFhzWHdCTDNjSjB4Z2VBd2dkMENBUUV3T3pBbk1TVXdJd1lEVlFRREhod0FZd0JvQUcwQVlRQnBBRUFBZGdCcEFITUFZUUF1QUdNQWJ3QnRBaEJjbCtQZjMrVTRwazEzblZEOW53UVFNQWtHQlNzT0F3SWFCUUF3RFFZSktvWklodmNOQVFFQkJRQUVnWUJhSzNFbE9zdGJIOFdvb3NlREFCZitKZ1wvMTI5SmNJYXdtN2M2VnhuN1phc05iQXEzdEF0OFB0eSt1UUNnc3NYcVprTEE3a3oyR3pNb2xOdHY5d1ltdTlVandhcjFQSFlTK0JcL29Hbm96NTkxd2phZ1hXUnowbk1vNXkzTzFLelgwZDhDUkhBVmE4OFNyVjFhNUpJaVJldjNvU3RJcXd2NXh1WmxkYWc2VHI4dz09In0="

    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
Esempio n. 31
0
    def make_creditCard(credit_card, expiration_date, card_code):
        """Create a payment object with credit card details"""

        payment = apicontractsv1.paymentType()

        creditCard = apicontractsv1.creditCardType()
        creditCard.cardNumber = credit_card
        creditCard.expirationDate = expiration_date
        creditCard.cardCode = card_code
        payment.creditCard = creditCard

        return payment
def create_subscription(amount, days):

    # Setting the merchant details
    merchantAuth = apicontractsv1.merchantAuthenticationType()
    merchantAuth.name = constants.apiLoginId
    merchantAuth.transactionKey = constants.transactionKey
    # Setting payment schedule
    paymentschedule = apicontractsv1.paymentScheduleType()
    paymentschedule.interval = apicontractsv1.paymentScheduleTypeInterval() #apicontractsv1.CTD_ANON() #modified by krgupta
    paymentschedule.interval.length = days
    paymentschedule.interval.unit = apicontractsv1.ARBSubscriptionUnitEnum.days
    paymentschedule.startDate = datetime(2020, 8, 30)
    paymentschedule.totalOccurrences = 12
    paymentschedule.trialOccurrences = 1
    # Giving the credit card info
    creditcard = apicontractsv1.creditCardType()
    creditcard.cardNumber = "4111111111111111"
    creditcard.expirationDate = "2020-12"
    payment = apicontractsv1.paymentType()
    payment.creditCard = creditcard
    # Setting billing information
    billto = apicontractsv1.nameAndAddressType()
    billto.firstName = "John"
    billto.lastName = "Smith"
    # Setting subscription details
    subscription = apicontractsv1.ARBSubscriptionType()
    subscription.name = "Sample Subscription"
    subscription.paymentSchedule = paymentschedule
    subscription.amount = amount
    subscription.trialAmount = Decimal('0.00')
    subscription.billTo = billto
    subscription.payment = payment
    # Creating the request
    request = apicontractsv1.ARBCreateSubscriptionRequest()
    request.merchantAuthentication = merchantAuth
    request.subscription = subscription
    # Creating and executing the controller
    controller = ARBCreateSubscriptionController(request)
    controller.execute()
    # Getting the response
    response = controller.getresponse()

    if (response.messages.resultCode=="Ok"):
        print ("SUCCESS:")
        print ("Message Code : %s" % response.messages.message[0]['code'].text)
        print ("Message text : %s" % str(response.messages.message[0]['text'].text))
        print ("Subscription ID : %s" % response.subscriptionId)
    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 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
Esempio n. 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
Esempio n. 35
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 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+QQAYI5EeXH4amYyOxt9klHb9erkLNwDPhBNkRh08kVlxPFHK4AHj1nXnaKjSs4yQ8JighJyD5rc1ekvX/n/Ng+TFbdpEUxsCAyNeClclxytaU0g6jJuxcsyq3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n5eo+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
Esempio n. 37
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 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 update_customer_payment_profile(customerProfileId,
                                    customerPaymentProfileId):
    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

    paymentProfile = apicontractsv1.customerPaymentProfileExType()
    paymentProfile.billTo = apicontractsv1.customerAddressType()
    paymentProfile.billTo.firstName = "John"
    paymentProfile.billTo.lastName = "Doe"
    paymentProfile.billTo.address = "123 Main St."
    paymentProfile.billTo.city = "Bellevue"
    paymentProfile.billTo.state = "WA"
    paymentProfile.billTo.zip = "98004"
    paymentProfile.billTo.country = "USA"
    paymentProfile.billTo.phoneNumber = "000-000-000"
    paymentProfile.payment = payment
    paymentProfile.customerPaymentProfileId = customerPaymentProfileId

    updateCustomerPaymentProfile = apicontractsv1.updateCustomerPaymentProfileRequest(
    )
    updateCustomerPaymentProfile.merchantAuthentication = merchantAuth
    updateCustomerPaymentProfile.paymentProfile = paymentProfile
    updateCustomerPaymentProfile.customerProfileId = customerProfileId
    updateCustomerPaymentProfile.validationMode = apicontractsv1.validationModeEnum.liveMode

    controller = updateCustomerPaymentProfileController(
        updateCustomerPaymentProfile)
    controller.execute()

    response = controller.getresponse()

    if (response.messages.resultCode == "Ok"):
        print("Successfully updated customer payment profile with id %s" %
              updateCustomerPaymentProfile.paymentProfile.
              customerPaymentProfileId)
    else:
        print(response.messages.message[0]['text'].text)
        print("Failed to update customer with customer payment profile id %s" %
              updateCustomerPaymentProfile.paymentProfile.
              customerPaymentProfileId)

    return response
Esempio n. 40
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
Esempio n. 41
0
    def make_bankAccount(account_type, routing_number, account_number,
                         name_on_account, bank_name):
        """Create a payment object with bank account details"""

        bankAccount = apicontractsv1.bankAccountType()
        bankAccount.accountType = account_type.name
        bankAccount.routingNumber = routing_number
        bankAccount.accountNumber = account_number
        bankAccount.nameOnAccount = name_on_account
        bankAccount.bankName = bank_name

        payment = apicontractsv1.paymentType()
        payment.bankAccount = bankAccount

        return payment
Esempio n. 42
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,
    )
Esempio n. 43
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 update_subscription(subscriptionId):
	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

	#set profile information
	profile = apicontractsv1.customerProfileIdType()
	profile.customerProfileId = "121212";
	profile.customerPaymentProfileId = "131313";
	profile.customerAddressId = "141414";

	subscription = apicontractsv1.ARBSubscriptionType()
	subscription.payment = payment
	#to update customer profile information
	#subscription.profile = profile

	request = apicontractsv1.ARBUpdateSubscriptionRequest()
	request.merchantAuthentication = merchantAuth
	request.refId = "Sample"
	request.subscriptionId = subscriptionId
	request.subscription = subscription

	controller = ARBUpdateSubscriptionController(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)
	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 update_customer_payment_profile(customerProfileId, customerPaymentProfileId):
	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

	paymentProfile = apicontractsv1.customerPaymentProfileExType()
	paymentProfile.billTo = apicontractsv1.customerAddressType()
	paymentProfile.billTo.firstName = "John"
	paymentProfile.billTo.lastName = "Doe"
	paymentProfile.billTo.address = "123 Main St."
	paymentProfile.billTo.city = "Bellevue"
	paymentProfile.billTo.state = "WA"
	paymentProfile.billTo.zip = "98004"
	paymentProfile.billTo.country = "USA"
	paymentProfile.billTo.phoneNumber = "000-000-000"
	paymentProfile.payment = payment
	paymentProfile.customerPaymentProfileId = customerPaymentProfileId

	updateCustomerPaymentProfile = apicontractsv1.updateCustomerPaymentProfileRequest()
	updateCustomerPaymentProfile.merchantAuthentication = merchantAuth
	updateCustomerPaymentProfile.paymentProfile = paymentProfile
	updateCustomerPaymentProfile.customerProfileId = customerProfileId
	updateCustomerPaymentProfile.validationMode = apicontractsv1.validationModeEnum.liveMode

	controller = updateCustomerPaymentProfileController(updateCustomerPaymentProfile)
	controller.execute()

	response = controller.getresponse()

	if (response.messages.resultCode=="Ok"):
		print ("Successfully updated customer payment profile with id %s" % updateCustomerPaymentProfile.paymentProfile.customerPaymentProfileId)
	else:
		print (response.messages.message[0]['text'].text)
		print ("Failed to update customer with customer payment profile id %s" % updateCustomerPaymentProfile.paymentProfile.customerPaymentProfileId)

	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_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
Esempio n. 49
0
    def create_saved_payment(self, credit_card, address=None, profile_id=None):
        """
        Creates a payment profile.
        """
        creditCard = apicontractsv1.creditCardType()
        creditCard.cardNumber = credit_card.card_number
        creditCard.expirationDate = '{0.exp_year}-{0.exp_month:0>2}'.format(credit_card)
        creditCard.cardCode = credit_card.cvv

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

        billTo = apicontractsv1.customerAddressType()
        if credit_card.first_name:
            billTo.firstName = credit_card.first_name
        if credit_card.last_name:
            billTo.lastName = credit_card.last_name

        profile = apicontractsv1.customerPaymentProfileType()
        profile.payment = payment
        profile.billTo = billTo
        self._address_to_profile(address, profile)

        if profile_id:
            createCustomerPaymentProfile = apicontractsv1.createCustomerPaymentProfileRequest()
            createCustomerPaymentProfile.merchantAuthentication = self.merchantAuth
            createCustomerPaymentProfile.paymentProfile = profile
            createCustomerPaymentProfile.customerProfileId = str(profile_id)

            controller = createCustomerPaymentProfileController(createCustomerPaymentProfile)
            if not self.debug:
                controller.setenvironment(constants.PRODUCTION)
            controller.execute()

            response = controller.getresponse()
            if response.messages.resultCode == "Ok":
                return response.customerPaymentProfileId
            else:
                raise AuthorizeResponseError(
                    "Failed to create customer payment profile %s" % response.messages.message[0]['text'].text)
        else:
            return profile
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
Esempio n. 53
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
Esempio n. 54
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
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.messages.resultCode=="Ok"):
		print "Transaction ID : %s" % response.transactionResponse.transId
	else:
		print "response code: %s" % response.messages.resultCode

	return response
def create_customer_payment_profile(customerProfileId):
    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

    billTo = apicontractsv1.customerAddressType()
    billTo.firstName = "John"
    billTo.lastName = "Snow"

    profile = apicontractsv1.customerPaymentProfileType()
    profile.payment = payment
    profile.billTo = billTo

    createCustomerPaymentProfile = apicontractsv1.createCustomerPaymentProfileRequest()
    createCustomerPaymentProfile.merchantAuthentication = merchantAuth
    createCustomerPaymentProfile.paymentProfile = profile
    print("customerProfileId in create_customer_payment_profile. customerProfileId = %s" %customerProfileId)
    createCustomerPaymentProfile.customerProfileId = str(customerProfileId)

    controller = createCustomerPaymentProfileController(createCustomerPaymentProfile)
    controller.execute()

    response = controller.getresponse()

    if (response.messages.resultCode=="Ok"):
        print("Successfully created a customer payment profile with id: %s" % response.customerPaymentProfileId)
    else:
        print("Failed to create customer payment profile %s" % response.messages.message[0]['text'].text)

    return response
Esempio n. 57
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)
from authorizenet import apicontractsv1
from authorizenet.apicontrollers import *

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

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

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

profile = apicontractsv1.customerPaymentProfileType()
profile.payment = payment

createCustomerPaymentProfile = apicontractsv1.createCustomerPaymentProfileRequest()
createCustomerPaymentProfile.merchantAuthentication = merchantAuth
createCustomerPaymentProfile.paymentProfile = profile
createCustomerPaymentProfile.customerProfileId = '36731856'

createCustomerPaymentProfileController = createCustomerPaymentProfileController(createCustomerPaymentProfile)
createCustomerPaymentProfileController.execute()

response = createCustomerPaymentProfileController.getresponse()

if (response.messages.resultCode=="Ok"):
	print "Successfully created a customer payment profile with id: %s" % response.customerPaymentProfileId
else:
	print "Failed to create customer payment profile %s" % response.messages.message[0].text