lemonway/php-sdk
Composer 安装命令:
composer require lemonway/php-sdk
包简介
PHP SDK for Lemon Way API
README 文档
README
⚠️WARNING: This client is deprecated⚠️
This repository is in Maintenance Mode
We recommend our new partners to use DirectkitJson2 following this example
We will keep supporting this repository only for old customers who couldn't migrate to DirectkitJson2 (recommended) or SoapClient:
- we will make only minimum changes to fix small bugs.
- Big pull-request (which make a lot of changes in the code) will be rejected.
The LemonWay API (called Directkit) has two implementations: DirectkitJson2 and DirectkitXml. There are different ways to call the service depends on the implementation you chose.
The json format is usually more network-efficient, and simpler to integrate. It is the reason why the DirectkitJson2 is recommended.
Anyway, if you don't like the json format, you can also send SOAP (XML) requests to the DirectkitXml. There are 3 different ways to call the DirectkitXml:
- SoapClient: the casual method in PHP to consume any Web Service. It is the simplest way to access to DirectkitXml.
- SoapClient SDK: same with the first method, but all the structure of requests / responses are generated overhead with
wsdl2phpgenerator - LemonWay SDK: call the web service as a normal http request
curl_init. The SDK will help you to parse the SOAP response.
We recommend the first method with SoapClient because it is the standard solution in PHP world.
This example demonstrates the third method. The LemonWay SDK doesn't really have any advantages over other methods (see an opinionated comparisons here). But we will keep maintaining the LemonWay SDK for old customers.
Lemon Way PHP SDK (This SDK is only used with Direckit XML)
Lemon Way SDK is a PHP client library to work with Lemon Way API.
Installation with Composer
You can use Lemon Way SDK library as a dependency in your project with Composer (which is the preferred technique). Follow these installation instructions if you do not already have Composer installed. A composer.json file is available in the repository and it has been referenced from Packagist.
The installation with Composer is easy and reliable:
Step 1 - Add the Lemon Way SDK as a dependency by executing the following command:
you@yourhost:/path/to/your-project$ composer require lemonway/php-sdk:^1.0
Step 2 - Update your dependencies with Composer
you@yourhost:/path/to/your-project$ composer update
Step 3 - Finally, be sure to include the autoloader in your project
require_once '/path/to/your-project/vendor/autoload.php';
The Library has been added into your dependencies and is ready to be used.
Installation without Composer
SDK has been written in PHP 5.4. You should ensure that curl and openssl extensions (that are part of standard PHP distribution) are enabled in your PHP installation.
The project attempts to comply with PSR-4 specification for autoloading classes from file paths. As a namespace prefix is LemonWay\ with base directory /path/to/your-project/.
But if you're not using PSR-4 or Composer, the installation is as easy as downloading the library and storing it under any location that will be available for including in your project (don't forget to include the required library dependencies though):
require_once '/path/to/your-project/LemonWay/Autoloader.php';
Contacts
Report bugs or suggest features using issue tracker on GitHub.
Account creation
You need a sandbox to run Examples.
Configuration
Using the credentials information from Lemon Way support, you should then set $api->config->wlLogin to your Lemon Way login and $api->config->wlPass to your Lemon Way password.
require_once '/path/to/your-project/vendor/autoload.php'; $api = new LemonWayAPI(); $api->config->dkUrl = 'Your DirectKitXML url'; $api->config->wkUrl = 'Your WebKit url'; $api->config->wlLogin = 'Your login'; $api->config->wlPass = 'Your password'; $api->config->lang = 'Your language'; //$api->config->isDebugEnabled = true; //Uncomment to turn on debug mode // call some API methods... $result = $api->RegisterWallet(...);
Response Object
All LemonWayAPI methods are returning \LemonWay\ApiResponse object.
It is a dynamic object with variable properties.
###Fixed properties :
| Property | Type | Description |
|---|---|---|
| lwError | LemonWay\Models\LwError | LwError Object |
| lwXml | SimpleXMLElement | Raw xml return as SimpleXMLElement object. Details in Lemon Way API |
###Variable properties:
Those properties depends of which method was called.
| Property | Type | Description |
|---|---|---|
| wallets | array of LemonWay\Models\Wallet | Filled when the API returns multiple Wallets |
| operations | array of LemonWay\Models\Operation | Filled when the API returns multiple Operations |
| wallet | LemonWay\Models\Wallet | Filled when the API returns only one Wallet |
| operation | LemonWay\Models\Operation | Filled when the API returns only one Operation |
| kycDoc | LemonWay\Models\KycDoc | Filled when the API returns a KycDoc |
| iban | LemonWay\Models\Iban | Filled when the API returns an Iban |
| sddMandate | LemonWay\Models\SddMandate | Filled when the API returns a SDD Mandate |
Sample usage
require_once '/path/to/your-project/vendor/autoload.php'; $api = new LemonWayAPI(); $api->config->dkUrl = 'Your DirectKitXML url'; $api->config->wkUrl = 'Your WebKit url'; $api->config->wlLogin = 'Your login'; $api->config->wlPass = 'Your password'; $api->config->lang = 'Your language'; // call some API methods... $walletID = 'Fill in with a unique id'; $response = $api->RegisterWallet(array('wallet' => $walletID, 'clientMail' => $walletID.'@mail.fr', 'clientTitle' => Wallet::UNKNOWN, 'clientFirstName' => 'Paul', 'clientLastName' => 'Atreides')); if (isset($response->lwError)) { print 'Error, code '.$response->lwError->CODE.' : '.$response->lwError->MSG; } else { print '<br/>Wallet created : ' . $response->wallet->ID; // OR BY USING lwXml : print '<br/>Wallet created : ' . $response->lwXml->WALLET->ID; }
Get started with our examples
In the examples folder, you can find an example for each API method.
You need to run the examples in a web server with php configured and a hostname different from localhost.
You also need a sandbox if you want to run examples (contact Lemon Way to create a sandbox)
An API method / example match table could be find in the Index of examples folder in HTML format and also in MarkDown in the examples folder README.md.
###Configuration By default, the examples run with our sandbox demo. If you need your own sandbox, please contact Lemon Way then do these configurations. There's two files that handles the examples configuration:
| File | Description |
|---|---|
| ExamplesDatas | Random ID generator, Test card number, Test Iban ... |
| ExamplesBootstrap | API configuration (login, urls ...), API factory, Host configuration |
lemonway/php-sdk 适用场景与选型建议
lemonway/php-sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 81.13k 次下载、GitHub Stars 达 6, 最近一次更新时间为 2016 年 03 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「payment」 「wallet」 「marketplace」 「Lemon Way」 「LemonWay」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 lemonway/php-sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 lemonway/php-sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 lemonway/php-sdk 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
The BlockTrail PHP SDK, for integration of Bitcoin functionality through the BlockTrail API
Library for validation of cryptocoin wallets
Automatically translate and review your content via Lokalise.
SDK de integração com a API de pagamentos da Braspag
Yoke: SSH Connection Manager/Wallet
Cliente em PHP para integração server-side com APIs Moip v2
统计信息
- 总下载量: 81.13k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 25
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-03-07