# 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
disabledis true anddeleteAtis 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
isEarlyReimbursementis true andpaidis 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
refundto true and notifies admin, lender and borrower. - Lenders will receive
amortization + interestfor the current(the year when admin executes early reimbursement) term and onlyamortizationfor upcoming terms. - Lenders will receive
half of the interestfor the current term if early reimbursement is executed before six months from reimbursement termsexecution date.
# CronHandleDelayedReimbursements every day at 12:00
- Selects reimbursements where
paidis false andexecutionAtis passed. - Sets the property
delayedto true.
# CronHandleNotSuccessfulProjects every hour
- Selects projects where
statusisPUBLIC_SALEandcollected < targetandendSaleAtis passed. - Updates the
statustoNOT_SUCCESSFUL. - Notifies project owners and investors by email.
# CronHandleSuccessfulProjects every hour
- Selects projects where
statusisPUBLIC_SALEandcollected >= target or maximumandenSaleAtis passed. - Updates the
statustoSUCCESSFUL. - 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
profileStatusisWALLET_CREATEDorREJECTED_PSP. - If Mangopay user's
kYCLevelisREGULAR, updatesprofileStatustoAPPROVED, addskycStatusand sends an email to the user. - Else if there are rejected documents, updates
profileStatustoREJECTED_PSP.
# CronMoveProjectsToPublicSale every 5 hours
- Selects projects where
statusisPRIVATE_SALEandstartSaleAtis 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
typeisLENDERandprofileStatusisNOT_SUBMITTED. - Notifies the user that the profile is still not submitted after 1 and 10 days by email.
# CronRefundProjectsNotSuccessful every hour
- Selects investments where
refundis false andstatusisCOMPLETED(when a project becomesNOT_SUCCESSFUL, therefundproperty is added to each related investment marking them as investments to refund). - Transfers money from the project wallet to each lenders wallet.
- Sets
refundto true.
# CronReimbursement every hour
- Selects reimbursement terms where
paidis false andexecutionAtis 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
refundto true and notifies admin, lender and borrower.
# CronReimbursementPayTax every hour
- Selects reimbursements where
paidis true andtaxPaidis false. - Calculates
socialTaxandincomeTax. - Transfers both taxes to the tax wallet.
- Sets
taxPaidto true.
# CronResetTaxExempt every 1st of april at 00:00
- Selects every users where
typeisLENDER. - Sets
taxExemptto false.
# CronSendEmailIncomeTaxExemption every 1st of november at 00:00
- Selects every users where
typeisLENDERandhasOrganizationis 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
statusisSUCCESSFUL. - 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
typeisLENDERandprofileStatusis notAPPROVED. - If
profileApprovedAtwas 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
typeisLENDERand their investments. - If user has
profileApprovedAtand 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
typeisLENDERandriskAssessment.isSignedis 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
profileStatusandkycStatuswith values from Lemonway.
# CronUploadDocument every five minutes
- Selects users where
typeisLENDERandprofileStatusisWALLET_CREATED. - Selects files uploaded by users (proofs) where
uploadIdis null. - Uploads the files to the payment service provider and update the
uploadId.
# CronUploadUBODeclaration every minute MANGOPAY
- Selects organizations where
profileStatusis notNOT_SUBMITTEDorREJECTEDanduboStatusis notVALIDATEDorSUBMITTED. - If
organization.uboStatusisREFUSEDor null, creates a new ubo declaration upload documents and submit ubo declaration. - If
organization.uboStatusisINCOMPLETEupdate submitted ubo document and details. - Else create new ubo declaration upload documents and submit ubo declaration.
# Webhooks
# document MANGOPAY
- triggerd on:
Kyc SucceededorKyc Failed - If Mangopay user's
kYCLevelisREGULAR, updatesprofileStatustoAPPROVED, addskycStatusand sends an email to the user. - Else if there are rejected documents, updates
profileStatustoREJECTED_PSP.
# payment MANGOPAY
- triggered on:
Payin SucceededorPayin Failed - If
PAYIN_NORMAL_SUCCEEDED,send an email to the user and update walletCreditedAt - Increment
logsCounton paynin succeeded or failed
# ubo MANGOPAY
- triggerd on:
Ubo Declaration RefusedorUbo Declaration Validated - If
UBO_DECLARATION_VALIDATED, updateuboStatustoVALIDATED - Else if refused, updates
profileStatustoREJECTED_PSPandkycStatustoACCOUNT_NOT_OPENED