# API reference
# GrahpQL
The backend of the platform is built using GraphQL. The list of queries and mutations can be found respectively:
./backend/graphql/typeDefs/types/Query.graphql
./backend/graphql/typeDefs/types/Mutation.graphql
It is also possible to explore the API using the GraphQL playground when the environment variable NODE_ENV
is set to development
. Simply visit http://localhost:$PORT/graphql
.
# Crons
# CronDeleteUsers every month at 00:00
- Selects users where
disabled
is true anddeleteAt
is passed. - Deletes them.
- If user is borrower, will also delete his projects.
- If user is organization owner, will also delete the organization members.
- If user is organization member, will be removed from organization members.
# CronEarlyReimbursement every hour
- Selects reimbursement plans where
isEarlyReimbursement
is true andpaid
is false. - If the wallet balance of the project owner is less than total amount to reimburse, then notifies admin every day.
- Else transfers money from the project wallet to lender wallet, updates
refund
to true and notifies admin, lender and borrower. - Lenders will receive
amortization + interest
for the current(the year when admin executes early reimbursement) term and onlyamortization
for upcoming terms. - Lenders will receive
half of the interest
for the current term if early reimbursement is executed before six months from reimbursement termsexecution date
.
# CronHandleDelayedReimbursements every day at 12:00
- Selects reimbursements where
paid
is false andexecutionAt
is passed. - Sets the property
delayed
to true.
# CronHandleNotSuccessfulProjects every hour
- Selects projects where
status
isPUBLIC_SALE
andcollected < target
andendSaleAt
is passed. - Updates the
status
toNOT_SUCCESSFUL
. - Notifies project owners and investors by email.
# CronHandleSuccessfulProjects every hour
- Selects projects where
status
isPUBLIC_SALE
andcollected >= target or maximum
andenSaleAt
is passed. - Updates the
status
toSUCCESSFUL
. - Populates reimbursement, reimbursement plan and reimbursement terms for each project based on defined respite period by admin.
- Notifies project owners and investors by email.
- Downloads, zip and uploads to s3 all investment contracts.
# CronHandleWalletStatusChange every minute MANGOPAY
- Selects users / organizations where
profileStatus
isWALLET_CREATED
orREJECTED_PSP
. - If Mangopay user's
kYCLevel
isREGULAR
, updatesprofileStatus
toAPPROVED
, addskycStatus
and sends an email to the user. - Else if there are rejected documents, updates
profileStatus
toREJECTED_PSP
.
# CronMoveProjectsToPublicSale every 5 hours
- Selects projects where
status
isPRIVATE_SALE
andstartSaleAt
is passed. - Updates the status to
PUBLIC_SALE
. - Notifies all lenders of a new project available by email.
# CronProfileNotCompleted every day at 12:00
- Selects users where
type
isLENDER
andprofileStatus
isNOT_SUBMITTED
. - Notifies the user that the profile is still not submitted after 1 and 10 days by email.
# CronRefundProjectsNotSuccessful every hour
- Selects investments where
refund
is false andstatus
isCOMPLETED
(when a project becomesNOT_SUCCESSFUL
, therefund
property is added to each related investment marking them as investments to refund). - Transfers money from the project wallet to each lenders wallet.
- Sets
refund
to true.
# CronReimbursement every hour
- Selects reimbursement terms where
paid
is false andexecutionAt
is passed. - If the wallet balance of the project owner is less than total amount to reimburse, then notifies admin every day.
- Else transfers money from the project wallet to lender wallet, updates
refund
to true and notifies admin, lender and borrower.
# CronReimbursementPayTax every hour
- Selects reimbursements where
paid
is true andtaxPaid
is false. - Calculates
socialTax
andincomeTax
. - Transfers both taxes to the tax wallet.
- Sets
taxPaid
to true.
# CronResetTaxExempt every 1st of april at 00:00
- Selects every users where
type
isLENDER
. - Sets
taxExempt
to false.
# CronSendEmailIncomeTaxExemption every 1st of november at 00:00
- Selects every users where
type
isLENDER
andhasOrganization
is false. - Notifies lenders about tax exemption.
# CronSendEmailNotEnoughBalanceToCompleteReimbursement every day at 12:00
- Sends an email to borrower and admin 15, 7 and 2 days before the reimbursement if the amount in the wallet is not enough.
# CronSendEmailProjectNewsNotPublished every day at 12:00
- Selects projects where status is SUCCESSFUL.
- Sends the borrower and admin a reminder email that project news have no been published for a long time every 5 days until a news is published.
NOTE: long time means 90 days after the last publication (or the end of the sale period if no news yet).
# CronSendEmailProjectPublishNews every day at 12:00
- Selects projects where
status
isSUCCESSFUL
. - Sends the borrower a reminder email to publish a news in his project 60 days after
endSaleAt
, then every 3 months until the project gets fully reimbursed.
# CronSendEmailToAdminsIfKycStatusNotUpdated every day at 12:00
- Selects users where
type
isLENDER
andprofileStatus
is notAPPROVED
. - If
profileApprovedAt
was 2 days ago, sends an email to admin as there might be an issue with the payment service provider.
# CronSendEmailToLenderApprovedButNotInvested every day at 12:00
- Selects users where
type
isLENDER
and their investments. - If user has
profileApprovedAt
and is 14 days or 84 days (3 months) ago, send an reminder email to the user.
# CronSendEmailToLenderIfRiskAssessmentNotSigned every day at 12:00
- Selects users where
type
isLENDER
andriskAssessment.isSigned
is false. - Sends a reminder to the lender if he did not sign the risk assessment after 3 days we sent it.
# CronStatistics every day at 12:00
- Calculates statistics for current year and updates the statistics table.
# CronUpdateKYCStatuses every hour LEMONWAY
- Updates
profileStatus
andkycStatus
with values from Lemonway.
# CronUploadDocument every five minutes
- Selects users where
type
isLENDER
andprofileStatus
isWALLET_CREATED
. - Selects files uploaded by users (proofs) where
uploadId
is null. - Uploads the files to the payment service provider and update the
uploadId
.
# CronUploadUBODeclaration every minute MANGOPAY
- Selects organizations where
profileStatus
is notNOT_SUBMITTED
orREJECTED
anduboStatus
is notVALIDATED
orSUBMITTED
. - If
organization.uboStatus
isREFUSED
or null, creates a new ubo declaration upload documents and submit ubo declaration. - If
organization.uboStatus
isINCOMPLETE
update submitted ubo document and details. - Else create new ubo declaration upload documents and submit ubo declaration.
# Webhooks
# document MANGOPAY
- triggerd on:
Kyc Succeeded
orKyc Failed
- If Mangopay user's
kYCLevel
isREGULAR
, updatesprofileStatus
toAPPROVED
, addskycStatus
and sends an email to the user. - Else if there are rejected documents, updates
profileStatus
toREJECTED_PSP
.
# payment MANGOPAY
- triggered on:
Payin Succeeded
orPayin Failed
- If
PAYIN_NORMAL_SUCCEEDED
,send an email to the user and update walletCreditedAt - Increment
logsCount
on paynin succeeded or failed
# ubo MANGOPAY
- triggerd on:
Ubo Declaration Refused
orUbo Declaration Validated
- If
UBO_DECLARATION_VALIDATED
, updateuboStatus
toVALIDATED
- Else if refused, updates
profileStatus
toREJECTED_PSP
andkycStatus
toACCOUNT_NOT_OPENED