refactor: replace direct WeChat/Alipay with unified pay-api gateway
Switch from direct WeChat Pay / Alipay integrations to the unified
宇之然 pay-api gateway (HMAC-SHA256 auth). Removes wechat_pay.py,
keeps PaymentGateway abstraction, adds UnifiedPayService. Simplifies
payment.py create_order to {plan, pay_type} params. Single webhook
endpoint replaces separate WeChat/Alipay notify handlers.
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import Optional, Dict, Any
|
||||
|
||||
|
||||
class PaymentGateway(ABC):
|
||||
name: str = ""
|
||||
|
||||
@abstractmethod
|
||||
async def create_order(self, order_no: str, amount: int, description: str,
|
||||
**kwargs) -> Dict[str, Any]:
|
||||
...
|
||||
|
||||
@abstractmethod
|
||||
async def query_order(self, order_no: str) -> Dict[str, Any]:
|
||||
...
|
||||
|
||||
@abstractmethod
|
||||
async def refund(self, order_no: str, amount: int, reason: str = "") -> Dict[str, Any]:
|
||||
...
|
||||
|
||||
@abstractmethod
|
||||
async def query_refund(self, order_no: str) -> Dict[str, Any]:
|
||||
...
|
||||
|
||||
@abstractmethod
|
||||
def verify_callback(self, headers: dict, body: str) -> bool:
|
||||
...
|
||||
|
||||
@abstractmethod
|
||||
def parse_callback(self, body: str, headers: dict) -> Dict[str, Any]:
|
||||
...
|
||||
|
||||
def supports(self, pay_type: str) -> bool:
|
||||
return pay_type in self.supported_types
|
||||
|
||||
supported_types: list = []
|
||||
Reference in New Issue
Block a user