def charge_customer_profile(customerProfileId, paymentProfileId, amount):
	merchantAuth = apicontractsv1.merchantAuthenticationType()
	merchantAuth.name = constants.apiLoginId
	merchantAuth.transactionKey = constants.transactionKey

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

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


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

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

	response = createtransactioncontroller.getresponse()

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

	return response
예제 #2
0
    def charge_customer_profile(self, paymentProfileId, amount, ref_id,
                                invoice_number):

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

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

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

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

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

        response = controller.getresponse()

        return Transaction(response)
def charge_customer_profile(customerProfileId, paymentProfileId, amount):
    merchantAuth = apicontractsv1.merchantAuthenticationType()
    merchantAuth.name = constants.apiLoginId
    merchantAuth.transactionKey = constants.transactionKey

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

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

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

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

    response = createtransactioncontroller.getresponse()

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

    return response
예제 #4
0
    def _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 charge_customer_profile(customerProfileId, paymentProfileId, amount):
	merchantAuth = apicontractsv1.merchantAuthenticationType()
	merchantAuth.name = constants.apiLoginId
	merchantAuth.transactionKey = constants.transactionKey

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

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


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

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

	response = createtransactioncontroller.getresponse()

	if response is not None:
		if response.messages.resultCode == "Ok":
			if hasattr(response.transactionResponse, 'messages') == True:
				print ('Successfully created transaction with Transaction ID: %s' % response.transactionResponse.transId);
				print ('Transaction Response Code: %s' % response.transactionResponse.responseCode);
				print ('Message Code: %s' % response.transactionResponse.messages.message[0].code);
				print ('Description: %s' % response.transactionResponse.messages.message[0].description);
			else:
				print ('Failed Transaction.');
				if hasattr(response.transactionResponse, 'errors') == True:
					print ('Error Code:  %s' % str(response.transactionResponse.errors.error[0].errorCode));
					print ('Error message: %s' % response.transactionResponse.errors.error[0].errorText);
		else:
			print ('Failed Transaction.');
			if hasattr(response, 'transactionResponse') == True and hasattr(response.transactionResponse, 'errors') == True:
				print ('Error Code: %s' % str(response.transactionResponse.errors.error[0].errorCode));
				print ('Error message: %s' % response.transactionResponse.errors.error[0].errorText);
			else:
				print ('Error Code: %s' % response.messages.message[0]['code'].text);
				print ('Error message: %s' % response.messages.message[0]['text'].text);
	else:
		print ('Null Response.');

	return response
def charge_customer_profile(customerProfileId, paymentProfileId, amount):
    merchantAuth = apicontractsv1.merchantAuthenticationType()
    merchantAuth.name = constants.apiLoginId
    merchantAuth.transactionKey = constants.transactionKey

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

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


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

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

    response = createtransactioncontroller.getresponse()

    if response is not None:
        if response.messages.resultCode == "Ok":
            if hasattr(response.transactionResponse, 'messages') == True:
                print ('Successfully created transaction with Transaction ID: %s' % response.transactionResponse.transId)
                print ('Transaction Response Code: %s' % response.transactionResponse.responseCode)
                print ('Message Code: %s' % response.transactionResponse.messages.message[0].code)
                print ('Description: %s' % response.transactionResponse.messages.message[0].description)
            else:
                print ('Failed Transaction.')
                if hasattr(response.transactionResponse, 'errors') == True:
                    print ('Error Code:  %s' % str(response.transactionResponse.errors.error[0].errorCode))
                    print ('Error message: %s' % response.transactionResponse.errors.error[0].errorText)
        else:
            print ('Failed Transaction.')
            if hasattr(response, 'transactionResponse') == True and hasattr(response.transactionResponse, 'errors') == True:
                print ('Error Code: %s' % str(response.transactionResponse.errors.error[0].errorCode))
                print ('Error message: %s' % response.transactionResponse.errors.error[0].errorText)
            else:
                print ('Error Code: %s' % response.messages.message[0]['code'].text)
                print ('Error message: %s' % response.messages.message[0]['text'].text)
    else:
        print ('Null Response.')

    return response
예제 #7
0
def get_an_accept_payment_page(apiLoginId, apiTransactionKey, hostedPaymentIFrameCommunicatorUrl,customerId= None):
    merchantAuth = apicontractsv1.merchantAuthenticationType()
    merchantAuth.name = apiLoginId
    merchantAuth.transactionKey = apiTransactionKey

    setting1 = apicontractsv1.settingType()
    setting1.settingName = apicontractsv1.settingNameEnum.hostedPaymentButtonOptions
    setting1.settingValue = "{\"text\": \"Pay\"}"

    setting2 = apicontractsv1.settingType()
    setting2.settingName = apicontractsv1.settingNameEnum.hostedPaymentOrderOptions
    setting2.settingValue = "{\"show\": false}"

    setting3 = apicontractsv1.settingType()
    setting3.settingName = apicontractsv1.settingNameEnum.hostedPaymentIFrameCommunicatorUrl
    setting3.settingValue = "{\"url\": \"" + hostedPaymentIFrameCommunicatorUrl + "\"}"

    setting4 = apicontractsv1.settingType()
    setting4.settingName = apicontractsv1.settingNameEnum.hostedPaymentBillingAddressOptions
    setting4.settingValue = "{\"show\": false}"

    setting5 = apicontractsv1.settingType()
    setting5.settingName = apicontractsv1.settingNameEnum.hostedPaymentReturnOptions
    setting5.settingValue = "{\"showReceipt\": false,\"url\":\"" + hostedPaymentIFrameCommunicatorUrl + "\",\"urlText\":\"Continue\",\"cancelUrlText\":\"Cancel\"}"


    settings = apicontractsv1.ArrayOfSetting()
    settings.setting.append(setting1)
    settings.setting.append(setting2)
    settings.setting.append(setting3)
    settings.setting.append(setting4)
    settings.setting.append(setting5)

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

    if customerId is not None:
       if customerId != '':
         custprofile = apicontractsv1.customerProfilePaymentType()
         custprofile.customerProfileId = customerId
         transactionrequest.profile =custprofile

    paymentPageRequest = apicontractsv1.getHostedPaymentPageRequest()
    paymentPageRequest.merchantAuthentication = merchantAuth
    paymentPageRequest.transactionRequest = transactionrequest
    paymentPageRequest.hostedPaymentSettings = settings

    paymentPageController = getHostedPaymentPageController(paymentPageRequest)

    paymentPageController.execute()

    paymentPageResponse = paymentPageController.getresponse()

    if paymentPageResponse is not None:
        if paymentPageResponse.messages.resultCode == apicontractsv1.messageTypeEnum.Ok:
            print('Successfully got hosted payment page!')

            print('Token : %s' % paymentPageResponse.token)

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

    return paymentPageResponse
