fix(payment): reject duplicate provider transactions
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -296,9 +296,11 @@ class Gateway {
|
||||
|
||||
$current = (string) ($order['status'] ?? '');
|
||||
|
||||
// 幂等:已支付/已交付/已完成视为成功,不重复处理(回调可能多次到达)
|
||||
// 幂等:仅同一交易号的重复回调可视为成功。不同交易号意味着
|
||||
// 用户可能重复付款,不能静默 ACK 为已正确同步。
|
||||
if (in_array($current, ['paid', 'delivered', 'completed'], true)) {
|
||||
return true;
|
||||
$stored_transaction = sanitize_text_field((string) ($order['payment_transaction_id'] ?? ''));
|
||||
return $stored_transaction !== '' && hash_equals($stored_transaction, $transaction_id);
|
||||
}
|
||||
// 只允许从未支付态完成
|
||||
if (!in_array($current, ['created', 'pending'], true)) {
|
||||
|
||||
Reference in New Issue
Block a user