codebuglab/laravel-like4card
Composer 安装命令:
composer require codebuglab/laravel-like4card
包简介
Integrate Like4Card API with Laravel
README 文档
README
Integrate Like4Card api with Laravel.
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
| Parameter | Description |
|---|---|
| response | 1 for success, 0 for failure |
| userId | merchant account identifier |
| balance | merchant account balance |
| currency |
Categories
Operation to get all categories available for this merchant.
$response = Like4Card::categories();
$response is an Array with the following parameters
| Parameter | Description |
|---|---|
| id | - |
| categoryParentId | - |
| categoryName | - |
| amazonImage | - |
| childs | Array of sub-categories with same parent category structure |
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:
$responseis astringwith error message
| Parameter | Description |
|---|---|
| productId | - |
| categoryId | - |
| productName | - |
| productImage | - |
| productCurrency | - |
| productPrice | that represents the product price including vat that the merchant paid for product |
| productPriceWithoutVat | - |
| sellPrice | that represents the price the customer pays for the product to the merchant. |
| sellPriceWithoutVat | - |
| available | determines if stock for this product is available or not. |
| optionalFieldsExist | 1 optional fields required, 0 there are no required optional fields. |
| productOptionalFields | array of optional fields where |
| vatAmount | - |
| vatPercentage | - |
Each optional field has
| Parameter | Description |
|---|---|
| id | identifier of the optional field |
| required | '1' means it's required, '0' means it's optional and not required |
| defaultValue | default value for this field |
| hint | placeholder for this field |
| label | label displayed on top of this field on UI |
| fieldTypeId | 1 plaintext ,7 email address, 10 phone number ,other number plaintext |
| fieldCode | |
| options | array of choices in case option is multi choice field |
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:
$responseis astringwith error message
| Parameter | Description |
|---|---|
| productId | - |
| categoryId | - |
| productName | - |
| productImage | - |
| productCurrency | - |
| productPrice | that represents the product price including vat that the merchant paid for product |
| productPriceWithoutVat | - |
| sellPrice | that represents the price the customer pays for the product to the merchant. |
| sellPriceWithoutVat | - |
| available | determines if stock for this product is available or not. |
| optionalFieldsExist | 1 optional fields required, 0 there are no required optional fields. |
| productOptionalFields | array of optional fields where |
| vatAmount | - |
| vatPercentage | - |
Each optional field has
| Parameter | Description |
|---|---|
| id | identifier of the optional field |
| required | '1' means it's required, '0' means it's optional and not required |
| defaultValue | default value for this field |
| hint | placeholder for this field |
| label | label displayed on top of this field on UI |
| fieldTypeId | 1 plaintext ,7 email address, 10 phone number ,other number plaintext |
| fieldCode | |
| options | array of choices in case option is multi choice field |
Get all orders
Operation to get all orders made by this merchant. This api can receive the following options:
| Parameter | Description |
|---|---|
| page | page number(default is 1), where page size is fixed value of 100 order per page |
| order_type | desc or asc, arranged by order create date orderCreateDate |
| from | get all orders with create date bigger than this timestamp |
| to | get all orders with create date less than this timestamp |
// 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
| Parameter | Description |
|---|---|
| orderNumber | - |
| orderFinalTotal | represent the price the merchant will pay for LikeCard for this order |
| currencySymbol | - |
| orderCreateDate | - |
| orderCurrentStatus | - |
| orderPaymentMethod | - |
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
| Parameter | Description |
|---|---|
| response | 1 for success, 0 for failure |
| serials | array of objects, each object represent a purchased product details. |
each serial object has
| Parameter | Description |
|---|---|
| serialCode | is the encrypted serial given to customer to be used |
| serialNumber | is the card manufacturing No |
| validTo | is the validation time for card |
Create new order
Operation to create new order. This api can receive the following parameters:
| Parameter | Description |
|---|---|
| product_id | product identifier Required |
| reference_id | merchant reference (Required and must be unique) |
| quantity | always 1 |
$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
| Parameter | Description |
|---|---|
| response | 1 for success, 0 for failure |
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.
codebuglab/laravel-like4card 适用场景与选型建议
codebuglab/laravel-like4card 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 99 次下载、GitHub Stars 达 1, 最近一次更新时间为 2021 年 05 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「api」 「gateway」 「laravel」 「online」 「Egypt」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 codebuglab/laravel-like4card 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 codebuglab/laravel-like4card 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 codebuglab/laravel-like4card 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
repository php library
Payyo Gateway for the Omnipay payment processing library
A PSR-7 compatible library for making CRUD API endpoints
Client library to send SMS using Comilio SMS Gateway API (https://www.comilio.it)
Alfabank REST API integration
GovPayNet driver for the Omnipay payment processing library
统计信息
- 总下载量: 99
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 21
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-05-19
