AZA Reserve and Acquirer Calculation ==== Business overview === ## Type of reserves - main pool - request charge-in (operator) - upload evidence of the transaction - applying the percentages calculation - accept charge-in (admin) - checking the evidence and checking the bank - accept and append the balance to main pool - acquirer pool - request charge-in for specifc pool (operator) - request specific amount to be transfered from the main pool to the acquirer's - inform the operator the amount after the calculation of the percentages - accept request (admin) - proceed to the transfer - update the system <br /> Technical Details === ## Main Reserve / Main Pool ### request charge-in (operator) - `/operator/mainReserve` - `/details` - response ``` { currentBalance, ...details, } ``` - `/charge` - `/request` - request body ``` { amount, currency, evidence } ``` - response ``` { amount currency attachment status chargePercentageId percentages: { actualCharge: { amount currency } mainMerchantCurrency mainMerchantCurrencyExchangeRate: { from to rate } chargedAmount vapulusFixedAmount vapulusPercentage calculatelatelate } } ``` - `/details` - request body ``` { id } ``` - response ``` { id amount, currency, evidence, status } ``` - `/update` operator shouldn't be able to change non-pending requests - request body ``` { id amount, currency, evidence } ``` - response ``` { status: pending, percentages: { chargedAmount, vapulusFixedAmount, vapulusPercentage, calculatedAmount }, } ``` - `/list` operator should be able to apply filter - response ``` [ { id, status } ] ``` ### accept charge-in (admin) - `/admin/operatorMainReserve` - `/currentBalance` - request body ``` { operatorId } ``` - response ``` { ...balanceDetails } ``` - `/chargeRequest/list` - response ``` [ { id, operatorId, status } ] ``` - `/chargeRequest/details` - response ``` { id amount, currency, evidence, } ``` - `/chargeRequest/respond` - request ``` { chargeId, status, reason, } <br /> ## Acquirer Pool / Acquirer Reserve ### Request Charge-in (operator) - `/operator/acquirerReserve` - `/currentBalance` - request body ``` { acquirerCodeName } ``` - response ``` { ...balanceDetails } ``` - `/listChargableAcquirers` - response ``` [ { ...acquirerData } ] ``` - `/charge` - `/request` - request body ``` { acquirerCodeName, amount, currency } ``` - response ``` { status: pending, percentages: { chargedAmount, vapulusFixedAmount, vapulusPercentage, calculatedAmount }, } ``` - `/request-back` <strong style="color: red">???</strong> - `/details` - request body ``` { id } ``` - response ``` { ...chargedDetails, } ``` - `/update` operator shouldn't be able to change non-pending requests - request body ``` { id amount, currency } ``` - response ``` { status: pending, percentages: { chargedAmount, vapulusFixedAmount, vapulusPercentage, calculatedAmount }, } ``` - `/list` operator should be able to apply filter - response ``` [ { id, status } ] ``` ### Accept Charge-in (admin) - `/admin/operatorAcquirerReserve` - `/currentBalance` - request body ``` { operatorId acquirerCodeName } ``` - `/list` - response ``` [ { id, operatorId, status } ] ``` - `/chargeRequest/details` - response ``` { ...chargedDetails } ``` - `/chargeRequest/respond` - request ``` { id, status, reason, } ``` ## Additional APIs - `/operator/getMainMerchantId` - request body ``` { deviceToken, authorization fingerPrint } ``` - response ``` { merchantId } ``` <br /> Required Models === - MainReserveCharge - id - issuerId - issuerRole - amount - currency - forexDetails (json) - timestamps - status {enum (PENDING, IN_PROGRESS, ACCEPTED, REJECTED)} - AcquirerReserveCharge - id - issuerId - issuerRole - acquiredCodeName - amount - currency - forexDetails (json) - timestamps - status {enum (PENDING, IN_PROGRESS, ACCEPTED, REJECTED)} - ChargeLog - id - chargeId - chargeType {enum (MAIN_RESERVE, ACQUIRER_RESERVE)} - status {enum (PENDING, IN_PROGRESS, ACCEPTED, REJECTED)} - actorId - actorRole - details - OperatorChargePercentage - id - operatorId - type {enum (CUSTOM, DEFAULT)} - fixedAmount - fixedAmountCurrency - percentage - defaultPercentageVersion - timestamps Main Reserve Calculation === ``` current balance = sum(acceptedMainCharges) + sum(settledPayIns) - sum([accepted, PENDING, IN_PROGRESS]AcquirerCharges) ``` Acquirer Reserve Calculation === ``` current balance = sum(acceptdAcquirerCharges) - sum(accepted and pending acquirer pay-outs) ``` <br /><br /> TODOs === - main reserve - operator calls & update operator roles - `/operator/mainReserve` - [x] `/details` - `/charge` - [x] `/request` - [x] `/details` - [x] `/update` - [x] `/list` - admin calls & update admin roles - [x] `/admin/operator/setChargePercentage` - `/admin/operatorMainReserve` - [ ] `/currentBalance`` - `/chargeRequest` - [x] `/list` - [x] `/details` - [x] `/respond` - acquirer reserve - operator calls & update operator roles - `operator/acquirerReserve` - [x] `/currentBalance` - [x] `/listChargableAcquirers` - `/charge` - [x] `/request` - [x] `/details` - [x] `/update` - [x] `/list` - admin calls & update admin roles - `/admin/operatorAcquirerReserve` - [x] `/setAcquirerChargePercentage` - [x] `/currentBalance` - [x] `/list` - `/chargeRequest` - [ ] `/details` - [x] `/process` - [x] `/respond` - additional apis - [ ] `/operator/getMainMerchantId` - [ ] Check balance before charging any acquirer (<span style="color: red">***very important***</span>) - [ ] implement payouts in queues (<span style="color: red">***very important***</span>) - [ ] enable specific pay-out acquirers for the operator from admin api (<span style="color: orange">***medium***</span>) - [ ] create another user for AZA at the bootstrap service (<span style="color: red">***very important***</span>) - [ ] Handle test and production recharges (<span style="color: red">***important***</span>) - [ ] Prevent main merchant from creating more than one app (<span style="color: red">***very important***</span>)