Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
desd
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
kj2-drupisz
desd
Compare revisions
11d0e94f1cf26ed4fc3da125afc626b3a2ffdc98 to 6d6097c167945fdb2531112eae8b869aa03319dd
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
kj2-drupisz/desd
Select target project
No results found
6d6097c167945fdb2531112eae8b869aa03319dd
Select Git revision
Branches
Brody
James
Kacper
Michael
brodybranch
hamid
main
7 results
Swap
Target
kj2-drupisz/desd
Select target project
kj2-drupisz/desd
1 result
11d0e94f1cf26ed4fc3da125afc626b3a2ffdc98
Select Git revision
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source (2)
Merge branch 'brodybranch' into 'main'
· 66379c64
b2-wilton
authored
1 year ago
Brodybranch See merge request
!26
66379c64
fix issues caused by me being a fuckhead when merging
· 6d6097c1
Brody Wilton
authored
1 year ago
6d6097c1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
myproject/myapp/payments.py
+1
-62
1 addition, 62 deletions
myproject/myapp/payments.py
myproject/myapp/urls.py
+1
-5
1 addition, 5 deletions
myproject/myapp/urls.py
with
2 additions
and
67 deletions
myproject/myapp/payments.py
View file @
6d6097c1
...
...
@@ -27,8 +27,6 @@ def create_payment(request):
"
redirect_urls
"
:
{
"
return_url
"
:
request
.
build_absolute_uri
(
reverse
(
'
execute_payment
'
)),
"
cancel_url
"
:
request
.
build_absolute_uri
(
reverse
(
'
payment_cancelled
'
)),
"
return_url
"
:
request
.
build_absolute_uri
(
reverse
(
'
execute_payment
'
)),
"
cancel_url
"
:
request
.
build_absolute_uri
(
reverse
(
'
payment_cancelled
'
)),
},
"
transactions
"
:
[{
"
item_list
"
:
{
...
...
@@ -48,7 +46,6 @@ def create_payment(request):
}]
})
<<<<<<<
HEAD
# Successfully communicated with API
if
payment
.
create
():
print
(
"
Payment created successfully!
"
)
...
...
@@ -63,64 +60,6 @@ def create_payment(request):
print
(
payment
.
error
)
# Execute a successful payment
def
execute_payment
(
request
):
# Get payment id and payer id
payment_id
=
request
.
GET
.
get
(
'
paymentId
'
)
payer_id
=
request
.
GET
.
get
(
'
PayerID
'
)
#If neither ID, error, restart
if
not
payment_id
or
not
payer_id
:
print
(
"
no payment
"
)
#TODO: Change this to a more appropriate path, maybe a generic error page that takes a string:Error to display in a template
return
redirect
(
'
handler404
'
)
# configure API
paypalrestsdk
.
configure
({
"
mode
"
:
settings
.
PAYPAL_MODE
,
"
client_id
"
:
settings
.
PAYPAL_CLIENT_ID
,
"
client_secret
"
:
settings
.
PAYPAL_CLIENT_SECRET
})
# Check we've got a successful payment
payment
=
paypalrestsdk
.
Payment
.
find
(
payment_id
)
# If it we do an the payer IDs match
if
payment
.
execute
({
"
payer_id
"
:
payer_id
}):
print
(
"
Payment executed successfully!
"
)
# Allocate some tokens
user
=
request
.
user
tokens_purchased
=
1
# increment user_tokens
# commit changes
return
redirect
(
'
success
'
)
else
:
#TODO: Change this to a more appropriate error message
print
(
"
exiting at the end of execute_payment()
"
)
return
redirect
(
'
handler404
'
)
def
payment_cancelled
(
request
):
return
render
(
request
,
'
payment_cancelled.html
'
)
def
payment_success
(
request
):
return
render
(
request
,
'
payment_success.html
'
)
=======
if
payment
.
create
():
print
(
"
Payment created successfully!
"
)
# get url for payment approval
for
link
in
payment
.
links
:
if
link
.
rel
==
"
approval_url
"
:
# turn link into text
approval_url
=
str
(
link
.
href
)
# send on merry way
return
redirect
(
approval_url
)
else
:
print
(
payment
.
error
)
# Execute a successful payment
def
execute_payment
(
request
):
# Get payment id and payer id
...
...
This diff is collapsed.
Click to expand it.
myproject/myapp/urls.py
View file @
6d6097c1
from
django.urls
import
path
<<<<<<<
HEAD
from
.views
import
InstrumentDetectionView
,
index
,
users
,
maintenance
,
handler404
,
handler500
,
terms_conditions
,
privacy_policy
,
handling_music_file
,
pricing
,
generate_pdf
,
admin_table
=======
from
.views
import
InstrumentDetectionView
,
index
,
users
,
maintenance
,
handler404
,
handler500
,
register
,
user_login
,
terms_conditions
,
privacy_policy
,
handling_music_file
,
pricing
,
generate_pdf
,
admin_table
from
.payments
import
create_payment
,
execute_payment
,
payment_cancelled
,
payment_success
from
django.contrib.auth
import
views
as
auth_views
...
...
@@ -34,7 +30,7 @@ urlpatterns = [
path
(
'
payment/create/
'
,
create_payment
,
name
=
'
create_payment
'
),
path
(
'
payment/execute/
'
,
execute_payment
,
name
=
'
execute_payment
'
),
path
(
'
payment/cancel/
'
,
payment_cancelled
,
name
=
'
payment_cancelled
'
),
path
(
'
payment_success/
'
,
payment_success
,
name
=
'
success
'
)
path
(
'
payment_success/
'
,
payment_success
,
name
=
'
success
'
)
,
# Authentication
path
(
'
login/
'
,
CustomLoginView
.
as_view
(),
name
=
'
login
'
),
...
...
This diff is collapsed.
Click to expand it.