'invalid payload'])); } $type = $event['type']; $data = $event['data']['object'] ?? []; switch($type) { case 'checkout.session.completed': $email = $data['customer_email'] ?? ''; $amount = ($data['amount_total'] ?? 0) / 100; file_put_contents("$logDir/stripe-payments.log", date('Y-m-d H:i:s')." PAYMENT $email {$amount}EUR\n", FILE_APPEND); break; case 'customer.subscription.created': case 'customer.subscription.updated': $status = $data['status'] ?? ''; $cid = $data['customer'] ?? ''; file_put_contents("$logDir/stripe-subs.log", date('Y-m-d H:i:s')." SUB $cid $status\n", FILE_APPEND); break; case 'invoice.paid': $email = $data['customer_email'] ?? ''; $total = ($data['total'] ?? 0) / 100; file_put_contents("$logDir/stripe-invoices.log", date('Y-m-d H:i:s')." INVOICE $email {$total}EUR\n", FILE_APPEND); break; } http_response_code(200); echo json_encode(['received'=>true,'type'=>$type]);