1. Go to this page and download the library: Download bnpl-partners/factoring004 library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
bnpl-partners / factoring004 example snippets
use BnplPartners\Factoring004\OAuth\OAuthTokenManager;
$tokenManager = new OAuthTokenManager('https://dev.bnpl.kz/api/users/api/v1', 'username', 'password');
use BnplPartners\Factoring004\Otp\SendOtp;
$sendOtp = new SendOtp('1', '1', 6000);
// or
$sendOtp = SendOtp::createFromArray(['merchantId' => '1', 'merchantOrderId' => '1', 'amount' => 6000]);
// send request and receive response
$response = $api->otp->sendOtp($sendOtp);
var_dump($response->getMsg());
var_dump($response->toArray(), json_encode($response));
use BnplPartners\Factoring004\Otp\CheckOtp;
$checkOtp = new CheckOtp('1', '1', '1111', 6000);
// or
$checkOtp = CheckOtp::createFromArray(['merchantId' => '1', 'merchantOrderId' => '1', 'otp' => '1111', 'amount' => 6000]);
// send request and receive response
$response = $api->otp->checkOtp($checkOtp);
var_dump($response->getMsg());
var_dump($response->toArray(), json_encode($response));
use BnplPartners\Factoring004\ChangeStatus\DeliveryOrder;
use BnplPartners\Factoring004\ChangeStatus\DeliveryStatus;
use BnplPartners\Factoring004\ChangeStatus\ErrorResponse;
use BnplPartners\Factoring004\ChangeStatus\MerchantsOrders;
use BnplPartners\Factoring004\ChangeStatus\SuccessResponse;
$orders = new MerchantsOrders('1', [new DeliveryOrder('1', DeliveryStatus::DELIVERY(), 6000)]);
// or
$orders = MerchantsOrders::createFromArray([
'merchantId' => '1',
'orders' => [
['orderId' => '1', 'status' => 'delivered', 'amount' => 6000],
],
]);
// send request and receive response
$response = $api->changeStatus->changeStatusJson($orders);
var_dump(array_map(fn(SuccessResponse $response) => $response->getMsg(), $response->getSuccessfulResponses()));
var_dump(array_map(fn(ErrorResponse $response) => $response->getMessage(), $response->getErrorResponses()));
var_dump($response->toArray(), json_encode($response));
use BnplPartners\Factoring004\Otp\SendOtpReturn;
$sendOtpReturn = new SendOtpReturn(6000, '1', '1');
// or
$sendOtpReturn = SendOtpReturn::createFromArray(['amountAr' => 6000, 'merchantId' => '1', 'merchantOrderId' => '1']);
// send request and receive response
$response = $api->otp->sendOtpReturn($sendOtpReturn);
var_dump($response->getMsg());
var_dump($response->toArray(), json_encode($response));
use BnplPartners\Factoring004\Otp\CheckOtpReturn;
$checkOtpReturn = new CheckOtpReturn(6000, '1', '1', '1111');
// or
$checkOtpReturn = CheckOtp::createFromArray(['amountAr' => 6000, 'merchantId' => '1', 'merchantOrderId' => '1', 'otp' => '1111']);
// send request and receive response
$response = $api->otp->checkOtpReturn($checkOtpReturn);
var_dump($response->getMsg());
var_dump($response->toArray(), json_encode($response));
use BnplPartners\Factoring004\ChangeStatus\ErrorResponse;
use BnplPartners\Factoring004\ChangeStatus\MerchantsOrders;
use BnplPartners\Factoring004\ChangeStatus\ReturnOrder;
use BnplPartners\Factoring004\ChangeStatus\ReturnStatus;
use BnplPartners\Factoring004\ChangeStatus\SuccessResponse;
$orders = new MerchantsOrders('1', [new ReturnOrder('1', ReturnStatus::RETURN(), 6000)]);
// or
$orders = MerchantsOrders::createFromArray([
'merchantId' => '1',
'orders' => [
['orderId' => '1', 'status' => 'return', 'amount' => 6000],
],
]);
// send request and receive response
$response = $api->changeStatus->changeStatusJson($orders);
var_dump(array_map(fn(SuccessResponse $response) => $response->getMsg(), $response->getSuccessfulResponses()));
var_dump(array_map(fn(ErrorResponse $response) => $response->getMessage(), $response->getErrorResponses()));
var_dump($response->toArray(), json_encode($response));
use BnplPartners\Factoring004\ChangeStatus\ErrorResponse;
use BnplPartners\Factoring004\ChangeStatus\MerchantsOrders;
use BnplPartners\Factoring004\ChangeStatus\CancelOrder;
use BnplPartners\Factoring004\ChangeStatus\CancelStatus;
use BnplPartners\Factoring004\ChangeStatus\SuccessResponse;
$orders = new MerchantsOrders('1', [new CancelOrder('1', CancelStatus::CANCEL())]);
// or
$orders = MerchantsOrders::createFromArray([
'merchantId' => '1',
'orders' => [
['orderId' => '1', 'status' => 'canceled'],
],
]);
// send request and receive response
$response = $api->changeStatus->changeStatusJson($orders);
var_dump(array_map(fn(SuccessResponse $response) => $response->getMsg(), $response->getSuccessfulResponses()));
var_dump(array_map(fn(ErrorResponse $response) => $response->getMessage(), $response->getErrorResponses()));
var_dump($response->toArray(), json_encode($response));
use BnplPartners\Factoring004\Exception\ApiException;
use BnplPartners\Factoring004\Exception\AuthenticationException;
use BnplPartners\Factoring004\Exception\EndpointUnavailableException;
use BnplPartners\Factoring004\Exception\ErrorResponseException;
use BnplPartners\Factoring004\Exception\NetworkException;
use BnplPartners\Factoring004\Exception\PackageException;
use BnplPartners\Factoring004\Exception\TransportException;
use BnplPartners\Factoring004\Exception\UnexpectedResponseException;
use BnplPartners\Factoring004\Exception\ValidationException;
try {
$api->preApps->preApp($message);
} catch (AuthenticationException $e) {
// authentication errors, token invalid, token expired, etc
var_dump($e->getCode(), $e->getMessage(), $e->getDescription());
} catch (EndpointUnavailableException $e) {
// to catch all internal server errors 500, 503, etc
var_dump($e->getResponse());
} catch (ErrorResponseException $e) {
// to catch all client errors 400, 405, etc
var_dump($e->getErrorResponse());
} catch (UnexpectedResponseException $e) {
// to catch all responses with unexpected schema
var_dump($e->getResponse());
} catch (ValidationException $e) {
// endpoint validation error
$details = $e->getResponse()->getDetails();
var_dump($details[0]->getError(), $details[0]->getField());
} catch (ApiException $e) {
// to catch all api layer exceptions
} catch (NetworkException $e) {
// network issues, connection refused, etc
} catch (TransportException $e) {
// to catch all transport layer exceptions
} catch (PackageException $e) {
// to catch all the package exceptions
}
use BnplPartners\Factoring004\Transport\GuzzleTransport;
);
use BnplPartners\Factoring004\Transport\PsrTransport;
7\HttpFactory(),
new GuzzleHttp\Psr7\HttpFactory(),
new GuzzleHttp\Psr7\HttpFactory(),
new GuzzleHttp\Client(),
);
use BnplPartners\Factoring004\Transport\PsrTransport;
uzzle\RequestFactory(),
new Http\Factory\Guzzle\StreamFactory(),
new Http\Factory\Guzzle\UriFactory(),
new Mjelamanov\GuzzlePsr18\Client(new GuzzleHttp\Client()),
);
use BnplPartners\Factoring004\Transport\PsrTransport;
(), // PSR-17 instance
new StreamFactory(), // PSR-17 instance
new UriFactory(), // PSR-17 instance
new Client() // PSR-18 instance
);
use BnplPartners\Factoring004\Auth\BearerTokenAuth;
use BnplPartners\Factoring004\Otp\OtpResource;
use BnplPartners\Factoring004\PreApp\PreAppResource;
= new OtpResource($transport, 'https://dev.bnpl.kz/api', new BearerTokenAuth('Access Token'));
$response = $otp->sendOtp(...);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.