braintree / braintree_python

Braintree Python library
https://developer.paypal.com/braintree/docs/start/overview
MIT License
242 stars 116 forks source link

braintree_subscription first_billing_date not in GMT timezone #121

Closed anu-kailash closed 4 years ago

anu-kailash commented 4 years ago

General information

Issue description

We create a new subscription with an yearly plan and ensure that the subscription created date matches today's date. However, when we compare the first billing date with today's date + 1 year, it does not match until the time is past 5:00AM GMT. If the same test is run immediately after 5:00AM GMT it passes.

Looks like the first billing date is calculated in a different timezone (GMT - 5) while the created time is based on GMT.

test snippet=============================================================

    def test_create_subscription_for_prepaid_account_no_date(self):
        # given
        prepaid_account = create_bt_prepaid_account_with_card_on_plan(
            self.session, subscription_plan_id=self.TEST_PLAN)

        # when
        subscription = self.braintree_subscription.create(
            prepaid_account,
            None)

        # then
        braintree_subs = braintree.Subscription.find(
            subscription.subscription_id
        )
        self.assertEqual(braintree_subs.plan_id, self.TEST_PLAN)
        self.assertEqual(braintree_subs.created_at.date(),
                         datetime.date.today())
        **self.assertEqual(
            braintree_subs.first_billing_date,
            datetime.date.today() + relativedelta(years=1))**

======================================================================

FAIL: bnkpcore.test.services.subscriptions.braintree:BraintreeSubscriptionTest.test_create_subscription_for_prepaid_account_no_date
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/src/bnkpcore/test/services/subscriptions/braintree.py", line 53, in test_create_subscription_for_prepaid_account_no_date
    datetime.date.today() + relativedelta(months=12))
AssertionError: datetime.date(2021, 3, 19) != datetime.date(2021, 3, 20)

TEST_PLAN used ========================================================

Plan ID yearly Name yearly Description Price £10.00 GBP

Trial Period

Duration 12 months

Billing Details

Billing Cycle Every 12 Month(s) Billing Start Immediately after trial Number of Billing Cycles Never Expires

hollabaq86 commented 4 years ago

👋 @anu-kailash, please contact Support referencing this issue and your merchant ID. They will partner with the team that owns our recurring billing API to investigate this behavior.