Exemplo n.º 1
0
    def setUp(self):
        super(TestPayoutApi, self).setUp()
        self.client = JSONAPITestClient()
        self.plain_user = BlueBottleUserFactory.create()
        self.plain_token = Token.objects.create(user=self.plain_user)
        self.finance_user = BlueBottleUserFactory.create()
        self.token = Token.objects.create(user=self.finance_user)
        financial = Group.objects.get(name='Financial')
        financial.user_set.add(self.finance_user)

        yesterday = now() - timedelta(days=1)
        payout_account = StripePayoutAccountFactory.create(status='verified')
        self.bank_account = ExternalAccountFactory.create(
            connect_account=payout_account)

        self.funding = FundingFactory.create(deadline=yesterday, status='open')

        self.funding.bank_account = self.bank_account
        self.funding.save()

        donations = DonationFactory.create_batch(4,
                                                 activity=self.funding,
                                                 amount=Money(35, 'EUR'),
                                                 status='succeeded')
        for donation in donations:
            StripePaymentFactory.create(status='succeeded', donation=donation)

        self.funding.states.succeed(save=True)
        self.payout = self.funding.payouts.first()
        self.payout_url = reverse('payout-details',
                                  kwargs={'pk': self.payout.id})
Exemplo n.º 2
0
    def setUp(self):
        self.initiative = InitiativeFactory.create()
        self.initiative.states.submit()
        self.initiative.states.approve(save=True)
        self.funding = FundingFactory.create(
            initiative=self.initiative,
            duration=30,
            target=Money(1000, 'EUR')
        )
        BudgetLineFactory.create(activity=self.funding)
        payout_account = StripePayoutAccountFactory.create(reviewed=True, status='verified')
        self.bank_account = ExternalAccountFactory.create(connect_account=payout_account, status='verified')
        self.funding.bank_account = self.bank_account
        self.funding.states.submit()
        self.funding.states.approve(save=True)

        for donation in DonationFactory.create_batch(
                3,
                amount=Money(150, 'EUR'),
                activity=self.funding,
                status='succeeded'):
            StripePaymentFactory.create(donation=donation)

        for donation in DonationFactory.create_batch(
                2,
                amount=Money(200, 'USD'),
                payout_amount=(150, 'EUR'),
                activity=self.funding,
                status='succeeded'):
            StripePaymentFactory.create(donation=donation)

        for donation in DonationFactory.create_batch(
                5,
                amount=Money(100, 'USD'),
                activity=self.funding,
                status='succeeded'):
            StripePaymentFactory.create(donation=donation)

        donation = DonationFactory.create(
            amount=Money(750, 'EUR'),
            activity=self.funding,
            status='succeeded')
        PledgePaymentFactory.create(donation=donation)

        self.donation = donation

        for donation in DonationFactory.create_batch(
                5,
                amount=Money(150, 'EUR'),
                activity=self.funding,
                status='succeeded'):
            StripePaymentFactory.create(donation=donation)

        for donation in DonationFactory.create_batch(
                5,
                amount=Money(100, 'USD'),
                activity=self.funding,
                status='succeeded'):
            StripePaymentFactory.create(donation=donation)
Exemplo n.º 3
0
 def setUp(self):
     super(InitiativeReviewStateMachineTests, self).setUp()
     self.user = BlueBottleUserFactory.create(first_name='Bart', last_name='Lacroix')
     self.initiative = InitiativeFactory.create(
         has_organization=False,
         owner=self.user,
         organization=None
     )
     payout_account = StripePayoutAccountFactory.create(status='verified')
     self.bank_account = ExternalAccountFactory.create(connect_account=payout_account, status='verified')
Exemplo n.º 4
0
 def setUp(self):
     super(PayoutAccountAdminTestCase, self).setUp()
     self.payout_account = StripePayoutAccountFactory.create(
         status='verified')
     self.bank_account = ExternalAccountFactory.create(
         connect_account=self.payout_account, status='verified')
     self.payout_account_url = reverse('admin:funding_payoutaccount_change',
                                       args=(self.payout_account.id, ))
     self.bank_account_url = reverse('admin:funding_bankaccount_change',
                                     args=(self.bank_account.id, ))
     self.client.force_login(self.superuser)
Exemplo n.º 5
0
 def setUp(self):
     self.initiative = InitiativeFactory.create()
     self.initiative.states.submit()
     self.initiative.states.approve(save=True)
     self.funding = FundingFactory.create(initiative=self.initiative,
                                          target=Money(1000, 'EUR'))
     BudgetLineFactory.create(activity=self.funding)
     payout_account = StripePayoutAccountFactory.create(status='verified')
     self.bank_account = ExternalAccountFactory.create(
         connect_account=payout_account, status='verified')
     self.funding.bank_account = self.bank_account
     self.funding.save()
