mitloshuk / moneycare
PHP library for MoneyCare API. MoneyCare is the leading credit platform for PIC lending in stores. More than 15 solutions from banks and MFIs in 2 minutes
1.0.2
2020-12-29 18:18 UTC
Requires
- php: ^7.2
- ext-json: *
- guzzlehttp/guzzle: ^7.0
Requires (Dev)
- codeception/codeception: ^4.1
- fzaninotto/faker: ^1.4
This package is auto-updated.
Last update: 2024-09-29 05:42:47 UTC
README
About package
PHP library for MoneyCare API www.moneycare.su. MoneyCare is the leading credit platform for PIC lending in stores. More than 15 solutions from banks and MFIs in 2 minutes
How to start
- Install package via
composer require mitloshuk/moneycare
command or add"mitloshuk/moneycare": "^1.0"
to yourcomposer.json
- Init
MoneyCare/MoneyCare
via your DI or use$moneyCare = new \MoneyCare\MoneyCare($username, $password);
where$username
and$password
are your auth data to MoneyCare API
How to create order
- Create Order model like
$order = new \MoneyCare\Models\OrderCreation();
- Create Good model like
$good = new \MoneyCare\Models\Good();
- Add price and another optional parameters to Good model
$good->setPrice(100)->setTitle('Good Title');
. You can use any parameter from docs withset
prefix like->setBrand('This is my brand')
. - For predefined parameter
goodType
can use dictionaryGoodTypesDictionary
, for example\MoneyCare\Dictionaries\GoodTypesDictionary::PRODUCT
- Add required Good and point id to your Order model
$order->addGood($good)->setPointId('point');
. You can use any parameter from docs withset
prefix like->setGenerateForm(true)
. - Execute sending of order model with
$response = $moneyCare->createOrder($order);
- Check response
$response->getIsAccepted()
or get form url with$response->getFormUrl()
if you requested it on previous step - For predefined parameters
creditTypes
,formMode
andcreditStatus
you can useCreditTypesDictionary
,FormModesDictionary
andCreditTypesDictionary
dictionaries.
So ready example code of creating order will look like
$moneyCare = new \MoneyCare\MoneyCare($username, $password);
$order = new \MoneyCare\Models\OrderCreation();
$good = new \MoneyCare\Models\Good();
$good->setPrice(100)->setTitle('Good Title');
$order->addGood($good)->setPointId('point');
$response = $moneyCare->createOrder($order);
if ($response->getIsAccepted()) {
echo $response->getFormUrl();
}
How to update order
- Get
order id
of existing order via$orderId = $response->getOrderId();
of previous response - Create new Order model like
$newOrderData = new \MoneyCare\Models\OrderUpdating();
- Create one more Good model like
$good2 = new \MoneyCare\Models\Good();
- Add price and another optional parameters to Good model
$good2->setPrice(100)->setTitle('Good Title');
. - Add that Good to your new Order model
$newOrderData->addGood($good)
. - Execute sending of order model with
$moneyCare->updateOrder($orderId, $newOrderData);
- There are no response from request, but you can get info with
details request
Ready code of updating previous example order will look like
$orderId = $response->getOrderId();
$newOrderData = new \MoneyCare\Models\OrderUpdating();
$good2 = new \MoneyCare\Models\Good();
$good2->setPrice(100)->setTitle('Good Title');
$newOrderData->addGood($good2);
$moneyCare->updateOrder($orderId, $newOrderData);
How to get order details
- Get
order id
of existing order via$orderId = $response->getOrderId();
of previous response - Execute request like
$response = $moneyCare->orderDetails($orderId);
- Response will contain all parameters from doc, they will accessible via their names with
get
prefix
Ready code of getting details
$orderId = $response->getOrderId();
$response = $moneyCare->orderDetails($orderId);
echo $response->getCreditLimit();
How to change order status
- Get
order id
of existing order via$orderId = $response->getOrderId();
of previous response - Execute request like
$moneyCare->updateStatus($orderId, OrderStatusesDictionary::DELIVERY);
- Second method argument is
orderStatus
and it predefined, so you can takeOrderStatusesDictionary
for simpler usage - There are no response from request, but you can get info with
details request
Ready code of getting details
$orderId = $response->getOrderId();
$moneyCare->updateStatus($orderId, OrderStatusesDictionary::DELIVERY);