Skip to content

Commit

Permalink
Merge pull request #507 from ticosax/fix-charge-capture
Browse files Browse the repository at this point in the history
Fix Capture charges with connect
  • Loading branch information
paltman committed Nov 23, 2017
2 parents e107ede + ffb0ce4 commit 041eab5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pinax/stripe/actions/charges.py
Expand Up @@ -36,7 +36,10 @@ def capture(charge, amount=None, idempotency_key=None):
amount if amount else charge.amount,
charge.currency
)
stripe_charge = stripe.Charge(charge.stripe_id).capture(
stripe_charge = stripe.Charge(
charge.stripe_id,
stripe_account=charge.stripe_account_stripe_id,
).capture(
amount=amount,
idempotency_key=idempotency_key,
expand=["balance_transaction"],
Expand Down
9 changes: 9 additions & 0 deletions pinax/stripe/tests/test_actions.py
Expand Up @@ -276,6 +276,15 @@ def test_capture_with_amount(self, CaptureMock, SyncMock):
self.assertEquals(kwargs["idempotency_key"], "IDEM")
self.assertTrue(SyncMock.called)

@patch("pinax.stripe.actions.charges.sync_charge_from_stripe_data")
@patch("stripe.Charge.capture")
def test_capture_with_connect(self, CaptureMock, SyncMock):
account = Account(stripe_id="acc_001")
customer = Customer(stripe_id="cus_001", stripe_account=account)
charges.capture(Charge(stripe_id="ch_A", amount=decimal.Decimal("100"), currency="usd", customer=customer))
self.assertTrue(CaptureMock.called)
self.assertTrue(SyncMock.called)

@patch("pinax.stripe.actions.charges.sync_charge")
def test_update_availability(self, SyncMock):
Charge.objects.create(customer=self.customer, amount=decimal.Decimal("100"), currency="usd", paid=True, captured=True, available=False, refunded=False)
Expand Down

0 comments on commit 041eab5

Please sign in to comment.