예제 #8
0
파일: __init__.py 프로젝트: vonq/saleor
def authorize(
    payment_information: PaymentData,
    config: GatewayConfig,
    user_id: Optional[int] = None,
) -> GatewayResponse:
    """Based on AcceptSuite create-an-accept-payment-transaction example.

    https://github.com/AuthorizeNet/sample-code-python/blob/master/AcceptSuite/create-an-accept-payment-transaction.py
    """
    kind = TransactionKind.CAPTURE if config.auto_capture else TransactionKind.AUTH
    merchant_auth = _get_merchant_auth(config.connection_params)

    # The Saleor token is the authorize.net "opaque data"
    opaque_data = apicontractsv1.opaqueDataType()
    opaque_data.dataDescriptor = "COMMON.ACCEPT.INAPP.PAYMENT"
    opaque_data.dataValue = payment_information.token

    payment_one = apicontractsv1.paymentType()
    payment_one.opaqueData = opaque_data

    order = apicontractsv1.orderType()
    order.invoiceNumber = payment_information.order_id
    order.description = payment_information.graphql_payment_id

    # An auth.net "profile" id is the id generated by auth.net.
    # It is not the Saleor user id.
    customer_id = (payment_information.customer_id
                   if payment_information.reuse_source else None)

    customer_data = apicontractsv1.customerDataType()
    customer_data.type = "individual"
    if user_id:
        customer_data.id = str(user_id)
    customer_data.email = payment_information.customer_email

    transaction_request = apicontractsv1.transactionRequestType()
    transaction_request.transactionType = ("authCaptureTransaction"
                                           if config.auto_capture else
                                           "authOnlyTransaction")
    transaction_request.amount = payment_information.amount
    transaction_request.currencyCode = payment_information.currency
    transaction_request.order = order
    transaction_request.payment = payment_one
    transaction_request.customer = customer_data

    if payment_information.reuse_source and customer_id is None:
        profile = apicontractsv1.customerProfilePaymentType()
        profile.createProfile = True
        transaction_request.profile = profile

    if payment_information.billing:
        customer_address = apicontractsv1.customerAddressType()
        customer_address.firstName = payment_information.billing.first_name
        customer_address.lastName = payment_information.billing.last_name
        customer_address.company = payment_information.billing.company_name
        # authorize.net support says we should not attempt submitting street_address_2
        customer_address.address = payment_information.billing.street_address_1
        customer_address.city = payment_information.billing.city
        customer_address.state = payment_information.billing.country_area
        customer_address.zip = payment_information.billing.postal_code
        customer_address.country = payment_information.billing.country
        transaction_request.billTo = customer_address

    create_transaction_request = apicontractsv1.createTransactionRequest()
    create_transaction_request.merchantAuthentication = merchant_auth
    create_transaction_request.refId = str(payment_information.payment_id)
    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)
    psp_reference = None
    if transaction_id:
        psp_reference = transaction_id
    elif payment_information.token:
        transaction_id = payment_information.token

    if hasattr(response, "profileResponse") and hasattr(
            response.profileResponse, "customerProfileId"):
        customer_id = response.profileResponse.customerProfileId

    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=kind,
        raw_response=raw_response,
        customer_id=customer_id,
        psp_reference=str(psp_reference) if psp_reference else None,
    )
예제 #9
0
파일: pay.py 프로젝트: jithuraju/moviesnow
    customer_id = form_data["cid"].value
    payment_id = form_data["pid"].value

    sqlfetch = 'select global_settings_key,global_settings_val from globalmaster'
    c.execute(sqlfetch)
    data = c.fetchone()
    transactionKey, apiLoginId = data[0], data[1]
    conn.commit()

    # API to initiate payment
    merchantAuth = apicontractsv1.merchantAuthenticationType()
    merchantAuth.name = apiLoginId
    merchantAuth.transactionKey = transactionKey

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

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

    createtransactionrequest = apicontractsv1.createTransactionRequest()
    createtransactionrequest.merchantAuthentication = merchantAuth
    createtransactionrequest.refId = "728180"

    createtransactionrequest.transactionRequest = transactionrequest
    createtransactioncontroller = createTransactionController(
from authorizenet import apicontractsv1
from authorizenet.apicontrollers import *
from decimal import *

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

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

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


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

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

response = createtransactioncontroller.getresponse()

if (response.messages.resultCode=="Ok"):