From cd3d7280ef4680e9f9665c9b2ffa7518c481b423 Mon Sep 17 00:00:00 2001 From: Erick Navarro Date: Thu, 21 Sep 2023 12:01:17 -0600 Subject: [PATCH 1/5] Update subscription methods in README Updated the 'Create Subscription' and 'Cancel Subscription' in the README. Changed trial_days to trial_end_date in 'Create Subscription' for better control of trial periods. Also added retrieval of a consumer subscription and how to change a subscription card for better clarity and completeness. --- README.md | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5ee32e3..e302f57 100644 --- a/README.md +++ b/README.md @@ -214,7 +214,13 @@ account = customer.back_accounts.retrieve("bsbg7igxh3yukpu8t2q4") Add subscription to customer ```python -customer.subscriptions.create(plan_id="pbkliysxavp8bvvp8f0k", trial_days="5", card_id="kvxvccpsesm4pwmtgnjb") +customer.subscriptions.create(plan_id="pbkliysxavp8bvvp8f0k", trial_end_date="2023/12/31", card_id="kvxvccpsesm4pwmtgnjb") +``` + +Get customer subscriptions + +```python +customer.subscriptions.retrieve("pbkliysxavp8bvvp8f0k") ``` Cancel subscription @@ -234,7 +240,16 @@ Update subscription ```python subscription = customer.subscriptions.all()[0] -subscription.cancel_at_end_period = True +subscription.cancel_at_period_end = True +subscription.save() +``` + +Change subscription card by token + +```python +subscription = customer.subscriptions.all()[0] +subscription.card_id = "ppldmckf6ls94skdihkd" +subscription.card = None subscription.save() ``` From 8fe205c2bad324da9b520cb7d3f81ac64cf86fba Mon Sep 17 00:00:00 2001 From: Erick Navarro Date: Wed, 7 Aug 2024 12:55:00 -0600 Subject: [PATCH 2/5] Comment use_2to3 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 9db965c..992d6ee 100644 --- a/setup.py +++ b/setup.py @@ -43,5 +43,5 @@ package_data={'openpay': ['data/ca-certificates.crt', '../VERSION']}, install_requires=install_requires, test_suite='openpay.test.all', - use_2to3=True, + # use_2to3=True, ) From 305eb6e1fdabdbd93060f57ec41f3f6515a3bd6d Mon Sep 17 00:00:00 2001 From: Erick Navarro Date: Wed, 7 Aug 2024 13:24:06 -0600 Subject: [PATCH 3/5] update util.py --- openpay/util.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openpay/util.py b/openpay/util.py index 40de5d8..38d7fd0 100644 --- a/openpay/util.py +++ b/openpay/util.py @@ -2,6 +2,8 @@ import logging import sys +from past.builtins import unicode + logger = logging.getLogger('stripe') __all__ = ['utf8'] From 91e49a9949d8f50b168cb05a249128c7438b030f Mon Sep 17 00:00:00 2001 From: Erick Navarro Date: Wed, 7 Aug 2024 13:42:19 -0600 Subject: [PATCH 4/5] Added six package --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 5feed29..3cba66c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,7 @@ before_install: install: - pip install pycurl flake8 - pip install mock + - pip install six - python setup.py install script: - python -W always setup.py test From 761755f38bba7dc6951f7ef9e6d854ae12474084 Mon Sep 17 00:00:00 2001 From: Erick Navarro Date: Wed, 7 Aug 2024 13:42:48 -0600 Subject: [PATCH 5/5] import six package and update fix --- openpay/util.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/openpay/util.py b/openpay/util.py index 38d7fd0..c3a8d2c 100644 --- a/openpay/util.py +++ b/openpay/util.py @@ -1,8 +1,7 @@ - import logging import sys -from past.builtins import unicode +import six logger = logging.getLogger('stripe') @@ -10,7 +9,7 @@ def utf8(value): - if isinstance(value, unicode) and sys.version_info < (3, 0): + if isinstance(value, six.text_type) and sys.version_info < (3, 0): return value.encode('utf-8') else: return value