-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modularity and documentation enhancements
- Loading branch information
Showing
18 changed files
with
193 additions
and
268 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Stripe | ||
|
||
## General flow | ||
|
||
![Payment authorization with stripe](stripe-authorization.png) | ||
|
||
|
||
## Split payments | ||
|
||
There three different ways to use stripe connect: https://stripe.com/docs/connect/charges#choosing-approach | ||
|
||
We choose to use destination charges: https://stripe.com/docs/connect/destination-charges | ||
|
||
For destination charges there are again two choices on how to split the funds: `application_fee` or `amount`. | ||
|
||
We've implemented the `amount` option. | ||
|
||
|
||
Split payments are configured with an optional `STRIPE_CONNECT` setting: | ||
|
||
transfer_destination is the id of the destination account (). | ||
transfer_percent is a number between 0 and 100. For instance 90 means that the destination will receive 90% of the charge amount. | ||
|
||
Example: | ||
|
||
``` | ||
STRIPE_CONNECT = { | ||
'transfer_destination': 'acct_1Es1XuECDoeqctKE', | ||
'transfer_percent': 90 | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -132,11 +132,6 @@ | |
form.submit(); | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
</script> | ||
|
||
</body> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,18 @@ | ||
from django.conf import settings | ||
from django.conf.urls.static import static | ||
from django.contrib import admin | ||
from django.urls import path, include | ||
|
||
import views | ||
from views import stripe | ||
from views import view_payment | ||
|
||
urlpatterns = [ | ||
path('admin/', admin.site.urls), | ||
path('payment/<payment_id>', view_payment, name='view_payment'), | ||
example_urlpatterns = [ | ||
path('<payment_id>', views.view_payment, name='view_payment'), | ||
path('<payment_id>/capture', views.capture, name='capture'), | ||
path('<payment_id>/refund', views.refund, name='refund'), | ||
path('stripe/', include(stripe.urls)), | ||
] | ||
|
||
stripe_urls = [ | ||
path('<payment_id>/stripe/checkout', stripe.checkout, name='stripe_checkout'), | ||
path('<payment_id>/stripe/elements_token', stripe.elements_token, name='stripe_elements_token'), | ||
|
||
path('<payment_id>/stripe/payment_intents_manual_flow', stripe.payment_intents_manual_flow, | ||
name='stripe_payment_intents_manual_flow'), | ||
path('<payment_id>/stripe/payment_intents_confirm_payment', stripe.payment_intents_confirm_payment, | ||
name='stripe_payment_intents_confirm_payment'), | ||
path('<payment_id>/stripe/capture', stripe.capture, name='stripe_capture'), | ||
path('<payment_id>/stripe/refund', stripe.refund, name='stripe_refund'), | ||
urlpatterns = [ | ||
path('admin/', admin.site.urls), | ||
path('payment/', include('payment.urls')), | ||
path('example/', include(example_urlpatterns)), | ||
] | ||
|
||
|
||
urlpatterns += [path('stripe', include(stripe_urls))] | ||
|
||
|
||
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,28 @@ | ||
from django.http import HttpRequest, HttpResponse | ||
from django.shortcuts import get_object_or_404 | ||
from django.shortcuts import get_object_or_404, redirect | ||
from django.template.response import TemplateResponse | ||
from structlog import get_logger | ||
|
||
from payment.models import Payment | ||
from payment.utils import gateway_capture, gateway_refund | ||
|
||
logger = get_logger() | ||
|
||
|
||
def view_payment(request: HttpRequest, payment_id: int) -> HttpResponse: | ||
payment = get_object_or_404(Payment, id=payment_id) | ||
return TemplateResponse(request, 'operation_list.html', {'payment': payment}) | ||
|
||
|
||
def capture(request: HttpRequest, payment_id: int) -> HttpResponse: | ||
payment = get_object_or_404(Payment, id=payment_id) | ||
capture_result = gateway_capture(payment=payment) | ||
logger.info('capture', payment=payment, capture_result=capture_result) | ||
return redirect('view_payment', payment_id=payment_id) | ||
|
||
|
||
def refund(request: HttpRequest, payment_id: int) -> HttpResponse: | ||
payment = get_object_or_404(Payment, id=payment_id) | ||
refund_result = gateway_refund(payment=payment) | ||
logger.info('refund', payment=payment, refund_result=refund_result) | ||
return redirect('view_payment', payment_id=payment_id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.