コード例 #1
0
 def setUp(self):
     super(StripeSourcePaymentAdminTestCase, self).setUp()
     account = generate_stripe_payout_account()
     bank_account = ExternalAccountFactory.create(connect_account=account)
     funding = FundingFactory.create(bank_account=bank_account)
     self.client.force_login(self.superuser)
     self.donation = DonationFactory(
         amount=Money(100, 'EUR'),
         activity=funding
     )
     with patch('stripe.Source.modify'):
         self.payment = StripeSourcePaymentFactory.create(
             source_token='source-token',
             charge_token='charge-token',
             donation=self.donation
         )
     self.admin_url = reverse('admin:funding_stripe_stripesourcepayment_change', args=(self.payment.id,))
     self.check_status_url = reverse('admin:funding_payment_check', args=(self.payment.id,))
     self.source = stripe.Source('source-token')
     self.source.update({
         'amount': 10000,
         'currency': 'EUR',
         'status': 'charged'
     })
     self.charge = stripe.Charge('charge-token')
     self.charge.update({
         'status': 'succeeded',
         'refunded': None,
         'dispute': None
     })
コード例 #2
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})
コード例 #3
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)
コード例 #4
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')
コード例 #5
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)
コード例 #6
0
 def setUp(self):
     super(IntentWebhookTestCase, self).setUp()
     StripePaymentProvider.objects.all().delete()
     StripePaymentProviderFactory.create()
     self.initiative = InitiativeFactory.create()
     self.initiative.states.submit()
     self.initiative.states.approve(save=True)
     self.bank_account = ExternalAccountFactory.create()
     self.funding = FundingFactory.create(initiative=self.initiative, bank_account=self.bank_account)
     self.donation = DonationFactory.create(activity=self.funding)
     self.intent = StripePaymentIntentFactory.create(donation=self.donation)
     self.webhook = reverse('stripe-intent-webhook')
コード例 #7
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()
コード例 #8
0
    def setUp(self):
        account_id = 'some-connect-id'
        self.user = BlueBottleUserFactory.create()
        self.account = StripePayoutAccount(owner=self.user,
                                           country='NL',
                                           account_id=account_id)
        self.stripe_account = stripe.Account(account_id)
        self.stripe_account.update({
            'country':
            'NL',
            'individual':
            munch.munchify({
                'first_name':
                'Jhon',
                'last_name':
                'Example',
                'email':
                '*****@*****.**',
                'verification': {
                    'status': 'verified',
                },
                'requirements':
                munch.munchify({
                    'eventually_due': [
                        'external_accounts',
                        'individual.verification.document',
                        'document_type',
                    ]
                }),
            }),
            'requirements':
            munch.munchify({
                'eventually_due': [
                    'external_accounts',
                    'individual.verification.document.front',
                    'document_type',
                ],
                'disabled':
                False
            }),
            'external_accounts':
            munch.munchify({
                'total_count': 0,
                'data': []
            })
        })
        with patch('stripe.Account.retrieve',
                   return_value=self.stripe_account):
            self.account.save()

        self.bank_account = ExternalAccountFactory.create(
            connect_account=self.account)
コード例 #9
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')
コード例 #10
0
    def setUp(self):
        super(SourcePaymentWebhookTestCase, self).setUp()
        StripePaymentProvider.objects.all().delete()
        StripePaymentProviderFactory.create()

        self.initiative = InitiativeFactory.create()
        self.initiative.states.submit()
        self.initiative.states.approve(save=True)

        self.bank_account = ExternalAccountFactory.create()
        self.funding = FundingFactory.create(initiative=self.initiative,
                                             bank_account=self.bank_account)
        self.donation = DonationFactory.create(activity=self.funding)

        with mock.patch('stripe.Source.modify'):
            self.payment = StripeSourcePaymentFactory.create(
                source_token='some-source-id', donation=self.donation)

        self.webhook = reverse('stripe-source-webhook')
コード例 #11
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()
コード例 #12
0
    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 = []
コード例 #13
0
ファイル: test_states.py プロジェクト: jayvdb/bluebottle
 def test_2nd_bank_verifies_right_away(self):
     self.account.states.verify(save=True)
     new_bank_account = ExternalAccountFactory.create(connect_account=self.account)
     new_bank_account.refresh_from_db()
     self.assertEqual(new_bank_account.status, 'verified')
コード例 #14
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')