Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
ecommerce
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
ecommerce
Commits
b808b0fe
Commit
b808b0fe
authored
Mar 31, 2017
by
Clinton Blackburn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP: Register PayPal webhook
parent
79819b36
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
1 deletions
+45
-1
ecommerce/extensions/payment/processors/paypal.py
+45
-1
No files found.
ecommerce/extensions/payment/processors/paypal.py
View file @
b808b0fe
...
@@ -331,6 +331,50 @@ class Paypal(BasePaymentProcessor):
...
@@ -331,6 +331,50 @@ class Paypal(BasePaymentProcessor):
response_id
=
entry
.
id
)
response_id
=
entry
.
id
)
raise
GatewayError
(
msg
)
raise
GatewayError
(
msg
)
# def create_webhooks(self):
# """ Registers webhooks. """
# url = 'https://f615ef32.ngrok.io'
# webhooks = paypalrestsdk.Webhook.all(api=self.paypal_api).webhooks
# webhook = next((_webhook for _webhook in webhooks if _webhook.url == url), None)
#
# event_types = [
# {'name': 'CUSTOMER.DISPUTE.CREATED'},
# ]
#
#
# if webhook:
# attributes = [
# {
# "op": "replace",
# "path": "/url",
# "value": url,
# },
# {
# "op": "replace",
# "path": "/event_types",
# "value": event_types,
# }
# ]
#
# webhook = paypalrestsdk.Webhook.find(webhook.id, api=self.paypal_api)
# if webhook.replace(attributes):
# logger.info('PayPal webhook [%s] updated successfully', webhook.id)
# else:
# logger.error('Failed to update PayPal webhook [%s]: %s', webhook.id, webhook.error)
# else:
# webhook = paypalrestsdk.Webhook(
# {
# 'url': url,
# 'event_types': event_types
# },
# api=self.paypal_api
# )
#
# if webhook.create():
# logger.info('PayPal webhook [%s] created successfully', webhook.id)
# else:
# logger.error('Failed to create PayPal webhook: %s', webhook.error)
def
verify_webhook_event
(
self
,
transmission_id
,
timestamp
,
event_body
,
cert_url
,
actual_signature
,
def
verify_webhook_event
(
self
,
transmission_id
,
timestamp
,
event_body
,
cert_url
,
actual_signature
,
auth_algo
):
auth_algo
):
""" Verifies the authenticity of a webhook request.
""" Verifies the authenticity of a webhook request.
...
@@ -347,5 +391,5 @@ class Paypal(BasePaymentProcessor):
...
@@ -347,5 +391,5 @@ class Paypal(BasePaymentProcessor):
if
not
self
.
dispute_webhook_id
:
if
not
self
.
dispute_webhook_id
:
raise
ImproperlyConfigured
(
'No PayPal dispute webhook ID set. Unable to verify webhook events.'
)
raise
ImproperlyConfigured
(
'No PayPal dispute webhook ID set. Unable to verify webhook events.'
)
return
paypalrestsdk
.
notifications
.
WebhookEvent
.
verify
(
return
paypalrestsdk
.
WebhookEvent
.
verify
(
transmission_id
,
timestamp
,
self
.
dispute_webhook_id
,
event_body
,
cert_url
,
actual_signature
,
auth_algo
)
transmission_id
,
timestamp
,
self
.
dispute_webhook_id
,
event_body
,
cert_url
,
actual_signature
,
auth_algo
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment