dmorenof/lendismart

Lendismart集成API

1.0.10 2019-12-11 16:48 UTC

This package is auto-updated.

Last update: 2024-09-12 03:13:21 UTC


README

这是为Lendismart, S.L.提供的一种快速且安全的集成方案

此库允许通过webservice创建和检查申请

安装

Composer

要安装此库,您必须执行以下代码

composer require dmorenof/lendismart dev-master

手动

https://github.com/dmorenof/lendismart下载库

包含"安装路径/src"中的所有文件

function autoload($path) {
    $items = glob($path . DIRECTORY_SEPARATOR . "*");

    foreach($items as $item) {
        $isPhp = pathinfo($item) ["extension"] === "php";

        if (is_file($item) && $isPhp) {
            require_once $item;
        } elseif (is_dir($item)) {
            autoload($item);
        }
    }
}

autoload($installation_path . DIRECTORY_SEPARATOR . 'src');

使用方法

实例化库

$Lendismart = new dmorenof\lendismart\Lendismart\Lendismart();

准备认证和环境

$Lendismart->setEndpoint('https://api-staging.lendismart.com/externalAPI/v1');
$Lendismart->setApiKey(AUTH_TOKEN);

创建一个应用

创建应用的示例

 try {
    $Lendismart = new dmorenof\lendismart\Lendismart\Lendismart();
    $Lendismart->setEndpoint('https://api-staging.lendismart.com/externalAPI/v1');
    $Lendismart->setApiKey(AUTH_TOKEN);
    
    $Application = new dmorenof\lendismart\Lendismart\Structures\Application([
        'goodsType' => 10101,
        'reference' => '2018/J3212',
        'serialNumber' => '11238630119',
        'purchaseAmount' => 2350,
        'requestedAmount' => 2000,
        'maxMonthlyPayment' => 80,
        'feePaymentType' => 1,
        'insurance' => true,
        'noAccount' => false,
        'terms' => [
            [
                'term' => 12,
            ],
        ],
        'gracePeriods' => [
            [
                'gracePeriod' => 0,
            ],
        ],
        'openingFeePcts' => [
            [
                'openingFeePct' => 0.025000000000000001,
            ],
        ],
        'productTypes' => [
            [
                'productType' => 1,
            ],
        ],
        'applicants' => [
            [
                'docIdType' => 1,
                'docIdNumber' => '11111111H',
                'docIdExpirationDate' => '2022-03-25T00:00:00.000Z',
                'firstName' => 'José',
                'surname1' => 'Pérez',
                'surname2' => 'García',
                'birthDate' => '1975-10-17T00:00:00.000Z',
                'nationality' => 65,
                'nativeCountry' => 65,
                'nativeProvince' => '28',
                'nativeCity' => '28079',
                'gender' => 1,
                'maritalStatus' => 1,
                'phoneType1' => 2,
                'phone1' => '611111111',
                'phoneType2' => 1,
                'phone2' => '911111111',
                'email' => 'prueba@prueba.es',
                'housingTenureType' => 1,
                'housingTenureStartDate' => '2008-04-12T00:00:00.000Z',
                'housingExpenses' => 400,
                'occupation' => 1120,
                'workingDayType' => 1,
                'profession' => 1,
                'jobTitle' => 1,
                'industry' => 901,
                'contractStartDate' => '2004-01-21T00:00:00.000Z',
                'companyName' => 'Despacho Prueba SA',
                'companyPhone' => '912222222',
                'companyProvince' => '28',
                'companyCity' => '28079',
                'companyPostalCode' => '28001',
                'monthlyIncome' => 1800.3399999999999,
                'incomeFrequency' => 14,
                'monthlyBonus' => 0,
                'otherMonthlyIncome' => 0,
                'dependentChildren' => 0,
                'dependentAdults' => 0,
                'otherExpenses' => 0,
                'role' => 1,
                'paymentMethod' => 1,
                'accountNumber' => 'ES9420805801101234567891',
                'accountCreationDate' => '2002-02-23T00:00:00.000Z',
                'address' => [
                    'streetType' => 6,
                    'street' => 'Francisco Silvela',
                    'number' => '62',
                    'stairs' => 'C',
                    'floor' => '2',
                    'door' => 'A',
                    'postalCode' => '28018',
                    'province' => '28',
                    'city' => '28079',
                    'locality' => '280790001',
                ],
            ],
        ],
    ]);
    
    $NewApplicationResponse = $Lendismart->createNewApplication(APP_USER_ID, $Application);
    $application_identifier = $$NewApplicationResponse->appId;
} catch (Exception $exception) {
    echo $exception->getMessage();
}

