Stripe live operatiu i descompte d stock al Google Sheet

This commit is contained in:
2026-04-09 09:46:07 +02:00
parent 70a20938ac
commit cd9633dfab
4 changed files with 87 additions and 4 deletions
+10 -2
View File
@@ -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;
}
}