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:
2026-07-11 17:42:35 +08:00
parent 12c31ad82b
commit c93b303453
16 changed files with 298 additions and 228 deletions
@@ -20,6 +20,10 @@ class AKSRT_Alipay_Gateway implements AKSRT_Payment_Gateway_Interface {
}
public function is_configured(): bool {
if (class_exists('AKSRT_Settings_Payment_Runtime')
&& !AKSRT_Settings_Payment_Runtime::is_gateway_enabled('alipay')) {
return false;
}
$config = $this->get_config();
return !empty($config['app_id']) && !empty($config['private_key']) && !empty($config['alipay_public_key']);
}
@@ -165,24 +169,19 @@ class AKSRT_Alipay_Gateway implements AKSRT_Payment_Gateway_Interface {
}
private function get_config(): array {
// 优先从统一设置读取(schema 保存的 key)
if (class_exists('AKSRT_Settings')) {
$all = AKSRT_Settings::get_all();
if (!empty($all['alipay_appid'])) {
return [
'app_id' => $all['alipay_appid'] ?? '',
'private_key' => $all['alipay_privatekey'] ?? '',
'alipay_public_key' => $all['alipay_publickey'] ?? '',
'return_url' => $all['alipay_return_url'] ?? '',
'notify_url' => $all['alipay_notify_url'] ?? '',
'payment_type' => $all['alipay_payment_type'] ?? 'page',
'sign_type' => $all['alipay_sign_type'] ?? 'RSA2',
];
}
if (!class_exists('AKSRT_Settings')) {
return [];
}
// 回退到独立 option
$settings = get_option('aksrt_payment_alipay', []);
return is_array($settings) ? $settings : [];
$all = AKSRT_Settings::get_all();
return [
'app_id' => (string) ($all['alipay_appid'] ?? ''),
'private_key' => (string) ($all['alipay_privatekey'] ?? ''),
'alipay_public_key' => (string) ($all['alipay_publickey'] ?? ''),
'return_url' => (string) ($all['alipay_return_url'] ?? ''),
'notify_url' => (string) ($all['alipay_notify_url'] ?? ''),
'payment_type' => (string) ($all['alipay_payment_type'] ?? 'page'),
'sign_type' => (string) ($all['alipay_sign_type'] ?? 'RSA2'),
];
}
private function create_sdk(array $config): \Yurun\PaySDK\AlipayApp\SDK {
@@ -20,6 +20,10 @@ class AKSRT_PayPal_Gateway implements AKSRT_Payment_Gateway_Interface {
}
public function is_configured(): bool {
if (class_exists('AKSRT_Settings_Payment_Runtime')
&& !AKSRT_Settings_Payment_Runtime::is_gateway_enabled('paypal')) {
return false;
}
$config = $this->get_config();
return !empty($config['client_id']) && !empty($config['client_secret']);
}
@@ -128,21 +132,16 @@ class AKSRT_PayPal_Gateway implements AKSRT_Payment_Gateway_Interface {
}
private function get_config(): array {
// 优先从统一设置读取(schema 保存的 key)
if (class_exists('AKSRT_Settings')) {
$all = AKSRT_Settings::get_all();
if (!empty($all['paypal_client_id'])) {
return [
'client_id' => $all['paypal_client_id'] ?? '',
'client_secret' => $all['paypal_client_secret'] ?? '',
'currency' => $all['paypal_currency'] ?? 'USD',
'mode' => !empty($all['paypal_sandbox']) ? 'sandbox' : 'live',
];
}
if (!class_exists('AKSRT_Settings')) {
return [];
}
// 回退到独立 option
$settings = get_option('aksrt_payment_paypal', []);
return is_array($settings) ? $settings : [];
$all = AKSRT_Settings::get_all();
return [
'client_id' => (string) ($all['paypal_client_id'] ?? ''),
'client_secret' => (string) ($all['paypal_client_secret'] ?? ''),
'currency' => (string) ($all['paypal_currency'] ?? 'USD'),
'mode' => !empty($all['paypal_sandbox']) ? 'sandbox' : 'live',
];
}
/**
@@ -20,6 +20,10 @@ class AKSRT_Stripe_Gateway implements AKSRT_Payment_Gateway_Interface {
}
public function is_configured(): bool {
if (class_exists('AKSRT_Settings_Payment_Runtime')
&& !AKSRT_Settings_Payment_Runtime::is_gateway_enabled('stripe')) {
return false;
}
$config = $this->get_config();
return !empty($config['secret_key']) && !empty($config['publishable_key']);
}
@@ -233,22 +237,17 @@ class AKSRT_Stripe_Gateway implements AKSRT_Payment_Gateway_Interface {
}
private function get_config(): array {
// 优先从统一设置读取(schema 保存的 key)
if (class_exists('AKSRT_Settings')) {
$all = AKSRT_Settings::get_all();
if (!empty($all['stripe_secret_key'])) {
return [
'secret_key' => $all['stripe_secret_key'] ?? '',
'publishable_key' => $all['stripe_publishable_key'] ?? '',
'webhook_secret' => $all['stripe_webhook_secret'] ?? '',
'currency' => $all['stripe_currency'] ?? 'usd',
'mode' => !empty($all['stripe_test_mode']) ? 'test' : 'live',
];
}
if (!class_exists('AKSRT_Settings')) {
return [];
}
// 回退到独立 option
$settings = get_option('aksrt_payment_stripe', []);
return is_array($settings) ? $settings : [];
$all = AKSRT_Settings::get_all();
return [
'secret_key' => (string) ($all['stripe_secret_key'] ?? ''),
'publishable_key' => (string) ($all['stripe_publishable_key'] ?? ''),
'webhook_secret' => (string) ($all['stripe_webhook_secret'] ?? ''),
'currency' => (string) ($all['stripe_currency'] ?? 'usd'),
'mode' => !empty($all['stripe_test_mode']) ? 'test' : 'live',
];
}
private function create_client(array $config): void {
@@ -20,6 +20,10 @@ class AKSRT_WechatPay_Gateway implements AKSRT_Payment_Gateway_Interface {
}
public function is_configured(): bool {
if (class_exists('AKSRT_Settings_Payment_Runtime')
&& !AKSRT_Settings_Payment_Runtime::is_gateway_enabled('wechatpay')) {
return false;
}
$config = $this->get_config();
return !empty($config['mch_id']) && !empty($config['key']);
}
@@ -206,24 +210,19 @@ class AKSRT_WechatPay_Gateway implements AKSRT_Payment_Gateway_Interface {
}
private function get_config(): array {
// 优先从统一设置读取(schema 保存的 key)
if (class_exists('AKSRT_Settings')) {
$all = AKSRT_Settings::get_all();
if (!empty($all['wechat_merchantid'])) {
return [
'mch_id' => $all['wechat_merchantid'] ?? '',
'key' => $all['wechat_jsapi'] ?? '',
'appid' => $all['wechat_appid'] ?? '',
'appsecret' => $all['wechat_appsecret'] ?? '',
'cert_path' => $all['wechat_cert_path'] ?? '',
'key_path' => $all['wechat_key_path'] ?? '',
'payment_type' => $all['wechat_payment_type'] ?? 'native',
];
}
if (!class_exists('AKSRT_Settings')) {
return [];
}
// 回退到独立 option
$settings = get_option('aksrt_payment_wechatpay', []);
return is_array($settings) ? $settings : [];
$all = AKSRT_Settings::get_all();
return [
'mch_id' => (string) ($all['wechat_merchantid'] ?? ''),
'key' => (string) ($all['wechat_jsapi'] ?? ''),
'appid' => (string) ($all['wechat_appid'] ?? ''),
'appsecret' => (string) ($all['wechat_appsecret'] ?? ''),
'cert_path' => (string) ($all['wechat_cert_path'] ?? ''),
'key_path' => (string) ($all['wechat_key_path'] ?? ''),
'payment_type' => (string) ($all['wechat_payment_type'] ?? 'native'),
];
}
private function create_sdk(array $config): \Yurun\PaySDK\Weixin\SDK {