Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add docs
Maciej Korycinskic25d9b8e3a89
diff --git a/docs/guides/payments.rst b/docs/guides/payments.rstindex d14eb06d4c..d3b5022f25 100644--- a/docs/guides/payments.rst+++ b/docs/guides/payments.rst@@ -39,13 +39,13 @@ Example.. note::- All the below methods receive ``payment_information`` as a dataclass: ``PaymentData``.- Methods should return a response as a dataclass: ``GatewayResponse``.+ All the below functions receive ``payment_information`` as a dataclass: ``PaymentData`` and ``config`` as a dataclass: ``ConfigData``.+ Functions should return a response as a dataclass: ``GatewayResponse``.The description of the given structures can be found below.-authorize(payment_information, connection_params)-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^+authorize(payment_information, config)+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^A process of reserving the amount of money against the customer's fundingsource. Money does not change hands until the authorization is captured.@@ -57,7 +57,7 @@ Exampledef authorize(payment_information: PaymentData,- connection_params: Dict) -> GatewayResponse:+ config: ConfigData) -> GatewayResponse:# Handle connecting to the gateway and sending the auth request hereresponse = gateway.authorize(token=payment_information.token)@@ -74,8 +74,8 @@ Exampleraw_response=get_payment_gateway_response(response),)-refund(payment_information, connection_params)-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^+refund(payment_information, config)+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^Full or partial return of captured funds to the customer.@@ -86,7 +86,7 @@ Exampledef refund(payment_information: PaymentData,- **connection_params: Dict) -> GatewayResponse:+ config: ConfigData) -> GatewayResponse:# Handle connecting to the gateway and sending the refund request hereresponse = gateway.refund(token=payment_information.token)@@ -103,8 +103,8 @@ Exampleraw_response=get_payment_gateway_response(response),)-capture(payment_information, connection_params)-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^+capture(payment_information, config)+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^A transfer of the money that was reserved during the authorization stage.@@ -115,7 +115,7 @@ Exampledef capture(payment_information: PaymentData,- connection_params: Dict) -> GatewayResponse:+ config: ConfigData) -> GatewayResponse:# Handle connecting to the gateway and sending the capture request hereresponse = gateway.capture(token=payment_information.token)@@ -132,8 +132,8 @@ Exampleraw_response=get_payment_gateway_response(response),)-void(payment_information, connection_params)-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^+void(payment_information, config)+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^A cancellation of a pending authorization or capture.@@ -144,7 +144,7 @@ Exampledef void(payment_information: PaymentData,- connection_params: Dict) -> GatewayResponse:+ config: ConfigData) -> GatewayResponse:# Handle connecting to the gateway and sending the void request hereresponse = gateway.void(token=payment_information.token)@@ -161,8 +161,8 @@ Exampleraw_response=get_payment_gateway_response(response),)-charge(payment_information, connection_params)-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^+charge(payment_information, config)+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^Authorization and capture in a single step.@@ -173,7 +173,7 @@ Exampledef charge(payment_information: PaymentData,- connection_params: Dict) -> GatewayResponse:+ config: ConfigData) -> GatewayResponse:# Handle connecting to the gateway and sending the charge request hereresponse = gateway.charge(@@ -192,8 +192,8 @@ Exampleraw_response=get_payment_gateway_response(response),)-process_payment(payment_information, connection_params)-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^+process_payment(payment_information, config)+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^Used for the checkout process, it should perform all the necessarysteps to process a payment. It should use already defined functions,@@ -206,15 +206,15 @@ Exampledef process_payment(payment_information: PaymentData,- connection_params: Dict) -> GatewayResponse:+ config: ConfigData) -> GatewayResponse:# Authorize, update the token, then captureauthorize_response = authorize(- payment_information, connection_params)+ payment_information, config)payment_information.token = authorize_response.transaction_idcapture_response = capture(- payment_information, connection_params)+ payment_information, config)return capture_response@@ -226,7 +226,7 @@ Parameters+-------------------------+-----------------+-----------------------------------------------------------------------------+| ``payment_information`` | ``PaymentData`` | Payment information, containing the token, amount, currency and billing. |+-------------------------+-----------------+-----------------------------------------------------------------------------+-| ``connection_params`` | ``dict`` | List of parameters used for connecting to the payment's gateway. |+| ``config`` | ``ConfigData`` | Configuration of the payment gateway. |+-------------------------+-----------------+-----------------------------------------------------------------------------+PaymentData@@ -280,6 +280,19 @@ AddressData| phone | ``str`` |+------------------+---------++ConfigData+""""""""""+++---------------------+-----------+---------------------------------------------------------------------------------------------------------++| name | type | description |++---------------------+-----------+---------------------------------------------------------------------------------------------------------++| auto_capture | ``bool`` | Define if gateway should also capture funds from the card. If false, payment should be only authorized |++---------------------+-----------+---------------------------------------------------------------------------------------------------------++| template_path | ``str`` | Should specify a 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. |++---------------------+-----------+---------------------------------------------------------------------------------------------------------++Returns^^^^^^^@@ -368,17 +381,24 @@ Exampledata, payment_information, connection_params)-Implement TEMPLATE_PATH+Implement template_path^^^^^^^^^^^^^^^^^^^^^^^Should specify a path to a template that will be rendered for the checkout.-Example-"""""""+.. code-block:: python- .. code-block:: python+ PAYMENT_GATEWAYS = {+ DUMMY: {+ "module": "saleor.payment.gateways.dummy",+ "config": {+ "auto_capture": True,+ "connection_params": {},+ "template_path": "order/payment/dummy.html",+ },+ },+ }- TEMPLATE_PATH = 'order/payment/braintree.html'Add template^^^^^^^^^^^^@@ -394,14 +414,18 @@ Adding new payment gateway to the settingsPAYMENT_GATEWAYS = {'braintree': {- 'module': 'saleor.payment.gateways.braintree',- 'connection_params': {- 'sandbox_mode': get_bool_from_env('BRAINTREE_SANDBOX_MODE', True),- 'merchant_id': os.environ.get('BRAINTREE_MERCHANT_ID'),- 'public_key': os.environ.get('BRAINTREE_PUBLIC_KEY'),- 'private_key': os.environ.get('BRAINTREE_PRIVATE_KEY')- }- }+ "module": "saleor.payment.gateways.braintree",+ "config": {+ "auto_capture": True,+ "template_path": "order/payment/braintree.html",+ "connection_params": {+ "sandbox_mode": get_bool_from_env("BRAINTREE_SANDBOX_MODE", True),+ "merchant_id": os.environ.get("BRAINTREE_MERCHANT_ID"),+ "public_key": os.environ.get("BRAINTREE_PUBLIC_KEY"),+ "private_key": os.environ.get("BRAINTREE_PRIVATE_KEY"),+ },+ },+ },}Please take a moment to consider the example settings above.@@ -419,6 +443,9 @@ Please take a moment to consider the example settings above.- ``connection_params``List of parameters used for connecting to the payment's gateway.+- ``auto_capture``+ Define if the gateway should also capture funds from the card. When auto_capture is set to False, funds will be blocked but manual capture will be required.+.. note::All payment backends default to using sandbox mode.