def setUp(self):
        account_id = 'some-connect-id'
        external_account_id = 'some-bank-token'
        country = 'NL'

        self.connect_account = stripe.Account(account_id)

        self.connect_account.update({
            'country':
            country,
            'individual':
            munch.munchify({
                'first_name': 'Jhon',
                'last_name': 'Example',
                'email': '*****@*****.**',
            }),
            'requirements':
            munch.munchify({
                'eventually_due': ['external_accounts'],
                'disabled': False
            }),
            'external_accounts':
            stripe.ListObject([])
        })

        with mock.patch('stripe.Account.retrieve',
                        return_value=self.connect_account):
            self.check = StripePayoutAccount(
                owner=BlueBottleUserFactory.create(),
                country=country,
                account_id=account_id)
            self.check.save()

        self.external_account = ExternalAccount(connect_account=self.check,
                                                account_id=external_account_id)

        self.connect_external_account = stripe.BankAccount(external_account_id)

        self.connect_external_account.update({
            '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'
        })

        super(StripeExternalAccountTestCase, self).setUp()
Example #2
0
 def CreateCustomer(self, email, card_token):
     logging.warning('USING FAKE STRIPE')
     cus = stripe.Customer()
     cus.cards = stripe.ListObject()
     if email == '*****@*****.**':
         cus.id = 'doomed_customer'
         cus.cards.data = []
     else:
         cus.id = 'fake_1234'
         cus.cards.data = [self.RetrieveCardData(id)]
     return cus
Example #3
0
def test_collection():
    # collection returns only its data
    customers = stripe.ListObject()
    customers.update({
        "data":
        [stripe.Customer(id="cust_foo"),
         stripe.Customer(id="cust_bar")]
    })
    expected_repr = (
        "ListObject(data=[Customer(id='cust_foo'), Customer(id='cust_bar')])")
    assert repr(customers) == expected_repr
Example #4
0
    def test_refund(self):
        self.payment.states.succeed(save=True)
        payment_intent = stripe.PaymentIntent('some intent id')

        charge = stripe.Charge('charge-id')
        charges = stripe.ListObject()
        charges.data = [charge]

        payment_intent.charges = charges

        with mock.patch('stripe.PaymentIntent.retrieve',
                        return_value=payment_intent):
            with mock.patch('stripe.Charge.refund') as refund_mock:
                self.payment.states.request_refund(save=True)

        self.assertTrue(refund_mock.called_once)
    def test_retrieve_already_in_account(self):
        list_object = stripe.ListObject()
        list_object['data'] = [self.connect_external_account]

        self.connect_account.external_accounts = list_object

        with mock.patch('stripe.Account.retrieve',
                        return_value=self.connect_account):
            with mock.patch('stripe.ListObject.retrieve',
                            return_value=self.connect_external_account
                            ) as retrieve_external_account:
                self.assertEqual(self.external_account.account.id,
                                 self.connect_external_account.id)
                self.assertEqual(self.external_account.account.last4,
                                 self.connect_external_account.last4)

                self.assertEqual(retrieve_external_account.call_count, 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')