def create_subscription_from_customer_profile(amount, days, profileId,
                                              paymentProfileId,
                                              customerAddressId):

    # 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

    #setting the customer profile details
    profile = apicontractsv1.customerProfileIdType()
    profile.customerProfileId = profileId
    profile.customerPaymentProfileId = paymentProfileId
    profile.customerAddressId = customerAddressId

    # Setting subscription details
    subscription = apicontractsv1.ARBSubscriptionType()
    subscription.name = "Sample Subscription"
    subscription.paymentSchedule = paymentschedule
    subscription.amount = amount
    subscription.trialAmount = Decimal('0.00')
    subscription.profile = profile

    # 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" % 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_subscription_from_customer_profile(amount, days, profileId, paymentProfileId, customerAddressId):

	# 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
	
	#setting the customer profile details
	profile = apicontractsv1.customerProfileIdType()
	profile.customerProfileId = profileId
	profile.customerPaymentProfileId = paymentProfileId
	profile.customerAddressId = customerAddressId
	
	# Setting subscription details
	subscription = apicontractsv1.ARBSubscriptionType()
	subscription.name = "Sample Subscription"
	subscription.paymentSchedule = paymentschedule
	subscription.amount = amount
	subscription.trialAmount = Decimal('0.00')
	subscription.profile = profile
	
	# 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
		print "Message text : %s" % response.messages.message[0].text
		print "Subscription ID : %s" % response.subscriptionId
	else:
		print "ERROR:" 
		print "Message Code : %s" % response.messages.message[0].code
		print "Message text : %s" % response.messages.message[0].text

	return response
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
Ejemplo n.º 4
0
def provider_get_subscriptiondetails_from_customer_profile(profileId):
    # Setting the merchant details
    merchantAuth = apicontractsv1.merchantAuthenticationType()
    merchantAuth.name = get_secret("API_LOGIN_ID")
    merchantAuth.transactionKey = get_secret("API_TRANSACTION_KEY")
    customerProfileId = None
    # setting the customer profile details
    profile = apicontractsv1.customerProfileIdType()

    getCustomerProfile = apicontractsv1.getCustomerProfileRequest()
    getCustomerProfile.merchantAuthentication = merchantAuth
    getCustomerProfile.customerProfileId = str(profileId)
    controller = getCustomerProfileController(getCustomerProfile)
    controller.execute()

    response = controller.getresponse()

    paymentProfileId = None
    if (response.messages.resultCode == "Ok"):
        print(
            "Successfully retrieved a customer with profile id %s and customer id %s"
            % (getCustomerProfile.customerProfileId,
               response.profile.merchantCustomerId))
        if hasattr(response, 'profile') == True:
            profile.customerProfileId = getCustomerProfile.customerProfileId
            customerProfileId = getCustomerProfile.customerProfileId
            if hasattr(response.profile, 'paymentProfiles') == True:
                for paymentProfile in response.profile.paymentProfiles:
                    print("paymentProfile in get_customerprofile is:" %
                          paymentProfile)
                    print("Payment Profile ID %s" %
                          str(paymentProfile.customerPaymentProfileId))
                    paymentProfileId = str(
                        paymentProfile.customerPaymentProfileId)
        else:
            print("Failed to get customer profile information with id %s" %
                  getCustomerProfile.customerProfileId)

    return customerProfileId
Ejemplo n.º 5
0
def provider_create_subscriptiondetails_from_customer_profile(
        amount, days, startdate, profileId):
    # Setting the merchant details
    merchantAuth = apicontractsv1.merchantAuthenticationType()
    merchantAuth.name = get_secret("API_LOGIN_ID")
    merchantAuth.transactionKey = get_secret("API_TRANSACTION_KEY")
    # 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 = startdate
    paymentschedule.totalOccurrences = 999
    paymentschedule.trialOccurrences = 0

    # setting the customer profile details
    profile = apicontractsv1.customerProfileIdType()

    getCustomerProfile = apicontractsv1.getCustomerProfileRequest()
    getCustomerProfile.merchantAuthentication = merchantAuth
    getCustomerProfile.customerProfileId = str(profileId)
    controller = getCustomerProfileController(getCustomerProfile)
    controller.execute()

    response = controller.getresponse()

    paymentProfileId = None
    if (response.messages.resultCode == "Ok"):
        print(
            "Successfully retrieved a customer with profile id %s and customer id %s"
            % (getCustomerProfile.customerProfileId,
               response.profile.merchantCustomerId))
        if hasattr(response, 'profile') == True:
            profile.customerProfileId = getCustomerProfile.customerProfileId
            if hasattr(response.profile, 'paymentProfiles') == True:
                for paymentProfile in response.profile.paymentProfiles:
                    print("paymentProfile in get_customerprofile is:" %
                          paymentProfile)
                    print("Payment Profile ID %s" %
                          str(paymentProfile.customerPaymentProfileId))
                    paymentProfileId = str(
                        paymentProfile.customerPaymentProfileId)
        else:
            print("Failed to get customer profile information with id %s" %
                  getCustomerProfile.customerProfileId)

    profile.customerPaymentProfileId = paymentProfileId
    profile.customerAddressId = None

    # Setting subscription details
    subscription = apicontractsv1.ARBSubscriptionType()
    subscription.name = "Sample Subscription"
    subscription.paymentSchedule = paymentschedule
    subscription.amount = amount
    subscription.trialAmount = Decimal('0.00')
    subscription.profile = profile

    # 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" % 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