codebuglab/laravel-like4card

Integrate Like4Card API with Laravel

v0.0.7-alpha 2021-05-31 11:19 UTC

This package is auto-updated.

Last update: 2024-11-15 18:36:32 UTC


README

Integrate Like4Card api with Laravel.

Laravel Like4Card

Table of Contents

Installation

Require via composer

composer require codebuglab/laravel-like4card

In config/app.php file

'providers' => [
  ...
  CodeBugLab\Like4Card\Like4CardServiceProvider::class,
];

Config

Add your info to .env file

LIKE4CARD_DEVICE_ID=xxx
LIKE4CARD_EMAIL=xxx
LIKE4CARD_PASSWORD=xxx
LIKE4CARD_SECURITY_CODE=xxx
LIKE4CARD_LANG_ID=xxx

The config file looks like

[
  'device_id' => env('LIKE4CARD_DEVICE_ID', null),
  'email' => env('LIKE4CARD_EMAIL', null),
  'password' => env('LIKE4CARD_PASSWORD', null),
  'security_code' => env('LIKE4CARD_SECURITY_CODE', null),
  'lang_id' => env('LIKE4CARD_LANG_ID', 1)
]

Available api methods

Get merchant balance

Operation that help the merchant to get his balance and user Id.

$response = Like4Card::balance();

$response is an Object with the following parameters

Categories

Operation to get all categories available for this merchant.

$response = Like4Card::categories();

$response is an Array with the following parameters

Products by products ids

There's an issue in API request param: This will only get the first ID

Operation to get all products available by an array of products identifiers.

$product_ids = [1, 2, 3]; // required products ids
$response = Like4Card::products($product_ids);

$response is an array. Each element is an object with the following parameters

When no products found: $response is a string with error message

Each optional field has

Products by category

Operation to get all products available by category id.

$category_id = 1;
$response = Like4Card::getProductsByCategoryId($category_id);

$response is an array. Each element is an object with the following parameters.

When no products found: $response is a string with error message

Each optional field has

Get all orders

Operation to get all orders made by this merchant. This api can receive the following options:

// all options are not required
$options = [
  'page' => 1,
  'orderType' => 'asc',
  'from' => 1621327053,
  'to' => 1623998253
];
$response = Like4Card::orders($options);

$response is an Object with the following parameters

Get an order info

Operation to get one order details by its id.

$order_id = 1;
$response = Like4Card::order($order_id);

$response is an Object with the following parameters

each serial object has

Create new order

Operation to create new order. This api can receive the following parameters:

$product_id = 1;
$local_id = 123; // the id from your local orders table

$response = Like4Card::createOrder($product_id, $local_id);

$response is an Object with the following parameters

API Exceptions

If the API response = 0, the service throws an exception. It could be one of the following exceptions

Wrong credentials

It been thrown if you enter wrong deviceId, username, password or securityCode.

example

  try {
    $response = Like4Card::balance();
  } catch (\CodeBugLab\Like4Card\Exceptions\WrongCredentialsException $ex) {
    echo $ex->getMessage(); // "Incorrect Login - invalid email or password"
  }

Products not available

It's been thrown if no products found with given category id or products ids array

example

  try {
    $data = Like4Card::getProductsByCategoryId(1);
  } catch (\CodeBugLab\Like4Card\Exceptions\ProductsNotFoundException $ex) {
    echo $ex->getMessage(); // "No available products"
  }

License

Laravel Like4Card is a free software distributed under the terms of the MIT license.