-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4669 from mirumee/extract-payment-plugins
Extract payment plugins
- Loading branch information
Showing
39 changed files
with
1,649 additions
and
1,161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
from abc import ABC, abstractmethod | ||
from enum import Enum | ||
from typing import TYPE_CHECKING, List | ||
|
||
if TYPE_CHECKING: | ||
from saleor.payment.interface import PaymentData, GatewayResponse, TokenConfig | ||
|
||
|
||
class Gateway(Enum): | ||
"""Possible gateway values. | ||
TODO: Create this in runtime based on available plugins | ||
""" | ||
|
||
DUMMY = "dummy" | ||
BRAINTREE = "braintree" | ||
RAZORPAY = "razorpay" | ||
STRIPE = "stripe" | ||
|
||
|
||
class PaymentInterface(ABC): | ||
@abstractmethod | ||
def list_payment_gateways(self) -> List[Gateway]: | ||
pass | ||
|
||
@abstractmethod | ||
def authorize_payment( | ||
self, gateway: Gateway, payment_information: "PaymentData" | ||
) -> "GatewayResponse": | ||
pass | ||
|
||
@abstractmethod | ||
def capture_payment( | ||
self, gateway: Gateway, payment_information: "PaymentData" | ||
) -> "GatewayResponse": | ||
pass | ||
|
||
@abstractmethod | ||
def refund_payment( | ||
self, gateway: Gateway, payment_information: "PaymentData" | ||
) -> "GatewayResponse": | ||
pass | ||
|
||
@abstractmethod | ||
def void_payment( | ||
self, gateway: Gateway, payment_information: "PaymentData" | ||
) -> "GatewayResponse": | ||
pass | ||
|
||
@abstractmethod | ||
def confirm_payment( | ||
self, gateway: Gateway, payment_information: "PaymentData" | ||
) -> "GatewayResponse": | ||
pass | ||
|
||
@abstractmethod | ||
def process_payment( | ||
self, gateway: Gateway, payment_information: "PaymentData" | ||
) -> "GatewayResponse": | ||
pass | ||
|
||
@abstractmethod | ||
def create_payment_form( | ||
self, data, gateway: Gateway, payment_information: "PaymentData" | ||
) -> "GatewayResponse": | ||
pass | ||
|
||
@abstractmethod | ||
def get_client_token(self, gateway: Gateway, token_config: "TokenConfig") -> str: | ||
pass | ||
|
||
@abstractmethod | ||
def list_payment_sources( | ||
self, gateway: Gateway, customer_id: str | ||
) -> List["CustomerSource"]: | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.