mirror of
https://github.com/myronblair/do-server-config
synced 2026-07-28 05:22:53 -05:00
[orbis] Weekly backup 2026-07-07 — 318 files changed, 48597 insertions(+), 7 deletions(-)
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* Tom's Java Jive - Redeem Gift Card API
|
||||
*/
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
require_once __DIR__ . '/../includes/functions.php';
|
||||
require_once __DIR__ . '/../includes/auth.php';
|
||||
require_once __DIR__ . '/../includes/loyalty.php';
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||
jsonResponse(['error' => 'Method not allowed'], 405);
|
||||
}
|
||||
|
||||
if (!CustomerAuth::isLoggedIn()) {
|
||||
jsonResponse(['error' => 'Please log in to redeem a gift card'], 401);
|
||||
}
|
||||
|
||||
$customer = CustomerAuth::getFullUser();
|
||||
$input = json_decode(file_get_contents('php://input'), true);
|
||||
|
||||
$result = loyalty()->redeemGiftCardToWallet($customer['customer_id'], $input['code'] ?? '');
|
||||
|
||||
if (!$result['success']) {
|
||||
jsonResponse(['error' => $result['error']], 400);
|
||||
}
|
||||
|
||||
jsonResponse([
|
||||
'success' => true,
|
||||
'amount' => $result['amount'],
|
||||
'new_balance' => $result['new_balance'],
|
||||
'message' => formatCurrency($result['amount']) . ' has been added to your wallet!'
|
||||
]);
|
||||
Reference in New Issue
Block a user