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
Commits
6d6097c1
Commit
6d6097c1
authored
1 year ago
by
Brody Wilton
Browse files
Options
Downloads
Patches
Plain Diff
fix issues caused by me being a fuckhead when merging
parent
66379c64
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide 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
+
1
−
62
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!
"
)
...
...
@@ -101,65 +98,7 @@ def execute_payment(request):
#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
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
'
)
...
...
This diff is collapsed.
Click to expand it.
myproject/myapp/urls.py
+
1
−
5
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.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment