BayRewards PHP SDK for Laravel Framework.
BayRewards revolutionizes e-commerce engagement with a comprehensive rewards platform. Seamlessly integrated with online stores, BayRewards offers point programs, referral incentives, and VIP perks to drive customer loyalty and sales. Elevate your e-commerce experience by incentivizing purchases, encouraging referrals, and rewarding VIP customers with exclusive benefits. With BayRewards, businesses can effortlessly cultivate customer relationships and foster brand advocacy, leading to increased retention and revenue.
- Requirements
- Installation
- Configuration
- Usage
- Testing
- Changelog
- Contributing
- Security Vulnerabilities
- Credits
- License
- PHP >= 8.2
- Laravel >= 10.0 | >= 11.0 | >= 12.0
You can install the package via Composer:
composer require palpalani/bayrewards-laravelThe package will automatically register its service provider and facade.
Publish the configuration file:
php artisan vendor:publish --tag="bayrewards-laravel-config"This will create a config/bayrewards-laravel.php file in your config directory.
Add the following to your .env file:
BAYREWARDS_BASE_URL=https://api.bayrewards.ioReplace the URL with your actual BayRewards API base URL.
The package provides a BayRewards facade for easy access:
use Palpalani\BayRewards\Facades\BayRewards;
$bayRewards = BayRewards::client();You can also use dependency injection:
use Palpalani\BayRewards\BayRewards;
class YourController
{
public function index()
{
$bayRewards = BayRewards::client();
// Use $bayRewards...
}
}Retrieve store details after integrating with BayRewards.io:
use Palpalani\BayRewards\Facades\BayRewards;
$bayRewards = BayRewards::client();
$store = $bayRewards->storeDetails()->get('<Store-Access-Token>');Get available features for a store:
use Palpalani\BayRewards\Facades\BayRewards;
$bayRewards = BayRewards::client();
$features = $bayRewards->getStoreFeatures()->get('<Store-Access-Token>');Create a new BayRewards activity:
use Palpalani\BayRewards\Facades\BayRewards;
$bayRewards = BayRewards::client();
$activity = $bayRewards->createActivity()->post('<Store-Access-Token>', [
'title' => 'Purchase Reward', // Required
'icon' => 'https://example.com/icon.png', // Required
]);Retrieve activity details:
use Palpalani\BayRewards\Facades\BayRewards;
$bayRewards = BayRewards::client();
$activity = $bayRewards->getActivity()->get('<Store-Access-Token>', '<Activity-ID>');Update an existing activity:
use Palpalani\BayRewards\Facades\BayRewards;
$bayRewards = BayRewards::client();
$activity = $bayRewards->updateActivity()->post('<Store-Access-Token>', [
'title' => 'Updated Purchase Reward', // Required
'icon' => 'https://example.com/updated-icon.png', // Required
'activity_id' => 12345, // Required
]);Update loyalty points for a customer:
use Palpalani\BayRewards\Facades\BayRewards;
$bayRewards = BayRewards::client();
$updatePoints = $bayRewards->updatePoints()->post('<Store-Access-Token>', [
'activity_id' => 12345, // Required - from activity payload
'customer_email' => '[email protected]', // Required
]);Retrieve all customers for a store with optional pagination and filtering:
use Palpalani\BayRewards\Facades\BayRewards;
$bayRewards = BayRewards::client();
// Get all customers with default pagination
$customers = $bayRewards->allCustomers()->get('<Store-Access-Token>');
// Get customers with custom pagination and filters
$customers = $bayRewards->allCustomers()->get(
'<Store-Access-Token>', // Required
1, // Optional - page number (default: 1)
25, // Optional - limit per page (default: 25)
'vip', // Optional - customer type filter (default: null)
'john' // Optional - search query (default: '')
);Run the tests with:
composer testFor test coverage:
composer test-coveragePlease see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.