def invalidate(self, obj=None): if self.network.startswith('stripe-'): if self.address.startswith('pm_'): stripe.PaymentMethod.detach(self.address) else: try: source = stripe.Source.retrieve(self.address).detach() except stripe.error.InvalidRequestError as e: if "does not appear to be currently attached" in str(e): pass else: raise else: assert source.status == 'consumed' self.update_status(source.status) return elif self.network == 'mango-cc': card = obj or Card.get(self.address) if card.Active: card.Active = False card.save() assert card.Active is False, card.Active if self.mandate: mandate = Mandate.get(self.mandate) if mandate.Status in ('SUBMITTED', 'ACTIVE'): mandate.cancel() self.update_status('canceled')
def test_Mandate_Get(self): mandate = Mandate() mandate.bank_account_id = BaseTestLive.get_johns_account().id mandate.return_url = 'http://test.test' mandate.culture = 'FR' mandate_created = Mandate(**mandate.save()) mandate = Mandate.get(mandate_created.id) self.assertIsNotNone(mandate) self.assertTrue(mandate.id) self.assertEqual(mandate_created.id, mandate.id)
def invalidate(self, obj=None): if self.network == 'mango-cc': card = obj or Card.get(self.address) if card.Active: card.Active = False card.save() assert card.Active is False, card.Active if self.mandate: mandate = Mandate.get(self.mandate) if mandate.Status in ('SUBMITTED', 'ACTIVE'): mandate.cancel() self.update_error('invalidated')
def invalidate(self, obj=None): if self.network.startswith('stripe-'): source = stripe.Source.retrieve(self.address).detach() assert source.status == 'consumed' self.update_status(source.status) return if self.network == 'mango-cc': card = obj or Card.get(self.address) if card.Active: card.Active = False card.save() assert card.Active is False, card.Active if self.mandate: mandate = Mandate.get(self.mandate) if mandate.Status in ('SUBMITTED', 'ACTIVE'): mandate.cancel() self.update_status('canceled')
def invalidate(self, obj=None): if self.network.startswith('stripe-'): if self.address.startswith('pm_'): stripe.PaymentMethod.detach(self.address) else: source = stripe.Source.retrieve(self.address).detach() assert source.status == 'consumed' self.update_status(source.status) return elif self.network == 'mango-cc': card = obj or Card.get(self.address) if card.Active: card.Active = False card.save() assert card.Active is False, card.Active if self.mandate: mandate = Mandate.get(self.mandate) if mandate.Status in ('SUBMITTED', 'ACTIVE'): mandate.cancel() self.update_status('canceled')