Advertisement
Guest User

Untitled

a guest
May 22nd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.58 KB | None | 0 0
  1. $dueDate = ((new \DateTime($loan->created_at))->modify('+30 days'))->format('yyyy-MM-d');
  2. $principalAmount = $loan->getShopLoan()->value / $loan->published_value * 100;
  3.  
  4. $guzzle = new Client(self::URL . self::TOKEN . '/loans');
  5. $guzzleRequest = $guzzle->post(null, null,
  6. json_encode([
  7. 'data' => [
  8. 'loan' => [
  9. 'lender_id' => $loan->id,
  10. 'country' => 'Russia',
  11. 'lender_issue_date' => (new \DateTime($loan->created_at))->format('yyyy-MM-d'),
  12. 'mintos_issue_date' => (new \DateTime('now'))->format('yyyy-MM-d'),
  13. 'final_payment_date' => $dueDate,
  14. 'loan_amount' => $loan->getShopLoan()->value,
  15. 'loan_amount_assigned_to_mintos' => self::PERCENT,//что это
  16. 'interest_rate_percent' => $loan->daily_interest_rate,
  17. 'purpose' => 'working capital',
  18. 'buyback' => true,
  19. 'currency' => 'RUR'
  20. ],
  21. 'client' => [
  22. 'id' => $loan->getShopLoan()->getCustomer()->id,
  23. 'name' => $loan->getShopLoan()->getCustomer()->getLegalEntity()->getFullName()
  24. ],
  25. 'pledge-other' => [
  26. 'type' => 'Shipments on the way to customers and cash on delivery paid by customers for that shipments',
  27. ],
  28. 'payment_schedule' => [
  29. 'number' => 1,
  30. 'date' => $dueDate,
  31. 'principal_amount' => $principalAmount,//что это
  32. 'interest_amount' => $principalAmount, //что это
  33. 'total_remaining_principal' => 0
  34. ]
  35. ]
  36. ]
  37. , JSON_UNESCAPED_UNICODE)
  38. );
  39.  
  40. $guzzleResponse = $guzzleRequest->send();
  41.  
  42. if ($guzzleResponse->isSuccessful())
  43. {
  44. $response = json_decode($guzzleResponse->getBody(true), true);
  45. if (isset($response['data']['loan']['mintos_id']))
  46. {
  47. $loan->prepareUpdateList()
  48. ->setJson('details', ['mintos_id' => $response['data']['loan']['mintos_id']])
  49. ->apply();
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement