Skip to content

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

Add charge to the docs

Pacu22ad61f83602b
diff --git a/docs/guides/payments.rst b/docs/guides/payments.rst
index 8e725fceaf..20a7e9b1a3 100644
--- a/docs/guides/payments.rst
+++ b/docs/guides/payments.rst
@@ -167,6 +167,36 @@ Example
is_success=response.is_success)
return txn, response['error']
+charge(payment, payment_token, amount, \*\*connection_params)
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Authorization and capture in a single step.
+
+Example
+"""""""
+
+.. code-block:: python
+
+ def charge(
+ payment: Payment,
+ payment_token: str,
+ amount: Decimal,
+ **connection_params: Dict) -> Tuple[Transaction, str]:
+
+ # Handle connecting to the gateway and sending the charge request here
+ response = gateway.charge(token=payment_token, amount=amount)
+
+ txn = create_transaction(
+ payment=payment,
+ kind=TransactionKind.CHARGE,
+ amount=response.amount,
+ currency=response.currency,
+ error=get_error(response),
+ gateway_response=get_payment_gateway_response(response),
+ token=response.transaction.id,
+ is_success=response.is_success)
+ return txn, response['error']
+
Parameters
^^^^^^^^^^
diff --git a/saleor/payment/gateways/braintree/__init__.py b/saleor/payment/gateways/braintree/__init__.py
index 0571d6c87d..6bea997a5d 100644
--- a/saleor/payment/gateways/braintree/__init__.py
+++ b/saleor/payment/gateways/braintree/__init__.py
@@ -22,8 +22,6 @@ logger = logging.getLogger(__name__)
CONFIRM_MANUALLY = False
THREE_D_SECURE_REQUIRED = False
-# FIXME: Provide list of visible errors and messages translations
-
# Error codes whitelist should be a dict of code: error_msg_override
# if no error_msg_override is provided,
# then error message returned by the gateway will be used