Exemple #1
0
 def retrieve(self):
     """Retrieves an existing Plan
     """
     _initialize_stripe(live_mode=self.live_mode)
     stripe_plan = safe_stripe_call(stripe.Plan.retrieve,
                                    *(self.stripe_id, ))
     return stripe_plan
Exemple #2
0
 def get_charges(self):
     _initialize_stripe(live_mode=self.live_mode)
     charges = safe_stripe_call(stripe.Charge.all, **{
         'customer': self.stripe_id,
     })
     charges = charges.get('data')
     return charges
Exemple #3
0
    def retrieve(self):
        """Retrieves an existing customer

        https://stripe.com/docs/api/python#retrieve_customer
        """
        _initialize_stripe(live_mode=self.live_mode)
        stripe_customer = safe_stripe_call(stripe.Customer.retrieve,
                                           *(self.stripe_id, ))
        return stripe_customer
Exemple #4
0
 def get_charges(self):
     _initialize_stripe(live_mode=self.live_mode)
     charges = safe_stripe_call(
         stripe.Charge.all,
         **{
             'customer' : self.stripe_id,
         }
     )
     charges = charges.get('data')
     return charges
Exemple #5
0
    def create_invoice(self):
        """Create an Invoice for this Customer to pay any outstanding invoice items such as when upgrading plans

        https://stripe.com/docs/api#create_invoice
        """
        _initialize_stripe(live_mode=self.live_mode)
        invoice = safe_stripe_call(stripe.Invoice.create, **{
            'customer': self.stripe_id,
        })
        return invoice
Exemple #6
0
 def retrieve(self):
     """Retrieves an existing Plan
     """
     _initialize_stripe(live_mode=self.live_mode)
     stripe_plan = safe_stripe_call(
         stripe.Plan.retrieve,
         *(
             self.stripe_id,
         )
     )
     return stripe_plan
Exemple #7
0
 def charge(self, amount=0, currency=DEFAULT_STRIPE_CURRENCY):
     """Charges a Customer
     """
     _initialize_stripe(live_mode=self.live_mode)
     ch = safe_stripe_call(
         stripe.Charge.create,
         **{
             'amount' : amount,
             'currency' : currency,
             'customer' : self.stripe_id,
         }
     )
     return ch
Exemple #8
0
    def retrieve(self):
        """Retrieves an existing customer

        https://stripe.com/docs/api/python#retrieve_customer
        """
        _initialize_stripe(live_mode=self.live_mode)
        stripe_customer = safe_stripe_call(
            stripe.Customer.retrieve,
            *(
                self.stripe_id,
            )
        )
        return stripe_customer
Exemple #9
0
    def create_invoice(self):
        """Create an Invoice for this Customer to pay any outstanding invoice items such as when upgrading plans

        https://stripe.com/docs/api#create_invoice
        """
        _initialize_stripe(live_mode=self.live_mode)
        invoice = safe_stripe_call(
            stripe.Invoice.create,
            **{
                'customer' : self.stripe_id,
            }
        )
        return invoice
Exemple #10
0
    def create(self):
        """Tries to create a product

        Will fail if product with the same Stripe id already exists
        """
        _initialize_stripe(live_mode=self.live_mode)
        stripe_product = safe_stripe_call(
            stripe.Product.create, **{
                'id': self.stripe_id,
                'name': self.name,
                'type': StripeProductType(self.product_type).name,
                'active': self.active,
                'statement_descriptor': self.statement_descriptor,
            })
        return stripe_product
Exemple #11
0
 def charge(self, amount=0, currency=DEFAULT_STRIPE_CURRENCY, metadata=None):
     """Charges a Customer
     """
     if metadata is None:
         metadata = {}
     _initialize_stripe(live_mode=self.live_mode)
     ch = safe_stripe_call(
         stripe.Charge.create,
         **{
             'amount' : amount,
             'currency' : currency,
             'customer' : self.stripe_id,
             'metadata' : metadata
         }
     )
     return ch
Exemple #12
0
 def charge(self, amount=0, currency=DEFAULT_STRIPE_CURRENCY, metadata=None):
     """Charges a Customer
     """
     if metadata is None:
         metadata = {}
     _initialize_stripe(live_mode=self.live_mode)
     ch = safe_stripe_call(
         stripe.Charge.create,
         **{
             'amount' : amount,
             'currency' : currency,
             'customer' : self.stripe_id,
             'metadata' : metadata
         }
     )
     return ch
Exemple #13
0
    def create(self):
        """Tries to create a product

        Will fail if product with the same Stripe id already exists
        """
        _initialize_stripe(live_mode=self.live_mode)
        stripe_product = safe_stripe_call(
            stripe.Product.create,
            **{
                'id' : self.stripe_id,
                'name' : self.name,
                'type' : StripeProductType(self.product_type).name,
                'active' : self.active,
                'statement_descriptor' : self.statement_descriptor,
            }
        )
        return stripe_product
Exemple #14
0
    def create(self):
        """Tries to create a plan

        Will fail if plan with the same Stripe id already exists
        """
        _initialize_stripe(live_mode=self.live_mode)
        stripe_plan = safe_stripe_call(
            stripe.Plan.create, **{
                'id': self.stripe_id,
                'amount': self.amount,
                'currency': self.currency,
                'interval': StripePlanInterval(self.interval).name,
                'interval_count': self.interval_count,
                'name': self.name,
                'trial_period_days': self.trial_period_days,
                'statement_description': self.statement_description,
            })
        return stripe_plan
Exemple #15
0
 def _create_recipient(self):
     stripe = _initialize_stripe()
     recipient = safe_stripe_call(
         stripe.Recipient.create, **{
             'name': 'John Doe',
             'type': 'individual',
         })
     self.assertEqual(STRIPE_ID_PREFIX_RECIPIENT,
                      recipient.id[:len(STRIPE_ID_PREFIX_RECIPIENT)])
     return recipient
Exemple #16
0
 def _create_recipient(self):
     stripe = _initialize_stripe()
     recipient = safe_stripe_call(
         stripe.Recipient.create,
         **{
             'name' : 'John Doe',
             'type' : 'individual',
         }
     )
     self.assertEqual(STRIPE_ID_PREFIX_RECIPIENT, recipient.id[:len(STRIPE_ID_PREFIX_RECIPIENT)])
     return recipient
Exemple #17
0
    def create(self):
        """Tries to create a plan

        Will fail if plan with the same Stripe id already exists
        """
        _initialize_stripe(live_mode=self.live_mode)
        stripe_plan = safe_stripe_call(
            stripe.Plan.create,
            **{
                'id' : self.stripe_id,
                'amount' : self.amount,
                'currency' : self.currency,
                'interval' : StripePlanInterval(self.interval).name,
                'interval_count' : self.interval_count,
                'name' : self.name,
                'trial_period_days' : self.trial_period_days,
                'statement_description' : self.statement_description,
            }
        )
        return stripe_plan