(self)
Detach the source from its customer.
Detach the source from its customer.
Detach the source from its customer .
def detach(self) -> bool:
        """
        Detach the source from its customer.
        """

        # First, wipe default source on all customers that use this.
        Customer.objects.filter(default_source=self.id).update(default_source=None)

        try:
            # TODO - we could use the return value of sync_from_stripe_data
            #  or call its internals - self._sync/_attach_objects_hook etc here
            #  to update `self` at this point?
            self.sync_from_stripe_data(self.api_retrieve().detach())
            return True
        except (InvalidRequestError, NotImplementedError):
            # The source was already detached. Resyncing.
            # NotImplementedError is an artifact of stripe-python<2.0
            # https://github.com/stripe/stripe-python/issues/376
            self.sync_from_stripe_data(self.api_retrieve())
            return False
def detach ( self ) -> bool : # First, wipe default source on all customers that use this. Customer . objects . filter ( default_source = self . id ) . update ( default_source = None ) try : # TODO - we could use the return value of sync_from_stripe_data #  or call its internals - self._sync/_attach_objects_hook etc here #  to update `self` at this point? self . sync_from_stripe_data ( self . api_retrieve ( ) . detach ( ) ) return True except ( InvalidRequestError , NotImplementedError ) : # The source was already detached. Resyncing. # NotImplementedError is an artifact of stripe-python<2.0 # https://github.com/stripe/stripe-python/issues/376 self . sync_from_stripe_data ( self . api_retrieve ( ) ) return False