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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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