Skip to content

b24io/loyalty-php-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

loyalty-php-sdk

License Total Downloads

Loyalty PHP SDK is a tool for work with REST-API Bitrix24 Application Loyalty Program and bonus cards for Bitrix24 CRM

  • Loyalty app adds bonus card for Bitrix24 client profile in CRM
  • Loyalty app support transactions for payment and accrual operations
  • store percentage of discount
  • operations with cards: create, read, delete, block

Documentation

Installation

Via Composer

$ composer require b24io/loyalty-php-sdk

Versions

loyalty-php-sdk
version
support status build
status
REST-API
version
PHP
versions
v4.x 🟩 active integration tests
phpstan
2 8.2,8.3
v3.x 🟨 bugfix only integration tests
phpstan
2 7.4
v2 πŸŸ₯ end of life ☠️ 1 7.4
v1 πŸŸ₯ end of life ☠️ 1 7.4

Requirements

Loyalty PHP SDK works with PHP 8.2 or above, need ext-json and ext-curl support

Authentication with admin and user roles

SDK can work with two roles:

  • admin - can work with all cards in his account and loyalty application instance
  • user - can work only with his own card

We work with many accounts, each account has a CLIENT_API_KEY If you want work in admin role you must use ADMIN_API_KEY to sign queries. If you want work with client role in JS you must use CLIENT_API_KEY and CARD_UUID as user API key.

Domain entities available from REST-API

Legend

  • βœ… β€” available wia rest-api and implemented in PHP-SDK
  • πŸ›  β€” available wia rest-api and not implemented in PHP-SDK
  • ❌ β€” not implemented in rest-api

Cards

Work with card as an admin role

Method Status Description
list βœ… get card list with page navigation
getById βœ… get card by uuid
count βœ…οΈ count cards
delete πŸ› οΈ delete card by uuid
add βœ…οΈ add new card
block ❌️ block card by uuid
unblock ❌️ unblock card by uuid
setLevel ❌️ set card level by uuid
setPercentage ❌️ set card percentage by uuid

Work with card as a user role

Method Status Description
getById πŸ›  get card by uuid

If you need export all cards, you can use CardsFetcher

CardLevels

Work with card levels as an admin role

Method Status Description
list πŸ›  get card level list
add πŸ›  add new card level
delete πŸ›  delete card level
update ❌️ update card level

Transactions

Work with transactions as an admin role.

Transactions service contains methods, list method work with pagination

Method Description
list get transactions list for all cards with pagination
count count transactions
getByCardNumber get transactions list for current card number
processAccrualTransactionByCardNumber process accrual transaction
processPaymentTransactionByCardNumber process payment transaction

if you want read all transactions without pagination you can work with TransactionsFetcherAll fetcher methods return generator, under the hood fetcher use pagination.

Method Description
list get transactions list for all cards
listByCardNumber list all transactions for current card

Work with transactions as an user role

Method Status Description
getByCardId πŸ›  get transactions list for current card

Contacts

Work with contacts as an admin role

Method Status Description
list βœ… get contacts list
getById βœ… get contact by id
add βœ… add new contact
update ❌️ update contact
delete ❌️ delete contact
count βœ… count contacts
startAuthByPhone ❌️ start auth attempt by phone
finishAuth ❌️ finish auth attempt

Work with contacts as an user role

Method Status Description
getById πŸ›  get contact by id
startAuthByPhone πŸ›  start auth attempt by phone
finishAuth πŸ›  finish auth attempt

If you need export all contacts, you can use ContactsFetcher

Company

Work with company as an admin role

Method Status Description
current ❌ get current company
add ❌️ add company
update ❌️ update company
delete ❌️ delete company

Work with company as an user role

Method Status Description
current πŸ›  get current company

ApplicationJournal

Work with application journal as an admin role

Method Status Description
list πŸ›  get application journal items list with page navigation
getById πŸ›  get application journal item by id

TouchPoints

Work with touch points as an admin role

Method Status Description
list πŸ›  get touch points list with page navigation
getById πŸ›  get touch point item by id
add πŸ›  add new touch point
update ❌️ update touch point
delete πŸ› οΈ delete touch point

Basic Usage

Command line utilities

Command line utilities for work via REST-API

php bin/console
  • cards:export Export loyalty cards to csv file
  • transactions:bulk-transaction Bulk transaction to all active cards: accrual or payment
  • transactions:load-from-file Process transactions from csv file
  • transactions:export Export transactions to csv file

Submitting bugs and feature requests

Bugs and feature request are tracked on GitHub

Development

Testing

Run static analysis tool

make phpstan

Support

Security

If you discover any security related issues, please contact us at app@b24.io

License

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