(self, instance, *, stripe_account)
Syncs Bank Accounts and Cards for both customers and all external accounts
Syncs Bank Accounts and Cards for both customers and all external accounts
Syncs Bank Accounts and Cards for both customers and all external accounts
def sync_bank_accounts_and_cards(self, instance, *, stripe_account):
        """
        Syncs Bank Accounts and Cards for both customers and all external accounts
        """
        type = getattr(instance, "type", None)
        kwargs = {
            "id": instance.id,
            "api_key": djstripe_settings.STRIPE_SECRET_KEY,
            "stripe_account": stripe_account,
        }

        if type in (enums.AccountType.custom, enums.AccountType.express) and isinstance(
            instance, models.Account
        ):

            # fetch all Card and BankAccount objects associated with the instance
            items = models.Account.stripe_class.list_external_accounts(
                **kwargs
            ).auto_paging_iter()

            self.start_sync(items, instance)
        elif isinstance(instance, models.Customer):
            for object in ("card", "bank_account"):
                kwargs["object"] = object

                # fetch all Card and BankAccount objects associated with the instance
                items = models.Customer.stripe_class.list_sources(
                    **kwargs
                ).auto_paging_iter()

                self.start_sync(items, instance)
def sync_bank_accounts_and_cards ( self , instance , * , stripe_account ) : type = getattr ( instance , "type" , None ) kwargs = { "id" : instance . id , "api_key" : djstripe_settings . STRIPE_SECRET_KEY , "stripe_account" : stripe_account , } if type in ( enums . AccountType . custom , enums . AccountType . express ) and isinstance ( instance , models . Account ) : # fetch all Card and BankAccount objects associated with the instance items = models . Account . stripe_class . list_external_accounts ( * * kwargs ) . auto_paging_iter ( ) self . start_sync ( items , instance ) elif isinstance ( instance , models . Customer ) : for object in ( "card" , "bank_account" ) : kwargs [ "object" ] = object # fetch all Card and BankAccount objects associated with the instance items = models . Customer . stripe_class . list_sources ( * * kwargs ) . auto_paging_iter ( ) self . start_sync ( items , instance )