Adding a new payment gateway
Saleor uses a universal flow that each gateway should implement by providing a class that contains all the necessary methods.
For more information on the plugin implementation methods, see the
plugin.py file for an existing payment gateway.
You will also need to integrate your payment gateway into your storefront’s code.
get_client_token: A client token is a signed data blob that includes configuration and authorization information required by the payment gateway.
Client tokens should not be reused; a new client token should be generated for each payment request.
All the payment methods receive
payment_information as a dataclass:
You are in charge of configuring your gateway. Based on the existing implementations, you may use the
GatewayConfig class to configure your plugin.
For more information on how to configure your plugin, see the Plugins topic.
authorize(payment_information): Authorization is a process of reserving the amount of money against the customer’s funding source. The money does not change hands until the authorization is captured.
refund(payment_information): A refund is a full or partial return of captured funds to the customer.
capture(payment_information): A transfer of the money that was reserved during the authorization stage.
void(payment_information): A cancellation of a pending authorization or capture.
process_payment(payment_information): Used for the checkout process, it should perform all the necessary steps to process a payment. It should use already-defined functions, like authorize and capture.
|Amount to be authorized/captured/charged/refunded|
|The currency used in this transaction|
|IP address of the customer|
|Email address of the customer|
|Token used for transaction, provided by the gateway|
|Indicates that if a payment method for this user has already been stored in payment service, the system should use this payment method|
|Define if a gateway should also capture funds from the card. If false, payment should be only authorized|
|Path to a template that will be rendered for the checkout|
|List of parameters used for connecting to the payment’s gateway|
|If set to True, the system will save this payment method for this customer|
|GatewayResponse containing details about every transaction, with |
|Unique client token that will be used as an identifier in the payment process|
|Transaction ID as returned by the gateway|
|Transaction kind, one of: auth, capture, charge, refund, void|
|Status showing whether the transaction was successful or not|
|Amount that the gateway actually charged or authorized|
|Currency in which the gateway charged, needs to be an ISO 4217 code|
|An error message, if one occurred. Should be |
|Raw gateway response as a dict object. By default it is |
Gateway-specific errors should be parsed to Saleor’s universal format.
Saleor unifies error codes across all gateways.
|Code||Graphql API Value||Description|
|Incorrect card number|
|Invalid card number|
|Incorrect CVV (or CVC)|
|Invalid CVV (or CVC)|
|Incorrect postal code|
|Incorrect address (excluding postal code)|
|Incorrect card expiration date|
|Expired payment method token|
|Transaction was declined by the gateway|
|Default error used for all cases not covered above|