Exemplo n.º 6
0
 def test_country_spec(self):
     account = StripePayoutAccountFactory.create(country='BE')
     self.assertEqual(account.document_spec['id'], 'BE')
     self.assertEqual(account.document_spec['supported_document_types'],
                      [u'passport', u'id-card', u'drivers-license'])
     self.assertEqual(
         account.document_spec['document_types_requiring_back'],
         [u'id-card'])
     account = StripePayoutAccountFactory.create(country='NL')
     self.assertEqual(account.document_spec['id'], 'NL')
     self.assertEqual(account.document_spec['supported_document_types'],
                      [u'passport', u'id-card', u'drivers-license'])
     self.assertEqual(
         account.document_spec['document_types_requiring_back'],
         [u'id-card', u'drivers-license'])
     account = StripePayoutAccountFactory.create(country='XX')
     self.assertEqual(account.document_spec['id'], 'DEFAULT')
     self.assertEqual(account.document_spec['supported_document_types'],
                      [u'passport', u'id-card', u'drivers-license'])
     self.assertEqual(
         account.document_spec['document_types_requiring_back'],
         [u'id-card', u'drivers-license'])
Exemplo n.º 7
0
    def setUp(self):
        super(DonationAdminTestCase, self).setUp()
        self.initiative = InitiativeFactory.create()
        self.initiative.states.submit()
        self.initiative.states.approve(save=True)
        account = StripePayoutAccountFactory.create(status='verified')
        bank_account = ExternalAccountFactory.create(connect_account=account,
                                                     status='verified')

        self.funding = FundingFactory.create(owner=self.superuser,
                                             initiative=self.initiative,
                                             bank_account=bank_account)
        self.admin_url = reverse('admin:funding_donation_changelist')
Exemplo n.º 8
0
    def setUp(self):
        self.initiative = InitiativeFactory.create()
        self.initiative.states.submit()
        self.initiative.states.approve(save=True)
        self.funding = FundingFactory.create(initiative=self.initiative,
                                             duration=30,
                                             target=Money(1000, 'EUR'))
        BudgetLineFactory.create(activity=self.funding)
        payout_account = StripePayoutAccountFactory.create(reviewed=True,
                                                           status='verified')
        self.bank_account = ExternalAccountFactory.create(
            connect_account=payout_account, status='verified')
        self.funding.bank_account = self.bank_account
        self.funding.states.submit()
        self.funding.states.approve(save=True)

        donation = DonationFactory.create(amount=Money(150, 'EUR'),
                                          activity=self.funding,
                                          status='succeeded')

        self.payment = StripePaymentFactory.create(donation=donation)
        super(StripePaymentTransitionsTestCase, self).setUp()
    def setUp(self):
        super(FundingTestCase, self).setUp()
        user = BlueBottleUserFactory.create(first_name='Jean Baptiste')
        self.initiative = InitiativeFactory.create(activity_manager=user)
        self.initiative.states.submit()
        self.initiative.states.approve(save=True)
        payout_account = StripePayoutAccountFactory.create(status='verified')
        bank_account = ExternalAccountFactory.create(
            connect_account=payout_account, status='verified')
        self.funding = FundingFactory.create(owner=user,
                                             initiative=self.initiative,
                                             target=Money(500, 'EUR'),
                                             deadline=now() +
                                             timedelta(weeks=2),
                                             bank_account=bank_account)
        BudgetLineFactory.create(activity=self.funding)
        self.funding.bank_account.reviewed = True

        self.funding.states.submit()
        self.funding.states.approve(save=True)
        BudgetLineFactory.create_batch(4,
                                       activity=self.funding,
                                       amount=Money(125, 'EUR'))
        mail.outbox = []
Exemplo n.º 10
0
    def setUp(self):
        super(StripeConnectWebhookTestCase, self).setUp()
        self.user = BlueBottleUserFactory.create()

        self.connect_account = stripe.Account('some-account-id')

        external_account = stripe.BankAccount('some-bank-token')
        external_account.update(munch.munchify({
            'object': 'bank_account',
            'account_holder_name': 'Jane Austen',
            'account_holder_type': 'individual',
            'bank_name': 'STRIPE TEST BANK',
            'country': 'US',
            'currency': 'usd',
            'fingerprint': '1JWtPxqbdX5Gamtc',
            'last4': '6789',
            'metadata': {
                'order_id': '6735'
            },
            'routing_number': '110000000',
            'status': 'new',
            'account': 'acct_1032D82eZvKYlo2C'
        }))

        external_accounts = stripe.ListObject()
        external_accounts.data = [external_account]
        external_accounts.update({
            'total_count': 1,
        })

        self.connect_account.update(munch.munchify({
            'country': 'NL',
            'requirements': {
                'disabled': False,
                'eventually_due': [],
                'currently_due': [],
                'past_due': [],
                'pending_verification': [],
                'disabled_reason': ''
            },
            'individual': {
                'verification': {
                    'status': 'verified',
                    'document': {
                        "back": None,
                        "details": None,
                        "details_code": None,
                        "front": "file_12345"
                    }
                },
                'requirements': {
                    'eventually_due': [],
                    'currently_due': [],
                    'past_due': [],
                    'pending_verification': [],
                },
            },
            'external_accounts': external_accounts
        }))

        with mock.patch('stripe.Account.create', return_value=self.connect_account):
            self.payout_account = StripePayoutAccountFactory.create(owner=self.user)

        external_account = ExternalAccountFactory.create(connect_account=self.payout_account)

        self.funding = FundingFactory.create(bank_account=external_account)
        self.funding.initiative.states.submit(save=True)
        BudgetLineFactory.create(activity=self.funding)
        self.webhook = reverse('stripe-connect-webhook')