1. Go to this page and download the library: Download mbsoft31/loyalty-rewards 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/ */
use LoyaltyRewards\Core\Services\LoyaltyService;
use LoyaltyRewards\Infrastructure\Repositories\{AccountRepository, TransactionRepository};
use LoyaltyRewards\Infrastructure\Audit\AuditLogger;
$accountRepo = new AccountRepository($pdo);
$transactionRepo = new TransactionRepository($pdo);
$auditLogger = new AuditLogger($pdo);
$loyaltyService = new LoyaltyService($accountRepo, $transactionRepo, $auditLogger, $rulesEngine);
use LoyaltyRewards\Core\Engine\RulesEngine;
use LoyaltyRewards\Rules\Earning\{CategoryMultiplierRule, TierBonusRule};
$rulesEngine = new RulesEngine();
// Base earning: 1 point per cent spent
$rulesEngine->addEarningRule(
new CategoryMultiplierRule('default', 1.0, ConversionRate::standard())
);
// Category bonuses
$rulesEngine->addEarningRule(
new CategoryMultiplierRule('premium', 5.0, ConversionRate::standard())
);
// Tier bonuses stack with category multipliers
$rulesEngine->addEarningRule(
new TierBonusRule('vip', 2.0, ConversionRate::standard())
);
use LoyaltyRewards\Core\Services\FraudDetectionService;
$fraudDetection = new FraudDetectionService();
// Automatic fraud checking on all transactions
$fraudResult = $fraudDetection->analyze($account, $amount, $context);
if ($fraudResult->shouldBlock()) {
throw new FraudDetectedException('Transaction blocked');
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.