fix(payment): harden payment and refund chains
This commit is contained in:
1 parent
c70fbe9835
commit
53ff99f343
24 files changed
+993
-251
No files matched your search
@@ -41,20 +41,14 @@ class PayAfterSale {
|
||||
|
||||
$ok = false;
|
||||
if ($order_number !== '' && class_exists('\AKSRT\Payment\AfterSale')) {
|
||||
$user_id = isset($_POST['user_id']) ? (int) $_POST['user_id'] : 0;
|
||||
if ($user_id <= 0 && class_exists('\AKSRT\Payment\OrderRepository')) {
|
||||
$order = \AKSRT\Payment\OrderRepository::get_instance()->get($order_number);
|
||||
$user_id = (int) ($order['user_id'] ?? 0);
|
||||
}
|
||||
$id = \AKSRT\Payment\AfterSale::get_instance()->create([
|
||||
'order_number' => $order_number,
|
||||
'user_id' => $user_id,
|
||||
'type' => sanitize_key((string) wp_unslash($_POST['type'] ?? 'refund')),
|
||||
'reason' => sanitize_textarea_field((string) wp_unslash($_POST['reason'] ?? '')),
|
||||
'amount' => (float) ($_POST['amount'] ?? 0),
|
||||
'note' => sanitize_textarea_field((string) wp_unslash($_POST['note'] ?? '')),
|
||||
]);
|
||||
$ok = $id > 0;
|
||||
$ok = !is_wp_error($id) && $id > 0;
|
||||
}
|
||||
|
||||
$msg = $ok ? 'after_sale_created' : 'after_sale_create_failed';
|
||||
|
||||
Reference in new issue
Block a user