palpalani/bayrewards-laravel

BayRewards PHP SDK for Laravel Framework - A comprehensive rewards platform integration for e-commerce stores.

Fund package maintenance!
palpalani

Installs: 7 888

Dependents: 0

Suggesters: 0

Security: 0

Stars: 3

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/palpalani/bayrewards-laravel

v0.4.0 2025-11-10 16:29 UTC

README

Latest Version on Packagist Total Downloads PHP Version Laravel Version GitHub Tests Action Status GitHub Code Style Action Status License

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.

Table of Contents

Requirements

  • PHP >= 8.2
  • Laravel >= 10.0 | >= 11.0 | >= 12.0

Installation

You can install the package via Composer:

composer require palpalani/bayrewards-laravel

The package will automatically register its service provider and facade.

Configuration

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.

Environment Variables

Add the following to your .env file:

BAYREWARDS_BASE_URL=https://api.bayrewards.io

Replace the URL with your actual BayRewards API base URL.

Usage

Using the Facade

The package provides a BayRewards facade for easy access:

use Palpalani\BayRewards\Facades\BayRewards;

$bayRewards = BayRewards::client();

Using Dependency Injection

You can also use dependency injection:

use Palpalani\BayRewards\BayRewards;

class YourController
{
    public function index()
    {
        $bayRewards = BayRewards::client();
        // Use $bayRewards...
    }
}

Get Store Details

Retrieve store details after integrating with BayRewards.io:

use Palpalani\BayRewards\Facades\BayRewards;

$bayRewards = BayRewards::client();
$store = $bayRewards->storeDetails()->get('<Store-Access-Token>');

Get Store Features

Get available features for a store:

use Palpalani\BayRewards\Facades\BayRewards;

$bayRewards = BayRewards::client();
$features = $bayRewards->getStoreFeatures()->get('<Store-Access-Token>');

Create Activity

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
]);

Get Activity

Retrieve activity details:

use Palpalani\BayRewards\Facades\BayRewards;

$bayRewards = BayRewards::client();
$activity = $bayRewards->getActivity()->get('<Store-Access-Token>', '<Activity-ID>');

Update Activity

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

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' => 'customer@example.com', // Required
]);

Get Store Customers

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: '')
);

Testing

Run the tests with:

composer test

For test coverage:

composer test-coverage

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.