PHP code example of giftd / giftd-php-client
1. Go to this page and download the library: Download giftd/giftd-php-client library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
giftd / giftd-php-client example snippets
$basketTotal = 900;
$promoCode = '1234-5678-9876-4321';
$giftdUserId = 1234;
$giftdApiKey = '7815696ecbf1c96e6894b779456d330e';
$apiClient = new Giftd\ApiClient($giftdUserId, $giftdApiKey);
$card = $apiClient->checkByToken($promoCode, $basketTotal);
if ($card) {
if ($card->is_available) {
echo "Available amount: {$card->amount_available}; minimum amount total: {$card->min_amount_total}";
// You may redeem this promocode after user finishes the order (i.e. charge the card):
// $apiClient->charge($promoCode, $card->amount_available)
} else {
echo "No amount available on the gift card";
}
} else {
echo "Wrong token passed, gift card not found!";
}
composer