Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Fix flake8 on tests and fix blake on payment docs
NyanKiyoshiad9728f31737
diff --git a/docs/guides/payments.rst b/docs/guides/payments.rstindex 61cd55d20d..170798405f 100644--- a/docs/guides/payments.rst+++ b/docs/guides/payments.rst@@ -39,8 +39,8 @@ Example.. note::- All the below functions receive ``payment_information`` as a dataclass: ``PaymentData`` and ``config`` as a dataclass: ``GatewayConfig``.- Those functions should return a response as a dataclass: ``GatewayResponse``.+ All the below functions receive ``payment_information`` as a dataclass: ``PaymentData`` and ``config`` as a dataclass: ``GatewayConfig``.+ Those functions should return a response as a dataclass: ``GatewayResponse``.The description of the given structures can be found below.@@ -57,7 +57,8 @@ Exampledef authorize(payment_information: PaymentData,- config: GatewayConfig) -> GatewayResponse:+ config: GatewayConfig,+ ) -> GatewayResponse:# Handle connecting to the gateway and sending the auth request hereresponse = gateway.authorize(token=payment_information.token)@@ -85,8 +86,9 @@ Example.. code-block:: pythondef refund(- payment_information: PaymentData,- config: GatewayConfig) -> GatewayResponse:+ payment_information: PaymentData,+ config: GatewayConfig,+ ) -> GatewayResponse:# Handle connecting to the gateway and sending the refund request hereresponse = gateway.refund(token=payment_information.token)@@ -114,8 +116,9 @@ Example.. code-block:: pythondef capture(- payment_information: PaymentData,- config: GatewayConfig) -> GatewayResponse:+ payment_information: PaymentData,+ config: GatewayConfig,+ ) -> GatewayResponse:# Handle connecting to the gateway and sending the capture request hereresponse = gateway.capture(token=payment_information.token)@@ -143,8 +146,9 @@ Example.. code-block:: pythondef void(- payment_information: PaymentData,- config: GatewayConfig) -> GatewayResponse:+ payment_information: PaymentData,+ config: GatewayConfig,+ ) -> GatewayResponse:# Handle connecting to the gateway and sending the void request hereresponse = gateway.void(token=payment_information.token)@@ -172,13 +176,15 @@ Example.. code-block:: pythondef charge(- payment_information: PaymentData,- config: GatewayConfig) -> GatewayResponse:+ payment_information: PaymentData,+ config: GatewayConfig,+ ) -> GatewayResponse:# Handle connecting to the gateway and sending the charge request hereresponse = gateway.charge(token=payment_information.token,- amount=payment_information.amount)+ amount=payment_information.amount,+ )# Return a correct response format so Saleor can process it,# the response must be json serializable@@ -205,29 +211,28 @@ Example.. code-block:: pythondef process_payment(- payment_information: PaymentData,- config: GatewayConfig) -> GatewayResponse:+ payment_information: PaymentData,+ config: GatewayConfig,+ ) -> GatewayResponse:# Authorize, update the token, then capture- authorize_response = authorize(- payment_information, config)+ authorize_response = authorize(payment_information, config)payment_information.token = authorize_response.transaction_id- capture_response = capture(- payment_information, config)+ capture_response = capture(payment_information, config)return capture_responseParameters^^^^^^^^^^-+-------------------------+-----------------+---------------------------------------------------------------------------+-| name | type | description |-+-------------------------+-----------------+---------------------------------------------------------------------------+-| ``payment_information`` | ``PaymentData`` | Payment information, containing the token, amount, currency and billing. |-+-------------------------+-----------------+---------------------------------------------------------------------------+-| ``config`` | ``GatewayConfig`` | Configuration of the payment gateway. |-+-------------------------+-----------------+---------------------------------------------------------------------------+++-------------------------+--------------------+---------------------------------------------------------------------------++| name | type | description |++-------------------------+--------------------+---------------------------------------------------------------------------++| ``payment_information`` | ``PaymentData`` | Payment information, containing the token, amount, currency and billing. |++-------------------------+--------------------+---------------------------------------------------------------------------++| ``config`` | ``GatewayConfig`` | Configuration of the payment gateway. |++-------------------------+--------------------+---------------------------------------------------------------------------+PaymentData"""""""""""@@ -288,7 +293,7 @@ GatewayConfig+---------------------+-----------+---------------------------------------------------------------------------------------------------------+| auto_capture | ``bool`` | Define if gateway should also capture funds from the card. If false, payment should be only authorized |+---------------------+-----------+---------------------------------------------------------------------------------------------------------+-| template_path | ``str`` | Path to a template that will be rendered for the checkout. tests/gateway/test_braintree.py |+| template_path | ``str`` | Path to a template that will be rendered for the checkout. |+---------------------+-----------+---------------------------------------------------------------------------------------------------------+| connection_params | ``Dict`` | List of parameters used for connecting to the payment’s gateway. |+---------------------+-----------+---------------------------------------------------------------------------------------------------------+diff --git a/tests/test_payment.py b/tests/test_payment.pyindex 064487af55..4017453346 100644--- a/tests/test_payment.py+++ b/tests/test_payment.py@@ -2,12 +2,9 @@ from decimal import Decimalfrom unittest.mock import Mock, patchimport pytest-from django.conf import settings as dj_settingsfrom django.core.exceptions import ImproperlyConfigured-from django.template.loader import get_templatefrom saleor.order.events import OrderEvents, OrderEventsEmails-from saleor.order.views import PAYMENT_TEMPLATEfrom saleor.payment import (ChargeStatus,GatewayError,