Skip to content

Commit

Permalink
Merge pull request #486 from blueyed/fix-sync_subscription_from_strip…
Browse files Browse the repository at this point in the history
…e_data

Fix subscriptions.create for Connect
  • Loading branch information
paltman committed Nov 8, 2017
2 parents 20666b6 + 3578682 commit 9ee8f6c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions pinax/stripe/actions/subscriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def create(customer, plan, quantity=None, trial_days=None, token=None, coupon=No
if token:
subscription_params["source"] = token

subscription_params["stripe_account"] = customer.stripe_account_stripe_id
subscription_params["customer"] = customer.stripe_id
subscription_params["plan"] = plan
subscription_params["quantity"] = quantity
Expand Down
30 changes: 30 additions & 0 deletions pinax/stripe/tests/test_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,36 @@ def test_subscription_create_token(self, SubscriptionCreateMock, CustomerMock):
_, kwargs = SubscriptionCreateMock.call_args
self.assertEquals(kwargs["source"], "token")

@patch("stripe.Subscription.create")
def test_subscription_create_with_connect(self, SubscriptionCreateMock):
SubscriptionCreateMock.return_value = {
"object": "subscription",
"id": "sub_XX",
"application_fee_percent": None,
"cancel_at_period_end": False,
"canceled_at": None,
"current_period_start": 1509978774,
"current_period_end": 1512570774,
"ended_at": None,
"quantity": 1,
"start": 1509978774,
"status": "active",
"trial_start": None,
"trial_end": None,
"plan": {
"id": self.plan.stripe_id,
}}
subscriptions.create(self.connected_customer, self.plan.stripe_id)
SubscriptionCreateMock.assert_called_once_with(
coupon=None,
customer=self.connected_customer.stripe_id,
plan="the-plan",
quantity=4,
stripe_account="acct_xx",
tax_percent=None)
subscription = Subscription.objects.get()
self.assertEqual(subscription.customer, self.connected_customer)

@patch("stripe.Subscription.retrieve")
@patch("stripe.Subscription.create")
def test_retrieve_subscription_with_connect(self, CreateMock, RetrieveMock):
Expand Down

0 comments on commit 9ee8f6c

Please sign in to comment.