Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $dueDate = ((new \DateTime($loan->created_at))->modify('+30 days'))->format('yyyy-MM-d');
- $principalAmount = $loan->getShopLoan()->value / $loan->published_value * 100;
- $guzzle = new Client(self::URL . self::TOKEN . '/loans');
- $guzzleRequest = $guzzle->post(null, null,
- json_encode([
- 'data' => [
- 'loan' => [
- 'lender_id' => $loan->id,
- 'country' => 'Russia',
- 'lender_issue_date' => (new \DateTime($loan->created_at))->format('yyyy-MM-d'),
- 'mintos_issue_date' => (new \DateTime('now'))->format('yyyy-MM-d'),
- 'final_payment_date' => $dueDate,
- 'loan_amount' => $loan->getShopLoan()->value,
- 'loan_amount_assigned_to_mintos' => self::PERCENT,//что это
- 'interest_rate_percent' => $loan->daily_interest_rate,
- 'purpose' => 'working capital',
- 'buyback' => true,
- 'currency' => 'RUR'
- ],
- 'client' => [
- 'id' => $loan->getShopLoan()->getCustomer()->id,
- 'name' => $loan->getShopLoan()->getCustomer()->getLegalEntity()->getFullName()
- ],
- 'pledge-other' => [
- 'type' => 'Shipments on the way to customers and cash on delivery paid by customers for that shipments',
- ],
- 'payment_schedule' => [
- 'number' => 1,
- 'date' => $dueDate,
- 'principal_amount' => $principalAmount,//что это
- 'interest_amount' => $principalAmount, //что это
- 'total_remaining_principal' => 0
- ]
- ]
- ]
- , JSON_UNESCAPED_UNICODE)
- );
- $guzzleResponse = $guzzleRequest->send();
- if ($guzzleResponse->isSuccessful())
- {
- $response = json_decode($guzzleResponse->getBody(true), true);
- if (isset($response['data']['loan']['mintos_id']))
- {
- $loan->prepareUpdateList()
- ->setJson('details', ['mintos_id' => $response['data']['loan']['mintos_id']])
- ->apply();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement