Repository: saleor/saleor
Pull request: Expose in API list of supported payment gateways
I want to merge this change because resolve #3617 

<!-- Please mention all relevant issue numbers. -->

### Screenshots

<!-- If your changes affect the UI, providing "before" and "after" screenshots will
greatly reduce the amount of work needed to review your work. -->

### Pull Request Checklist

<!-- Please keep this section. It will make maintainer's life easier. -->

1. [x] Privileged views and APIs are guarded by proper permission checks.
1. [x] All visible strings are translated with proper context.
1. [x] All data-formatting is locale-aware (dates, numbers, and so on).
1. [x] Database queries are optimized and the number of queries is constant.
1. [x] Database migration files are up to date.
1. [x] The changes are tested.
1. [x] The code is documented (docstrings, project documentation).
1. [x] GraphQL schema and type definitions are up to date.
1. [x] Changes are mentioned in the changelog.


Problem statement:
Expose in API list of supported payment gateways
In API we expose the `GatewaysEnum` enum which contains all the available payment gateways, but there is no way for the Storefront 2.0 to determine which of them are actually enabled (currently Braintree is hardcoded over there). We should expose a field that would provide this information, e.g:
```
type Shop {
  enabledGateways: [GatewaysEnum]
}
```

A resolver function should take into account gateways enabled in `CHECKOUT_PAYMENT_GATEWAYS` setting.

Hints from issue discussion:

Commit message: Add tests

Patch to review:
diff --git a/saleor/graphql/shop/types.py b/saleor/graphql/shop/types.py
index b5abf085a7c..119c15599b8 100644
--- a/saleor/graphql/shop/types.py
+++ b/saleor/graphql/shop/types.py
@@ -17,6 +17,7 @@
 from ..core.types.common import (
     CountryDisplay, LanguageDisplay, PermissionDisplay)
 from ..menu.types import Menu
+from ..payment.enums import PaymentGatewayEnum
 from ..product.types import Collection
 from ..utils import format_permissions_for_display
 from .enums import AuthorizationKeyType
@@ -76,6 +77,8 @@ class Shop(graphene.ObjectType):
         required=True)
     default_currency = graphene.String(
         description='Default shop\'s currency.', required=True)
+    enabled_gateways = graphene.List(
+        PaymentGatewayEnum, description='List of available payment gateways.')
     default_country = graphene.Field(
         CountryDisplay, description='Default shop\'s country')
     description = graphene.String(description='Shop\'s description.')
@@ -144,6 +147,9 @@ def resolve_geolocalization(self, info):
     def resolve_default_currency(self, info):
         return settings.DEFAULT_CURRENCY
 
+    def resolve_enabled_gateways(self, info):
+        return settings.CHECKOUT_PAYMENT_GATEWAYS.keys()
+
     def resolve_description(self, info):
         return info.context.site.settings.description
 
diff --git a/tests/api/test_shop.py b/tests/api/test_shop.py
index c02ae0466c9..abe9711f677 100644
--- a/tests/api/test_shop.py
+++ b/tests/api/test_shop.py
@@ -512,3 +512,20 @@ def test_shop_fetch_tax_rates(
         MUTATION_SHOP_FETCH_TAX_RATES)
     get_graphql_content(response)
     mock_call_command.assert_called_once_with('get_vat_rates')
+
+
+def test_shop_enabled_gateways(
+        api_client, settings):
+    query = """
+    query {
+        shop {
+            enabledGateways
+        }
+    }
+    """
+    response = api_client.post_graphql(query)
+    content = get_graphql_content(response)
+    data = content['data']['shop']
+    checkout_payment_gateways = [
+        str_to_enum(gateway) for gateway in settings.CHECKOUT_PAYMENT_GATEWAYS.keys()]
+    assert data['enabledGateways'] == checkout_payment_gateways


Code review comments:
diff_hunk: @@ -76,6 +77,8 @@ class Shop(graphene.ObjectType):
         required=True)
     default_currency = graphene.String(
         description='Default shop\'s currency.', required=True)
+    enabled_gateways = graphene.List(
path: saleor/graphql/shop/types.py
text: @user1:
It might not be obvious that we are talking about the payments gateways. I’d opt for payment_gateways or available_payment_gateways 

(Don’t feel like “enabled” fits well in this context, as the API is user facing we should talk about the gateways that are available to use, not enabled by the store’s admin)