-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
upgrade and add dj stripe #40
base: master
Are you sure you want to change the base?
Conversation
README.md
Outdated
@@ -181,3 +181,48 @@ class TestExceptionsViewSet(APIView): | |||
| command | description| | |||
| :--- | :----: | | |||
| `upload_file <source> <destination>` | uses `django-storages` settings to upload a file | | |||
|
|||
### djstripe |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
### djstripe | |
### Payment helpers ([dj-stripe](https://dj-stripe.dev/)) |
README.md
Outdated
#### Create and charge a payment intent | ||
```py | ||
from ckc.stripe.utils.payments import create_payment_intent, confirm_payment_intent | ||
#for manual control |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#for manual control | |
# for manual control |
README.md
Outdated
@@ -181,3 +181,48 @@ class TestExceptionsViewSet(APIView): | |||
| command | description| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the ./manage.py
commands are meant to go at the end of the README btw
# 'customer', | ||
# 'stripe_id', | ||
# 'card_brand', | ||
# 'card_last4', | ||
# 'card_exp_month', | ||
# 'card_exp_year', | ||
# 'is_default', | ||
# 'created', | ||
# 'modified', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pull, or useful?
ckc/stripe/utils/payments.py
Outdated
|
||
) | ||
except stripe.error.CardError: | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oo, should we really let this pass? I think we should let this be raised, and handle it with ValidationError
wrappers at a certain point?
try:
create_payment_intent(...)
except stripe.error.CardError:
raise ValidationError("There was a problem with your card? Please try a different card.")
ckc/stripe/utils/subscriptions.py
Outdated
@@ -0,0 +1,39 @@ | |||
import stripe |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually think we don't need this utils/
subdir? payments.py
, and subscriptions.py
could live right in ckc.stripe
ckc/stripe/utils/subscriptions.py
Outdated
@returns stripe.Price | ||
|
||
""" | ||
stripe_product = stripe.Product.create( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any error handling needed in this function? we can have some fun soon trying to cause all kinds of problems and handle them nicely .. then never have to handle them again!
setup.cfg
Outdated
@@ -60,3 +61,7 @@ license_files = | |||
python_requires = >= 3.6 | |||
packages = find: | |||
zip_safe: False | |||
|
|||
[options.extras_require] | |||
stripe = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should make this optional, lots of other projects don't use stripe
So we can install django-ckc
without also installing stripe, unless we do django-ckc[stripe]
or something
def setUp(self): | ||
self.user = User.objects.create_user(username="test", password="test") | ||
self.client.force_authenticate(user=self.user) | ||
return super().setUp() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's do a setUpTestData
(runs only once for a class, re-used between functions)
Can throw customer, created = Customer.get_or_create(subscriber=self.user)
in it as well
example:
@classmethod
def setUpTestData(cls):
cls.user = User.objects.create_user(username="test", password="test")
cls.client.force_authenticate(user=self.user)
cls.customer, cls.created = Customer.get_or_create(subscriber=cls.user)
if cls.client
isn't available, you may have to do that force_authenticate
step in the setUp
function instead
Template
This is a template. While not all sections are necessary, depending on the size and complexity of the PR,
more information is better.
@ mention of reviewers
...
A brief description of the purpose of the changes contained in this PR.
...
Known issues to be addressed in a separate PR
...
Hand testing
Any relevant files for testing
link to any relevant files (or drag and drop into github)
Misc. comments
...
Checklist