Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Restrict single payment resolving

NyanKiyoshi2d10a2c73ae3
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e6db082696..b93cf3bdf9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -29,6 +29,7 @@ All notable, unreleased changes to this project will be documented in this file.
- Update file field styles with materializecss template filter - #3998 by @zodiacfireworks
- Add filtering interface for graphQL API - #3952 by @korycins
+- Restrict single payment resolving - #4009 @NyanKiyoshi
## 2.5.0
diff --git a/saleor/graphql/payment/schema.py b/saleor/graphql/payment/schema.py
index d95d243445..75d32b3231 100644
--- a/saleor/graphql/payment/schema.py
+++ b/saleor/graphql/payment/schema.py
@@ -15,6 +15,7 @@ class PaymentQueries(graphene.ObjectType):
payment_client_token = graphene.Field(
graphene.String, args={'gateway': PaymentGatewayEnum()})
+ @permission_required('order.manage_orders')
def resolve_payment(self, info, **data):
return graphene.Node.get_node_from_global_id(
info, data.get('id'), Payment)
diff --git a/tests/api/test_payment.py b/tests/api/test_payment.py
index 21fb82a3d2..3a0eb45143 100644
--- a/tests/api/test_payment.py
+++ b/tests/api/test_payment.py
@@ -411,7 +411,8 @@ def test_payments_query(
'lastDigits': pay.cc_last_digits}
-def test_query_payment(payment_dummy, user_api_client):
+def test_query_payment(
+ payment_dummy, user_api_client, permission_manage_orders):
query = """
query payment($id: ID) {
payment(id: $id) {
@@ -422,7 +423,8 @@ def test_query_payment(payment_dummy, user_api_client):
payment = payment_dummy
payment_id = graphene.Node.to_global_id('Payment', payment.pk)
variables = {'id': payment_id}
- response = user_api_client.post_graphql(query, variables)
+ response = user_api_client.post_graphql(
+ query, variables, permissions=[permission_manage_orders])
content = get_graphql_content(response)
received_id = content['data']['payment']['id']
assert received_id == payment_id