Stripe live operatiu i descompte d stock al Google Sheet
This commit is contained in:
@@ -69,8 +69,15 @@ try {
|
||||
}
|
||||
|
||||
$alreadyUpdated = (string)($order['stock_updated'] ?? '') === '1';
|
||||
$stockResult = null;
|
||||
|
||||
if ($paymentStatus === 'paid' && !$alreadyUpdated) {
|
||||
$stockResult = kapvoe_decrement_sheet_stock($config, $order, $sessionId);
|
||||
|
||||
if (!($stockResult['ok'] ?? false)) {
|
||||
throw new RuntimeException('No s\'ha pogut actualitzar l\'stock al Google Sheet');
|
||||
}
|
||||
|
||||
kapvoe_mark_order_stock_updated($config, $sessionId);
|
||||
$alreadyUpdated = true;
|
||||
}
|
||||
@@ -82,7 +89,8 @@ try {
|
||||
'handled' => $type,
|
||||
'session_id' => $sessionId,
|
||||
'payment_intent_id' => $paymentIntentId,
|
||||
'already_updated' => $alreadyUpdated
|
||||
'already_updated' => $alreadyUpdated,
|
||||
'stock_result' => $stockResult
|
||||
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||
exit;
|
||||
|
||||
@@ -103,4 +111,4 @@ try {
|
||||
'error' => $e->getMessage()
|
||||
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user