Looking to hire Laravel developers? Try LaraJobs

laravel-infobip maintained by zenepay

Author
Zenepay
Last update
2026/11/11 07:59 (1.0.0)
License
Links
Downloads
0
Tags

Comments
comments powered by Disqus

Laravel Infobip

Laravel client for the Infobip People API: read and update person profiles, batch updates, and people events.

Laravel discovers the service provider and the Infobip facade automatically.

Requirements

  • PHP 8.2+
  • Laravel 10, 11, 12, or 13

Install

From Packagist, after you publish the package:

composer require zenepay/laravel-infobip

From GitHub before it is on Packagist, add the repository and require the branch:

composer config repositories.infobip vcs https://github.com/YOUR-ACCOUNT/laravel-infobip
composer require zenepay/laravel-infobip:dev-main

The Composer package name is zenepay/laravel-infobip. Point the VCS repository at the GitHub account that owns the repository.

Configuration

INFOBIP_API_ADDRESS=https://xxxx.api.infobip.com
INFOBIP_API_ACCESS_TOKEN=
INFOBIP_TOKEN_SCHEME=App
INFOBIP_HTTP_VERIFY=true
INFOBIP_HTTP_PROXY=
INFOBIP_HTTP_TIMEOUT=30

INFOBIP_API_ADDRESS is the base URL from the Infobip portal, with no path and no trailing slash. The token is sent as Authorization: App {token}.

Publish the config file when you want to edit attribute filters or HTTP options in PHP:

php artisan vendor:publish --tag=infobip-config

config/infobip.php has empty attribute allow-lists, so every custom attribute is sent. Add keys to a list to drop anything else. Person updates filter customAttributes only. Purchase and referral events are filtered only when the payload includes a customAttributes array; those filtered values become the event properties.

The current tanos module disables TLS verification and uses the shared API proxy. Match that only if this app still needs it:

INFOBIP_HTTP_VERIFY=false
INFOBIP_HTTP_PROXY="${API_PROXY}"

Usage

use Zenepay\Infobip\Facades\Infobip;

$person = Infobip::getPerson('ada@example.com', 'EMAIL');

$people = Infobip::getPeople(limit: 1000, page: 1);

Infobip::updatePerson('ada@example.com', 'EMAIL', [
    'firstName' => 'Ada',
    'lastName' => 'Lovelace',
    'customAttributes' => [
        'Member ID' => '111222555',
        'Member Tier' => 'C1',
        'Point' => 305,
    ],
]);

Infobip::batchUpdatePeople([
    [
        'identifier' => 'ada@example.com',
        'type' => 'EMAIL',
        'customAttributes' => [
            'Member ID' => '12345',
            'Point' => 110,
        ],
    ],
]);

Infobip::sendEventPurchase([
    'email' => 'ada@example.com',
    'paymentType' => 'online',
    'transactionType' => 'TS',
    'productName' => 'Bag',
    'brandCode' => 'EXAMPLE',
    'netSale' => 1500,
    'outletCode' => 'STORE1',
    'quantity' => 1,
    'price' => 1500,
]);

Infobip::sendPeopleEvent('ada@example.com', 'EMAIL', 'purchase', [
    'productName' => 'Bag',
    'quantity' => 1,
]);

Infobip::sendEventReferralRedeem([
    [
        'email' => 'ada@example.com',
        'referralCode' => 'REF1',
        'rewardCode' => 'RW1',
    ],
]);

sendEventPurchase() and sendEventReferralRedeem() return null when the email is missing. batchUpdatePeople() turns an empty success body into results[0]->status = 201, because Infobip often returns no JSON on success. A JSON error body is returned as Infobip sent it.

getPeople() requests page 1 unless you pass another page. The in-app module always requested page 100.

What stays in the application

app/Modules/Infobip/Controllers/InfobipController.php loads Club21 sales, members, vouchers, and promotions, then calls this client. That sync is not part of the package. Keep the controller in the app and point it at Zenepay\Infobip\Infobip when you switch.

Tests

composer install
composer test

Tests fake the HTTP client. They do not call Infobip.

Publishing the GitHub repository

This folder is the package root. The parent application gitignores /packages/, so initialize git here rather than committing the package into the application repository.

cd packages/laravel-infobip
git init
git add .
git commit -m "Initial Infobip Laravel package"
git branch -M main
git remote add origin git@github.com:YOUR-ACCOUNT/laravel-infobip.git
git push -u origin main

On GitHub, add a description and the topics laravel and infobip. To list it on Packagist, submit the repository URL at packagist.org/packages/submit and add the Packagist webhook.

License

MIT. See LICENSE.