Skip to content

Commit

Permalink
Render default templates
Browse files Browse the repository at this point in the history
  • Loading branch information
dinoperovic committed Mar 24, 2022
1 parent 9c34f5d commit 054df1a
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 12 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

<!-- ## [Unreleased] -->

## [0.1.2] - 2022-03-24
### Changed
- Render default templates for success and cancel

## [0.1.1] - 2022-03-24
### Fixed
- Handle guest customer correctly
Expand All @@ -14,5 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Initial code

[Unreleased]: https://github.com/dinoperovic/django-salesman-stripe/compare/0.1.0...HEAD
[Unreleased]: https://github.com/dinoperovic/django-salesman-stripe/compare/0.1.2...HEAD
[0.1.2]: https://github.com/dinoperovic/django-salesman-stripe/releases/tag/0.1.2
[0.1.1]: https://github.com/dinoperovic/django-salesman-stripe/releases/tag/0.1.1
[0.1.0]: https://github.com/dinoperovic/django-salesman-stripe/releases/tag/0.1.0
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pip install django-salesman-stripe
Add to your setting file:

```python
INSTALLED_APPS += ['salesman_stripe']
SALESMAN_PAYMENT_METHODS = ['salesman_stripe.payment.StripePayment']
SALESMAN_STRIPE_SECRET_KEY = '<stripe-secret-key>'
SALESMAN_STRIPE_WEBHOOK_SECRET = '<stripe-webhook-secret>'
Expand Down
1 change: 1 addition & 0 deletions example/project/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
'salesman.orders',
'salesman.admin',
'rest_framework',
'salesman_stripe',
'shop',
]

Expand Down
17 changes: 6 additions & 11 deletions salesman_stripe/payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,9 @@
from typing import Optional, TypeVar

import stripe
from django.contrib.auth.models import AbstractUser
from django.core.exceptions import FieldDoesNotExist
from django.http import (
HttpRequest,
HttpResponse,
HttpResponseBadRequest,
HttpResponseRedirect,
)
from django.http import HttpRequest, HttpResponse, HttpResponseBadRequest
from django.shortcuts import redirect, render
from django.urls import path, reverse
from django.utils.decorators import method_decorator
from django.views.decorators.csrf import csrf_exempt
Expand Down Expand Up @@ -234,17 +229,17 @@ def cancel_view(cls, request: HttpRequest) -> HttpResponse:
Handle cancelled payment on Stripe.
"""
if app_settings.SALESMAN_STRIPE_CANCEL_URL:
return HttpResponseRedirect(app_settings.SALESMAN_STRIPE_CANCEL_URL)
return HttpResponse("Stripe payment cancelled")
return redirect(app_settings.SALESMAN_STRIPE_CANCEL_URL)
return render(request, 'salesman_stripe/cancel.html')

@classmethod
def success_view(cls, request: HttpRequest) -> HttpResponse:
"""
Handle successfull payment on Stripe.
"""
if app_settings.SALESMAN_STRIPE_SUCCESS_URL:
return HttpResponseRedirect(app_settings.SALESMAN_STRIPE_SUCCESS_URL)
return HttpResponse("Stripe payment successfull")
return redirect(app_settings.SALESMAN_STRIPE_SUCCESS_URL)
return render(request, 'salesman_stripe/success.html')

@classmethod
@method_decorator(csrf_exempt)
Expand Down
1 change: 1 addition & 0 deletions salesman_stripe/templates/salesman_stripe/cancel.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1>Stripe payment cancelled</h1>
1 change: 1 addition & 0 deletions salesman_stripe/templates/salesman_stripe/success.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1>Stripe payment successfull</h1>

0 comments on commit 054df1a

Please sign in to comment.