返回dmorenof\lendismart\Lendismart\Structures\NewApplicationResponse对象或错误时抛出异常

检查一个应用

检查应用的示例

try {
    $Lendismart = new dmorenof\lendismart\Lendismart\Lendismart();
    $Lendismart->setEndpoint('https://api-staging.lendismart.com/externalAPI/v1');
    $Lendismart->setApiKey(AUTH_TOKEN);
    
    $ApplicationResponse = $Lendismart->application($application_identifier, 'long');
    $application_status = $ApplicationResponse->status;
} catch (Exception $exception) {
    echo $exception->getMessage();
}

返回dmorenof\lendismart\Lendismart\Structures\ApplicationResponse对象或错误时抛出异常

文档

Lendismart::class

Lendismart::setEndpoint(string $endpoint)

设置未来调用所使用的环境的端点(基础URL)

Lendismart::setApiKey(string $api_key)

设置Lendismart提供的用于未来调用的api_key(授权令牌)

Lendismart::application(string $application_id, string $format)

$application_id Lendismart应用程序ID

$format short|long

返回dmorenof\lendismart\Lendismart\Structures\ApplicationResponse对象或错误时抛出异常

Lendismart::createNewApplication(int $merchant_id, Application $application)

$merchant_id 与应用程序关联的Lendismart商户ID

$application 新Application对象

返回dmorenof\lendismart\Lendismart\Structures\NewApplicationResponse对象或错误时抛出异常

Lendismart::getCallUrl()

获取调试目的的调用URL

Lendismart::getPostData()

获取调试目的的发送POST数据

Lendismart::getRawResponse()

获取调试目的的原始响应

Lendismart::getHttpCode()

获取调试目的的HTTP代码

示例

try {
    $Lendismart = new dmorenof\lendismart\Lendismart\Lendismart();
    $Lendismart->setEndpoint('https://api-staging.lendismart.com/externalAPI/v1');
    $Lendismart->setApiKey(AUTH_TOKEN);
    
    $ApplicationResponse = $Lendismart->application($application_identifier, 'long');
    $application_status = $ApplicationResponse->status;
} catch (Exception $exception) {
    echo $exception->getMessage();
} finally {
    if (isset($Lendismart)) {
        echo $Lendismart->getCallUrl();
        echo $Lendismart->getPostData();
        echo $Lendismart->getHttpCode();
        echo $Lendismart->getRawResponse();
    } 
}

Validation::class

Dynamically validates the objects on the Structures creation

结构类

  • 地址
  • 申请人
  • 申请
  • 申请响应
  • 错误
  • 宽限期
  • 事件
  • 新申请响应
  • OpeningFeePct
  • 产品类型
  • 期限

在构建时评估输入数组并返回对象

使用字典检查有效值

示例

try {
    $Address = new dmorenof\lendismart\Lendismart\Structures\Address([
        'streetType' => 6,
        'street' => 'Francisco Silvela',
        'number' => '62',
        'stairs' => 'C',
        'floor' => '2',
        'door' => 'A',
        'postalCode' => '28018',
        'province' => '28',
        'city' => '28079',
        'locality' => '280790001',
    ]);
} catch (Exception $exception) {
    echo $exception->getMessage();
}

Dictionary::class

设置字典

Dictionary::getById(int $value_id)

根据ID获取字符串名称

示例

try {
    $ApplicationResponse = $Lendismart->application($application_identifier, 'short');
    $application_status = $ApplicationResponse->status;
    $ApplicationStatuses = new dmorenof\lendismart\Lendismart\Dictionaries\ApplicationStatuses();
    $status_text = $ApplicationStatuses->getById($application_status);
} catch (Exception $exception) {
    echo $exception->getMessage();
}

Dictionary类

  • ApplicationStatuses
  • 城市
  • 国家
  • DocIdTypes
  • ErrorTypes
  • FeePaymentTypes
  • Genders
  • HousingTenureTypes
  • IncidentTypes
  • 行业
  • 职位
  • LenderCustomers
  • 地区
  • 婚姻状况
  • 职业
  • 支付方式
  • 电话类型
  • 产品类型
  • 专业
  • 省份
  • 关系
  • ResponseCodes
  • 角色
  • 服务时长
  • 街道类型
  • UsedSignatureMethods
  • 工作日类型