Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GET method to purchase/ and subscribe/ #173

Merged
merged 1 commit into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions web/perma_payments/tests/test_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,10 +475,15 @@ def test_purchase_post_redirect_form_populated_correctly(client, purchase, purch


def test_purchase_other_methods(client, purchase):
get_not_allowed(client, purchase['route'])
put_patch_delete_not_allowed(client, purchase['route'])


def test_purchase_get(client, purchase, index):
response = client.get(purchase['route'])
assert response.status_code == 200
expected_template_used(response, index['template'])


# acknowledge-purchase

@pytest.mark.django_db
Expand Down Expand Up @@ -742,10 +747,15 @@ def test_subscribe_post_redirect_form_populated_correctly(client, subscribe, sub


def test_subscribe_other_methods(client, subscribe):
get_not_allowed(client, subscribe['route'])
put_patch_delete_not_allowed(client, subscribe['route'])


def test_subscribe_get(client, subscribe, index):
response = client.get(subscribe['route'])
assert response.status_code == 200
expected_template_used(response, index['template'])


# change

def test_change_post_invalid_perma_transmission(client, change, mocker):
Expand Down
16 changes: 14 additions & 2 deletions web/perma_payments/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,13 +236,19 @@ def index(request):


@csrf_exempt
@require_http_methods(["POST"])
@require_http_methods(["GET", "POST"])
@sensitive_post_parameters('encrypted_data')
def purchase(request):
"""
Processes user-initiated one-time purchase requests from Perma.cc;
Redirects user to CyberSource for payment.
"""
if request.method == "GET":
return render(request, 'generic.html', {
'heading': "Perma Payments",
'message': "A window to CyberSource Secure Acceptance Web/Mobile"
})

try:
data = process_perma_transmission(request.POST, FIELDS_REQUIRED_FROM_PERMA['purchase'])
except InvalidTransmissionException:
Expand Down Expand Up @@ -316,13 +322,19 @@ def acknowledge_purchase(request):


@csrf_exempt
@require_http_methods(["POST"])
@require_http_methods(["GET", "POST"])
@sensitive_post_parameters('encrypted_data')
def subscribe(request):
"""
Processes user-initiated subscription requests from Perma.cc;
Redirects user to CyberSource for payment.
"""
if request.method == "GET":
return render(request, 'generic.html', {
'heading': "Perma Payments",
'message': "A window to CyberSource Secure Acceptance Web/Mobile"
})

try:
data = process_perma_transmission(request.POST, FIELDS_REQUIRED_FROM_PERMA['subscribe'])
except InvalidTransmissionException:
Expand Down
Loading