mohdnazrul / laravel-ctos-kyc
v1.8
2020-11-05 03:16 UTC
Requires
- guzzlehttp/guzzle: ^6.3
Requires (Dev)
- illuminate/support: 5.4.*
- phpunit/phpunit: ^7.0.2
README
此库允许查询注册用户的CTOS - B2B API。
您需要提供的访问详情以进行API调用。关于数据数组/XML中的确切参数,请参阅您的离线文档。
如果您不知道这些是什么,那么您可能不需要或想要这个库。
配置
.env文件
通过.env文件进行配置目前允许设置以下变量
- CTOS_KYC_URL='http://api.endpoint/url/'
- CTOS_KYC_USERNAME=demouser
- CTOS_KYC_PASSWORD=demoPassword
可用函数
CTOSV2::generateXMLFromArray($data, $XMLEscape = true);
此函数接受CTOS API的选项数组,并生成可以通过API调用提交的XML代码。XMLEscape自动设置为true,因为返回的XML数据必须包含HTML特殊字符('UTF-8')。示例
// This is for Company Format [ 'company_code' => 'XXXXXX', // Required 'account_no' => 'AAAAAA', // Required 'user_id' => 'AAAAAA', // Required 'records' => [ 'type' => 'C', // Required and type is C for Company 'name' => 'COMPANY_NAME', 'ic_lc' => 'COMPANY_REGISTRATION_NO', // Conditional if type is individual (old IC), if type is Company is registration no 'nic_br' => '', // Conditional if type is individual 'country>' => 'MALAYSIA' // Required ], ] // This is for Individual Format [ 'company_code' => 'XXXXXX', // Required 'account_no' => 'AAAAAA', // Required 'user_id' => 'AAAAAA', // Required 'records' => [ 'type' => 'I', // Required and type is I for Individual 'name' => 'INDIVIDUAL NAME', 'ic_lc' => '', // Conditional if type is individual (old IC), if type is Company is registration no 'nic_br' => 'PASSPORT NO/NICR', // Conditional if type is individual 'country>' => 'MALAYSIA' // Required ], ] // This is for Business Format [ 'company_code' => 'XXXXXX', // Required 'account_no' => 'AAAAAA', // Required 'user_id' => 'AAAAAA', // Required 'records' => [ 'type' => 'B', // Required and type is B for Individual 'name' => 'BUSINESS NAME', 'ic_lc' => 'BUSINESS_REGISTRATION_NO', // Conditional if type is individual (old IC), if type is business is business no 'nic_br' => '', // Conditional if type is individual 'country>' => 'MALAYSIA' // Required ], ]
将生成 // 这适用于公司格式
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.proxy.xml.ctos.com.my/"> <soapenv:Header/> <soapenv:Body> <ws:request> <!--Optional:--> <input> <batch output="0" no="1234" xmlns="http://ws.cmctos.com.my/ctosnet/kyc"> <company_code>XXXXXX</company_code> <account_no>AAAAAA</account_no> <user_id>AAAAAA</user_id> <records> <type>C</type> <name>COMPANY_NAME</name> <ic_lc>COMPANY_REGISTRATION_NO</ic_lc> <nic_br/> <country/> </records> </batch> </input> </ws:request> </soapenv:Body> </soapenv:Envelope>
// 这适用于个人格式
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.proxy.xml.ctos.com.my/"> <soapenv:Header/> <soapenv:Body> <ws:request> <!--Optional:--> <input> <batch output="0" no="1234" xmlns="http://ws.cmctos.com.my/ctosnet/kyc"> <company_code>XXXXXX</company_code> <account_no>AAAAAA</account_no> <user_id>AAAAAA</user_id> <records> <type>C</type> <name>INDIVIDUAL NAME</name> <ic_lc/> <nic_br>NRIC</nic_br> <country/> </records> </batch> </input> </ws:request> </soapenv:Body> </soapenv:Envelope>
// 这适用于商业格式
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.proxy.xml.ctos.com.my/"> <soapenv:Header/> <soapenv:Body> <ws:request> <!--Optional:--> <input> <batch output="0" no="1234" xmlns="http://ws.cmctos.com.my/ctosnet/kyc"> <company_code>XXXXXX</company_code> <account_no>AAAAAA</account_no> <user_id>AAAAAA</user_id> <records> <type>C</type> <name>BUSINESS NAME</name> <ic_lc>BUSINESS REGISTRATION NO</ic_lc> <nic_br/> <country/> </records> </batch> </input> </ws:request> </soapenv:Body> </soapenv:Envelope>
对于LARAVEL设置配置:-
- 使用composer require mohdnazrul/laravel-ctos-kyc
composer require mohdnazrul/laravel-ctos-kyc
- 在config/app.php中添加以下语法
.... 'providers'=> [ . MohdNazrul\CTOSKYCLaravel\CTOSKYCServiceProvider::class, . ], 'aliases' => [ . 'CTOSKYC' => MohdNazrul\CTOSKYCLaravel\CTOSKYCApiFacade::class, ' ],
- 如下发布
php artisan vendor:publish --tag=ctoskyc
- 您可以根据以下说明编辑默认的CTOS KYC配置 config/ctoskyc.php
return [ 'serviceUrl' => env('CTOS_KYC_URL','https://'), 'username' => env('CTOS_KYC_USERNAME','username'), 'password' => env('CTOS_KYC_PASSWORD','password') ];