|
|
@@ -0,0 +1,84 @@
|
|
|
+<?php
|
|
|
+declare(strict_types=1);
|
|
|
+namespace SixShop\Payment\Contracts;
|
|
|
+
|
|
|
+use SixShop\Payment\Enum\PaymentBizEnum;
|
|
|
+
|
|
|
+class PaymentResponse {
|
|
|
+ public function __construct(public string $orderNo, public string $type, public array $raw)
|
|
|
+ {
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+class PaymentNotifyResult {
|
|
|
+ public string $orderNo;
|
|
|
+ public string $transactionId;
|
|
|
+ public float $amount;
|
|
|
+ public string $status; // success/fail
|
|
|
+ public array $raw;
|
|
|
+}
|
|
|
+
|
|
|
+class PaymentQueryResult {
|
|
|
+ public string $orderNo;
|
|
|
+ public string $status; // paid/unpaid/closed
|
|
|
+ public float $amount;
|
|
|
+ public array $raw;
|
|
|
+}
|
|
|
+
|
|
|
+class PaymentRefundResult {
|
|
|
+ public string $refundNo;
|
|
|
+ public string $orderNo;
|
|
|
+ public float $refundAmount;
|
|
|
+ public string $status; // success/fail
|
|
|
+ public array $raw;
|
|
|
+}
|
|
|
+
|
|
|
+class PaymentRefundQueryResult {
|
|
|
+ public string $refundNo;
|
|
|
+ public string $status; // success/fail/processing
|
|
|
+ public array $raw;
|
|
|
+}
|
|
|
+
|
|
|
+interface PaymentProviderInterface
|
|
|
+{
|
|
|
+ /**
|
|
|
+ * 创建支付订单(统一下单)
|
|
|
+ * @param array $order 订单信息(如订单号、金额、用户、商品等)
|
|
|
+ * @param PaymentBizEnum $bizType 业务类型
|
|
|
+ * @return PaymentResponse 下单结果(含支付跳转/二维码/表单/参数等)
|
|
|
+ * @throws PaymentException
|
|
|
+ */
|
|
|
+ public function create(array $order, PaymentBizEnum $bizType): PaymentResponse;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 处理支付回调(异步/同步通知)
|
|
|
+ * @param array $request 回调请求参数
|
|
|
+ * @return PaymentNotifyResult 处理结果(如订单号、金额、状态等)
|
|
|
+ * @throws PaymentException
|
|
|
+ */
|
|
|
+ public function notify(array $request): PaymentNotifyResult;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询支付订单状态
|
|
|
+ * @param string $orderNo 订单号
|
|
|
+ * @return PaymentQueryResult
|
|
|
+ * @throws PaymentException
|
|
|
+ */
|
|
|
+ public function query(string $orderNo): PaymentQueryResult;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 申请退款
|
|
|
+ * @param array $refund 退款信息(如原订单号、退款金额、原因等)
|
|
|
+ * @return PaymentRefundResult
|
|
|
+ * @throws PaymentException
|
|
|
+ */
|
|
|
+ public function refund(array $refund): PaymentRefundResult;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询退款状态
|
|
|
+ * @param string $refundNo 退款单号
|
|
|
+ * @return PaymentRefundQueryResult
|
|
|
+ * @throws PaymentException
|
|
|
+ */
|
|
|
+ public function refundQuery(string $refundNo): PaymentRefundQueryResult;
|
|
|
+}
|