From da9aef5c65d16c68db452ad09c75d077615d0f9a Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Sat, 20 Dec 2025 13:21:51 +0100 Subject: [PATCH] adding braintree --- rowers/braintreestuff.py | 16 ++++++++++++++++ rowers/tests/testdata/testdata.tcx.gz | Bin 3989 -> 3989 bytes 2 files changed, 16 insertions(+) diff --git a/rowers/braintreestuff.py b/rowers/braintreestuff.py index 92a10f28..b08dee2c 100644 --- a/rowers/braintreestuff.py +++ b/rowers/braintreestuff.py @@ -619,3 +619,19 @@ def get_transactions(start_date, end_date): # pragma: no cover def mocktest(rower): # pragma: no cover return '5' + +def cancel_braintree_subscriptions(gateway): + """ + Cancel all Braintree subscriptions for Rowers, ensuring they run to the end of the current billing period. + """ + rowers = Rower.objects.exclude(subscription_id__isnull=True) + for rower in rowers: + subscription_id = rower.subscription_id + try: + result = gateway.subscription.cancel(subscription_id) + if result.is_success: + print(f"✅ Subscription {subscription_id} for Rower {rower.id} will not renew.") + else: + print(f"❌ Failed to cancel subscription {subscription_id}: {result.message}") + except Exception as e: + print(f"🚨 Error processing subscription {subscription_id}: {e}") diff --git a/rowers/tests/testdata/testdata.tcx.gz b/rowers/tests/testdata/testdata.tcx.gz index 5cf0703cb272a8b8956755a0c6a78807e5a2957f..a3ba1af581198d9007d1bb0452bee681985a3c3a 100644 GIT binary patch delta 16 XcmbO#KUJPxzMF$1Z<5 delta 16 XcmbO#KUJPxzMF&Ne6Yht_C9_9DQE=Y