def create_subscription(self, credit_card, amount, start,
            days=None, months=None, occurrences=None, trial_amount=None,
            trial_occurrences=None):
        subscription = self.client.factory.create('ARBSubscriptionType')

        # Add the basic amount and payment fields
        amount = Decimal(str(amount)).quantize(Decimal('0.01'))
        subscription.amount = str(amount)
        payment_type = self.client.factory.create('PaymentType')
        credit_card_type = self.client.factory.create('CreditCardType')
        credit_card_type.cardNumber = credit_card.card_number
        credit_card_type.expirationDate = '{0}-{1:0>2}'.format(
            credit_card.exp_year, credit_card.exp_month)
        credit_card_type.cardCode = credit_card.cvv
        payment_type.creditCard = credit_card_type
        subscription.payment = payment_type
        if not (credit_card.first_name and credit_card.last_name):
            raise AuthorizeInvalidError('Subscriptions require first name '
                'and last name to be provided with the credit card.')
        subscription.billTo.firstName = credit_card.first_name
        subscription.billTo.lastName = credit_card.last_name

        # Add the fields for the payment schedule
        if (days and months) or not (days or months):
            raise AuthorizeInvalidError('Please provide either the months or '
                'days argument to define the subscription interval.')
        if days:
            try:
                days = int(days)
                assert days >= 7 and days <= 365
            except (AssertionError, ValueError):
                raise AuthorizeInvalidError('The interval days must be an '
                    'integer value between 7 and 365.')
            subscription.paymentSchedule.interval.unit = \
                self.client.factory.create('ARBSubscriptionUnitEnum').days
            subscription.paymentSchedule.interval.length = days
        elif months:
            try:
                months = int(months)
                assert months >= 1 and months <= 12
            except (AssertionError, ValueError):
                raise AuthorizeInvalidError('The interval months must be an '
                    'integer value between 1 and 12.')
            subscription.paymentSchedule.interval.unit = \
                self.client.factory.create('ARBSubscriptionUnitEnum').months
            subscription.paymentSchedule.interval.length = months
        if start < date.today():
            raise AuthorizeInvalidError('The start date for the subscription '
                'may not be in the past.')
        subscription.paymentSchedule.startDate = start.strftime('%Y-%m-%d')
        if occurrences is None:
            occurrences = 9999 # That's what they say to do in the docs
        subscription.paymentSchedule.totalOccurrences = occurrences

        # If a trial period has been specified, add those fields
        if trial_amount and trial_occurrences:
            subscription.paymentSchedule.trialOccurrences = trial_occurrences
            trial_amount = Decimal(str(trial_amount))
            trial_amount = trial_amount.quantize(Decimal('0.01'))
            subscription.trialAmount = str(trial_amount)
        elif trial_amount or trial_occurrences:
            raise AuthorizeInvalidError('To indicate a trial period, you '
                'must provide both a trial amount and occurrences.')

        # Make the API call to create the subscription
        response = self._make_call('ARBCreateSubscription', subscription)
        return response.subscriptionId
Creates a recurring subscription payment on the CreditCard provided.
dataset/ETHPy150Open drewisme/authorizesauce/authorize/apis/recurring.py/RecurringAPI.create_subscription