-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
handle paypal payment recipt url SONIC-784
- Loading branch information
1 parent
b1e03fb
commit 945b0c1
Showing
15 changed files
with
179 additions
and
20 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
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,8 @@ | ||
""" | ||
App configuration for the Commerce Coordinator stripe app. | ||
""" | ||
from django.apps import AppConfig | ||
|
||
|
||
class PaypalConfig(AppConfig): | ||
name = 'commerce_coordinator.apps.paypal' |
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,31 @@ | ||
""" | ||
Pipelines for paypal app | ||
""" | ||
|
||
import logging | ||
from urllib.parse import urlencode, urljoin | ||
|
||
from django.conf import settings | ||
from openedx_filters import PipelineStep | ||
|
||
from commerce_coordinator.apps.commercetools.catalog_info.constants import EDX_PAYPAL_PAYMENT_INTERFACE_NAME | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class GetPayPalPaymentReceipt(PipelineStep): | ||
""" Purpare PayPal payment recipt """ | ||
|
||
def run_filter(self, psp=None, **params): | ||
if psp == EDX_PAYPAL_PAYMENT_INTERFACE_NAME: | ||
base_url = settings.PAYPAL_BASE_URL | ||
activities_url = settings.PAYPAL_USER_ACTIVITES_URL | ||
query_params = {'free_text_search': params.get('order_number')} | ||
|
||
redirect_url = urljoin(base_url, activities_url) + '?' + urlencode(query_params) | ||
|
||
return { | ||
'redirect_url': redirect_url, | ||
} | ||
|
||
return None |
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 @@ | ||
"""Constants for PayPal app tests.""" |
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,27 @@ | ||
""" PayPal Pipeline Tests""" | ||
from unittest import TestCase | ||
|
||
from django.conf import settings | ||
from django.test import override_settings | ||
|
||
from commerce_coordinator.apps.paypal.pipeline import GetPayPalPaymentReceipt | ||
|
||
|
||
class TestGetPayPalPaymentReceipt(TestCase): | ||
"""A pytest Test case for the GetPayPalPaymentReceipt Pipeline Step""" | ||
|
||
@override_settings( | ||
PAYPAL_BASE_URL="https://paypal.com/", | ||
PAYPAL_USER_ACTIVITES_URL="myaccount/activities/" | ||
) | ||
def test_pipeline_step(self): | ||
order_number = '123' | ||
paypal_payment_pipe = GetPayPalPaymentReceipt("test_pipe", None) | ||
|
||
result: dict = paypal_payment_pipe.run_filter( | ||
edx_lms_user_id=1, | ||
psp='paypal_edx', | ||
order_number=order_number | ||
) | ||
redirect_url = f"{settings.PAYPAL_BASE_URL}{settings.PAYPAL_USER_ACTIVITES_URL}?free_text_search={order_number}" | ||
self.assertEqual(redirect_url, result['redirect_url']) |
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,10 @@ | ||
commerce\_coordinator.apps.paypal.migrations package | ||
==================================================== | ||
|
||
Module contents | ||
--------------- | ||
|
||
.. automodule:: commerce_coordinator.apps.paypal.migrations | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
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,38 @@ | ||
commerce\_coordinator.apps.paypal package | ||
========================================= | ||
|
||
Subpackages | ||
----------- | ||
|
||
.. toctree:: | ||
:maxdepth: 4 | ||
|
||
commerce_coordinator.apps.paypal.migrations | ||
commerce_coordinator.apps.paypal.tests | ||
|
||
Submodules | ||
---------- | ||
|
||
commerce\_coordinator.apps.paypal.apps module | ||
--------------------------------------------- | ||
|
||
.. automodule:: commerce_coordinator.apps.paypal.apps | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
commerce\_coordinator.apps.paypal.pipeline module | ||
------------------------------------------------- | ||
|
||
.. automodule:: commerce_coordinator.apps.paypal.pipeline | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
Module contents | ||
--------------- | ||
|
||
.. automodule:: commerce_coordinator.apps.paypal | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
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 @@ | ||
commerce\_coordinator.apps.paypal.tests package | ||
=============================================== | ||
|
||
Submodules | ||
---------- | ||
|
||
commerce\_coordinator.apps.paypal.tests.test\_pipeline module | ||
------------------------------------------------------------- | ||
|
||
.. automodule:: commerce_coordinator.apps.paypal.tests.test_pipeline | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
Module contents | ||
--------------- | ||
|
||
.. automodule:: commerce_coordinator.apps.paypal.tests | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
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