def get_customer_payment_profile(customerProfileId, customerPaymentProfileId):

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

	getCustomerPaymentProfile = apicontractsv1.getCustomerPaymentProfileRequest()
	getCustomerPaymentProfile.merchantAuthentication = merchantAuth
	getCustomerPaymentProfile.customerProfileId = customerProfileId
	getCustomerPaymentProfile.customerPaymentProfileId = customerPaymentProfileId

	controller = getCustomerPaymentProfileController(getCustomerPaymentProfile)
	controller.execute()

	response = controller.getresponse()

	if (response.messages.resultCode=="Ok"):
		print("Successfully retrieved a payment profile with profile id %s and customer id %s" % (getCustomerPaymentProfile.customerProfileId, getCustomerPaymentProfile.customerProfileId))
		if hasattr(response, 'paymentProfile') == True:
			if hasattr(response.paymentProfile, 'subscriptionIds') == True:
				if hasattr(response.paymentProfile.subscriptionIds, 'subscriptionId') == True:
					print("list of subscriptionid:")
					for subscriptionid in response.paymentProfile.subscriptionIds.subscriptionId:
						print(subscriptionid)
	else:
		print("response code: %s" % response.messages.resultCode)
		print("Failed to get payment profile information with id %s" % getCustomerPaymentProfile.customerPaymentProfileId)

	return response
Exemple #2
0
def get_customer_payment_profile(customerProfileId, customerPaymentProfileId):

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

    getCustomerPaymentProfile = apicontractsv1.getCustomerPaymentProfileRequest(
    )
    getCustomerPaymentProfile.merchantAuthentication = merchantAuth
    getCustomerPaymentProfile.customerProfileId = customerProfileId
    getCustomerPaymentProfile.customerPaymentProfileId = customerPaymentProfileId

    controller = getCustomerPaymentProfileController(getCustomerPaymentProfile)
    controller.execute()

    response = controller.getresponse()

    if (response.messages.resultCode == "Ok"):
        print "Successfully retrieved a payment profile with profile id %s and customer id %s" % (
            getCustomerPaymentProfile.customerProfileId,
            getCustomerPaymentProfile.customerProfileId)
        if hasattr(response, 'paymentProfile') == True:
            if hasattr(response.paymentProfile, 'subscriptionIds') == True:
                if hasattr(response.paymentProfile.subscriptionIds,
                           'subscriptionId') == True:
                    print "list of subscriptionid:"
                    for subscriptionid in response.paymentProfile.subscriptionIds.subscriptionId:
                        print subscriptionid
    else:
        print "response code: %s" % response.messages.resultCode
        print "Failed to get payment profile information with id %s" % getCustomerPaymentProfile.customerPaymentProfileId

    return response
Exemple #3
0
    def client_token(self, customer):
        """ Return the client token for a given customer.

        :param customer: A Silver customer
        :returns customer_payment_profile_id:
        """

        customer_data = CustomerData.objects.get_or_create(
            customer=customer)[0]

        customer_id = customer_data.get('id')
        customer_profile_id = customer_data.get('profile_id')
        customer_payment_profile_id = customer_data.get('payment_id')

        if customer_payment_profile_id is not None:
            return customer_payment_profile_id

        getCustomerPaymentProfile = apicontractsv1.getCustomerPaymentProfileRequest(
        )
        getCustomerPaymentProfile.merchantAuthentication = self.merchantAuth
        getCustomerPaymentProfile.customerProfileId = customer_profile_id
        getCustomerPaymentProfile.customerPaymentProfileId = customer_payment_profile_id

        controller = getCustomerPaymentProfileController(
            getCustomerPaymentProfile)
        controller.execute()

        response = controller.getresponse()

        resp_okay = response.messages.resultCode == apicontractsv1.messageTypeEnum.Ok

        if resp_okay:
            self._update_customer(
                customer, {
                    'id': customer_id,
                    'payment_id': str(response.customerPaymentProfileId)
                })
            # TODO: update token on user profile
            return response.customerPaymentProfileId
        else:
            logger.warning('Couldn\'t obtain Authorize.net client_token %s', {
                'customer_id': customer_authorizenet_id,
                'exception': str(e)
            })
from authorizenet import apicontractsv1
from authorizenet.apicontrollers import *

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

getCustomerPaymentProfile = apicontractsv1.getCustomerPaymentProfileRequest()
getCustomerPaymentProfile.merchantAuthentication = merchantAuth
getCustomerPaymentProfile.customerProfileId = "36731856"
getCustomerPaymentProfile.customerPaymentProfileId = "33211899"

getCustomerPaymentProfileController = getCustomerPaymentProfileController(getCustomerPaymentProfile)
getCustomerPaymentProfileController.execute()

response = getCustomerPaymentProfileController.getresponse()

if (response.messages.resultCode=="Ok"):
	print "Successfully retrieved a payment profile with profile id %s and customer id %s" % (getCustomerPaymentProfile.customerProfileId, getCustomerPaymentProfile.customerProfileId)	
else:
	print "response code: %s" % response.messages.resultCode
	print "Failed to get payment profile information with id %s" % getCustomerPaymentProfile.customerPaymentProfileId
from authorizenet import apicontractsv1
from authorizenet.apicontrollers import *

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

getCustomerPaymentProfile = apicontractsv1.getCustomerPaymentProfileRequest()
getCustomerPaymentProfile.merchantAuthentication = merchantAuth
getCustomerPaymentProfile.customerProfileId = "36731856"
getCustomerPaymentProfile.customerPaymentProfileId = "33211899"

getCustomerPaymentProfileController = getCustomerPaymentProfileController(
    getCustomerPaymentProfile)
getCustomerPaymentProfileController.execute()

response = getCustomerPaymentProfileController.getresponse()

if (response.messages.resultCode == "Ok"):
    print "Successfully retrieved a payment profile with profile id %s and customer id %s" % (
        getCustomerPaymentProfile.customerProfileId,
        getCustomerPaymentProfile.customerProfileId)
else:
    print "response code: %s" % response.messages.resultCode
    print "Failed to get payment profile information with id %s" % getCustomerPaymentProfile.customerPaymentProfileId