giftd / giftd-php-client
GIFTD API PHP 客户端。允许检查促销代码
1.1.5
2018-08-07 10:05 UTC
Requires
- php: ^5.3.3 || ^7.0
This package is not auto-updated.
Last update: 2024-09-23 07:07:47 UTC
README
此仓库包含 Giftd.tech 项目 API 的 PHP 客户端。
查看完整的 API 文档。
要求
-
PHP 版本 >= 5.3.3
-
php-cURL 扩展
查看 example.php 以获取使用示例。
安装
composer require giftd/giftd-php-client
基本使用示例
<?php $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!"; } ?>
支持
请将您的问题和建议发送至 support@giftd.tech。