feat(payment): finish Zibll key contract and wire checkout gateways
Drop dual-read payment runtime fallbacks, align PHP schema to Vue keys, read gateway credentials only from aksrt_settings with enable toggles, expose configured adapters at checkout, fix credits pay signatures, and apply order expiry settings. Wire orphan order/card-pass/withdrawal schema pages; delete unused Payment* wrappers.
This commit is contained in:
@@ -351,7 +351,13 @@ class AKSRT_Balance_Gateway implements AKSRT_Payment_Gateway_Interface {
|
||||
}
|
||||
|
||||
public function is_configured(): bool {
|
||||
return class_exists('AKSRT_Credits');
|
||||
if (!class_exists('AKSRT_Credits')) {
|
||||
return false;
|
||||
}
|
||||
if (class_exists('AKSRT_Settings_Payment_Runtime')) {
|
||||
return AKSRT_Settings_Payment_Runtime::is_gateway_enabled('balance');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function create_payment(array $order): array {
|
||||
@@ -362,6 +368,7 @@ class AKSRT_Balance_Gateway implements AKSRT_Payment_Gateway_Interface {
|
||||
$user_id = (int) ($order['user_id'] ?? 0);
|
||||
$amount = (float) ($order['amount'] ?? 0);
|
||||
$credits_cost = (int) ceil($amount * 100); // 1 元 = 100 积分
|
||||
$order_number = (string) ($order['order_number'] ?? '');
|
||||
|
||||
$balance = AKSRT_Credits::balance($user_id);
|
||||
|
||||
@@ -369,18 +376,23 @@ class AKSRT_Balance_Gateway implements AKSRT_Payment_Gateway_Interface {
|
||||
return ['success' => false, 'message' => __('余额不足', 'aksrt')];
|
||||
}
|
||||
|
||||
// Deduct credits
|
||||
$result = AKSRT_Credits::deduct($user_id, $credits_cost, 'order_payment', sprintf(__('订单 %s 支付', 'aksrt'), $order['order_number'] ?? ''));
|
||||
$result = AKSRT_Credits::deduct(
|
||||
$user_id,
|
||||
$credits_cost,
|
||||
'order_payment',
|
||||
['order' => $order_number],
|
||||
sprintf(__('订单 %s 支付', 'aksrt'), $order_number)
|
||||
);
|
||||
|
||||
if ($result) {
|
||||
return [
|
||||
'success' => true,
|
||||
'transaction_id' => 'BAL_' . ($order['order_number'] ?? time()),
|
||||
'message' => __('余额支付成功', 'aksrt'),
|
||||
];
|
||||
if (is_wp_error($result)) {
|
||||
return ['success' => false, 'message' => $result->get_error_message() ?: __('扣款失败', 'aksrt')];
|
||||
}
|
||||
|
||||
return ['success' => false, 'message' => __('扣款失败', 'aksrt')];
|
||||
return [
|
||||
'success' => true,
|
||||
'transaction_id' => 'BAL_' . ($order_number !== '' ? $order_number : (string) time()),
|
||||
'message' => __('余额支付成功', 'aksrt'),
|
||||
];
|
||||
}
|
||||
|
||||
public function verify_callback(WP_REST_Request $request): array {
|
||||
@@ -418,12 +430,18 @@ class AKSRT_Balance_Gateway implements AKSRT_Payment_Gateway_Interface {
|
||||
$user_id = (int) $order['user_id'];
|
||||
$credits_refund = (int) ceil($amount * 100);
|
||||
|
||||
$result = AKSRT_Credits::add($user_id, $credits_refund, 'order_refund', sprintf(__('订单 %s 退款', 'aksrt'), $order_number));
|
||||
$result = AKSRT_Credits::add(
|
||||
$user_id,
|
||||
$credits_refund,
|
||||
'order_refund',
|
||||
['order' => $order_number],
|
||||
sprintf(__('订单 %s 退款', 'aksrt'), $order_number)
|
||||
);
|
||||
|
||||
if ($result) {
|
||||
return ['success' => true, 'refund_id' => 'BAL_REF_' . $order_number, 'message' => __('退款成功', 'aksrt')];
|
||||
if (is_wp_error($result)) {
|
||||
return ['success' => false, 'message' => $result->get_error_message() ?: __('退款失败', 'aksrt')];
|
||||
}
|
||||
|
||||
return ['success' => false, 'message' => __('退款失败', 'aksrt')];
|
||||
return ['success' => true, 'refund_id' => 'BAL_REF_' . $order_number, 'message' => __('退款成功', 'aksrt')];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user