Repository: saleor/saleor

Issue:
Razorpay Token not return when using checkoutCreate
the graphql input
``` Graphql
mutation {
  checkoutCreate(
    input: {
      email: "customer@example.com"
      lines: [{ quantity: 1, variantId: "UHJvZHVjdFZhcmlhbnQ6MjAy" }]
    }
  ) {
    checkout {
      id
      totalPrice {
        gross {
          amount
          currency
        }
      }
      isShippingRequired
      availableShippingMethods {
        id
        name
      }
      availablePaymentGateways {
        name
        config {
          field
          value
        }
      }
    }
    errors {
      field
      message
    }
  }
}
```
Response
``` JSON
{
  "data": {
    "checkoutCreate": {
      "checkout": {
        "id": "Q2hlY2tvdXQ6NWNjZGI4M2MtZGE4NS00OWQ0LTg3MmUtYWUyODc4NzI1YzJm",
        "totalPrice": {
          "gross": {
            "amount": 3,
            "currency": "USD"
          }
        },
        "isShippingRequired": true,
        "availableShippingMethods": [],
        "availablePaymentGateways": [
          {
            "name": "Dummy",
            "config": [
              {
                "field": "store_customer_card",
                "value": "false"
              }
            ]
          },
          {
            "name": "Braintree",
            "config": [
              {
                "field": "store_customer_card",
                "value": "false"
              },
              {
                "field": "client_token",
                "value": "eyJ2ZXJzaW9uIjoyLCJhdXRob3JpemF0aW9uRmluZ2VycHJpbnQiOiJleUowZVhBaU9pSktWMVFpTENKaGJHY2lPaUpGVXpJMU5pSXNJbXRwWkNJNklqSXdNVGd3TkRJMk1UWXRjMkZ1WkdKdmVDSXNJbWx6Y3lJNklrRjFkR2g1SW4wLmV5SmxlSEFpT2pFMU56TXhNVEEwTnpFc0ltcDBhU0k2SWpZeU9EYzVZVEl4TFRjNU9ETXROR1F3WlMwNFlXWm1MV1prT0RNek16Y3hObVl5T1NJc0luTjFZaUk2SWpaak4yMW9kemxpYUhSMmVYcHRhM01pTENKcGMzTWlPaUpCZFhSb2VTSXNJbTFsY21Ob1lXNTBJanA3SW5CMVlteHBZMTlwWkNJNklqWmpOMjFvZHpsaWFIUjJlWHB0YTNNaUxDSjJaWEpwWm5sZlkyRnlaRjlpZVY5a1pXWmhkV3gwSW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jeVVybCI6Imh0dHA6Ly9leGFtcGxlLmNvbS9wcCIsInVzZXJBZ3JlZW1lbnRVcmwiOiJodHRwOi8vZXhhbXBsZS5jb20vdG9zIiwiYmFzZVVybCI6Imh0dHBzOi8vYXNzZXRzLmJyYWludHJlZWdhdGV3YXkuY29tIiwiYXNzZXRzVXJsIjoiaHR0cHM6Ly9jaGVja291dC5wYXlwYWwuY29tIiwiZGlyZWN0QmFzZVVybCI6bnVsbCwiYWxsb3dIdHRwIjp0cnVlLCJlbnZpcm9ubWVudE5vTmV0d29yayI6dHJ1ZSwiZW52aXJvbm1lbnQiOiJvZmZsaW5lIiwidW52ZXR0ZWRNZXJjaGFudCI6ZmFsc2UsImJyYWludHJlZUNsaWVudElkIjoibWFzdGVyY2xpZW50MyIsImJpbGxpbmdBZ3JlZW1lbnRzRW5hYmxlZCI6dHJ1ZSwibWVyY2hhbnRBY2NvdW50SWQiOiJ6YXJ0ZWsiLCJjdXJyZW5jeUlzb0NvZGUiOiJVU0QifSwibWVyY2hhbnRJZCI6IjZjN21odzliaHR2eXpta3MiLCJ2ZW5tbyI6Im9mZiJ9"
              }
            ]
          },
          {
            "name": "Razorpay",
            "config": []
          }
        ]
      },
      "errors": []
    }
  }
}
```

the razorpay key and secret are set in the admin dashboard
didn't change the source code, this was deployed straight to heroku from the link in the readme


Discussion:
Hi! @korycins is looking into that. It looks like the field is not returning the public key for razorpay because no `get_payment_config` was defined into `payments.razorpay.plugin`.

Resolving patch:
diff --git a/saleor/payment/gateways/razorpay/__init__.py b/saleor/payment/gateways/razorpay/__init__.py
--- a/saleor/payment/gateways/razorpay/__init__.py
+++ b/saleor/payment/gateways/razorpay/__init__.py
@@ -80,9 +80,9 @@ def create_form(data, payment_information, connection_params):
     )
 
 
-def get_client(public_key: str, secret_key: str, **_):
+def get_client(public_key: str, private_key: str, **_):
     """Create a Razorpay client from set-up application keys."""
-    razorpay_client = razorpay.Client(auth=(public_key, secret_key))
+    razorpay_client = razorpay.Client(auth=(public_key, private_key))
     return razorpay_client
 
 
diff --git a/saleor/payment/gateways/razorpay/plugin.py b/saleor/payment/gateways/razorpay/plugin.py
--- a/saleor/payment/gateways/razorpay/plugin.py
+++ b/saleor/payment/gateways/razorpay/plugin.py
@@ -83,8 +83,11 @@ def _initialize_plugin_configuration(self):
                 connection_params={
                     "public_key": configuration["Public API key"],
                     "private_key": configuration["Secret API key"],
+                    "prefill": True,
+                    "store_name": None,
+                    "store_image": None,
                 },
-                template_path="",
+                template_path=configuration["Template path"],
                 store_customer=configuration["Store customers card"],
             )
 
@@ -146,3 +149,8 @@ def create_form(
             payment_information,
             connection_params=self._get_gateway_config().connection_params,
         )
+
+    @require_active_plugin
+    def get_payment_config(self, previous_value):
+        config = self._get_gateway_config()
+        return [{"field": "api_key", "value": config.connection_params["public_key"]}]


Test patch:
diff --git a/tests/gateway/test_razorpay.py b/tests/gateway/test_razorpay.py
--- a/tests/gateway/test_razorpay.py
+++ b/tests/gateway/test_razorpay.py
@@ -36,7 +36,7 @@ def gateway_config():
         template_path="template.html",
         connection_params={
             "public_key": "public",
-            "secret_key": "secret",
+            "private_key": "secret",
             "prefill": True,
             "store_name": "Saleor",
             "store_image": "image.png",