-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
329 additions
and
29 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
18 changes: 18 additions & 0 deletions
18
bb_data/migrations/0024_colocationclient_stripe_account_id.py
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,18 @@ | ||
# Generated by Django 3.2.9 on 2021-11-18 19:29 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('bb_data', '0023_alter_colocationclientowner_unique_together'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='colocationclient', | ||
name='stripe_account_id', | ||
field=models.CharField(blank=True, max_length=128, null=True), | ||
), | ||
] |
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
Empty file.
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,5 @@ | ||
''' bb_webhook - Admin interface for the webhook module ''' | ||
|
||
# from django.contrib import admin | ||
|
||
# Register your models here. |
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,12 @@ | ||
''' bb_webhook app settings ''' | ||
|
||
from django.apps import AppConfig | ||
|
||
|
||
class BbWebhookConfig(AppConfig): | ||
''' | ||
app specific configuration | ||
''' | ||
name = 'bb_webhook' | ||
default_auto_field = 'django.db.models.BigAutoField' | ||
name = 'bb_webhook' |
Empty file.
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,12 @@ | ||
'''urls.py for bb_webhook''' | ||
|
||
from django.urls import path | ||
|
||
from bb_webhook import views_stripe | ||
|
||
app_name = 'bb_webhook' | ||
|
||
urlpatterns = [ | ||
# ------------------------- Stripe Webhook Endpoints ------------------------- # | ||
path('stripe/account', views_stripe.account_event, name='webhook_stripe_account'), | ||
] |
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,50 @@ | ||
''' Processes webhooks from Stripe ''' | ||
|
||
import json | ||
import stripe | ||
|
||
from django.shortcuts import HttpResponse | ||
|
||
from django.views.decorators.csrf import csrf_exempt | ||
|
||
|
||
@csrf_exempt | ||
def account_event(request): | ||
''' | ||
URL: webhook/stripe/account | ||
''' | ||
payload = request.body | ||
event = None | ||
|
||
try: | ||
event = stripe.Event.construct_from( | ||
json.loads(payload), stripe.api_key | ||
) | ||
except ValueError: | ||
# Invalid payload | ||
return HttpResponse(status=400) | ||
|
||
# Account Updated | ||
if event.type == 'account.updated': | ||
account = event.data.object.id | ||
print(account) | ||
|
||
|
||
|
||
|
||
# Handle the event | ||
if event.type == 'payment_intent.succeeded': | ||
payment_intent = event.data.object # contains a stripe.PaymentIntent | ||
print(payment_intent) | ||
# Then define and call a method to handle the successful payment intent. | ||
# handle_payment_intent_succeeded(payment_intent) | ||
elif event.type == 'payment_method.attached': | ||
payment_method = event.data.object # contains a stripe.PaymentMethod | ||
print(payment_method) | ||
# Then define and call a method to handle the successful attachment of a PaymentMethod. | ||
# handle_payment_method_attached(payment_method) | ||
# ... handle other event types | ||
else: | ||
print(f'Unhandled event type {event.type}') | ||
|
||
return HttpResponse(status=200) |
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
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<div class="modal fade" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true" id="eth_address"> | ||
|
||
<div class="modal-dialog modal-xl" style="transform: translate(0, 0)"> | ||
<div class="modal-content"> | ||
<div class="modal-body"> | ||
|
||
<!-- An input field for eth address --> | ||
<div class="form-group"> | ||
<label for="eth_address">ETH Address</label> | ||
<input type="text" class="form-control" id="eth_address" placeholder="0x..." style="color: black;"> | ||
</div> | ||
|
||
</div> | ||
<div class="modal-footer"> | ||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button> | ||
<button type="button" class="btn btn-danger" id="confirm_eth_address_button">Confirm</button> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
</div> |
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.