Clone the repository from your version control system
git clone https://github.com/Rann-Studio/saweria-deposit-system
cd saweria-deposit-system
Install the required npm packages:
npm install
Create a .env file in the root directory of your project and add the following environment variables:
PORT=3000
WEBHOOK_SECRET=your-webhook-secret
Run Prisma migrations to set up the SQLite database:
npx prisma migrate dev --name init
Run the server using the following command:
npm start
URL: POST /deposit
Description: Creates a new deposit record.
Request Body:
{
"userId": <user-id>,
"amount": <amount>
}
URL: POST /webhook
Description: Verifies and updates deposit status based on the webhook notification.
Query Parameters:
secret
: The webhook secret defined in .env
Example: /webhook?secret=your-webhook-secret
To integrate the webhook with Saweria:
- Log in to your Saweria account.
- Navigate to the Integration settings page.
- Select the Webhook option.
- Add webhook endpoint with the URL corresponding to your server's
/webhook
endpoint. For example:https://your-domain.com/webhook?secret=your-webhook-secret
. - Save the configuration.