Move Batch Payment Validation Logic to Backend API
gruz0 opened this issue · 0 comments
We would like to optimize the gas consumption during batch payment processing on the blockchain by moving the relevant logic from the smart contract to our backend API. The proposed solution involves creating a new endpoint, /api/blockchain/verify_batch_payment
, which will accept a POST request with the following attributes in the request body:
groupId
: The identifier of the group to which the user should have access.recipients
: An array of objects containing the following attributes for each recipient:recipient_id
: The identifier of the recipient.payment_amount
: The positive value of the payment amount.
The primary responsibility of this endpoint will be to validate the data that will be sent from the frontend to the blockchain. The validation process should include the following steps:
- Verify that the user making the request has access to the specified
groupId
. - Verify that each recipient belongs to the specified
groupId
. - Ensure that the
payment_amount
for each recipient is a positive value.
If all the validation checks pass, the endpoint should return a response with a status code of 200. In case of any validation failure, the endpoint should return a response with a status code of 422, along with an appropriate error explanation.