The Pay-Simple API provides endpoints for a simulation payment system. It includes authentication, user registration, profile management, balance inquiries, product listings, and transaction history.
- Have a Git that has been installed on your computer
- Go Language has been installed and PostgreSQL
- Have this clone repo
- Or please access endpoint https://pay-simple.adaptable.app/api/v1/{resource} using a REST Client such as Postman or Insomnia to make a request without having to do this clone repo
Note*: I recommend running the application locally, as there were some issues during the deployment process and I haven't tried all the endpoints that were created. But for the process of registering, logging in, logging out, and viewing all products it runs smoothly on the adaptable server.
If you want to clone this repo and run it on your local computer. Follow these steps
# clone this repository using command
git clone https://github.com/Rizkyyullah/pay-simple.git
# cd to it
cd pay-simple
# you must enter key and value pair on the .env file, which is used to retrieve database configurations, server ports etc.
# you can copy the contents of .env.example file, create the .env file and fill in the value according to your configuration
# after that run this command to start application
go run main.go
Logout the currently authenticated user.
- Request Method: GET
- Response:
{
"status": "Success",
"code": 200,
"message": "Logout Successfully"
}
Register a new merchant. For balance I gave automatically 10,000,000 to facilitate the simulation process. You can also do topup and transfer to other users
Request:
- Method:
POST
- Body:
{
"name": "Merchant 1",
"username": "merchant 1",
"email": "[email protected]",
"phoneNumber": "0812345678910",
"password": "password",
"confirmPassword": "password"
}
- Response Body:
{
"meta": {
"status": "Success",
"code": 201,
"message": "Register Successfully",
"createdAt": "Thursday, 25 January 2024 18:57:13 WIB"
},
"data": {
"id": "USR-0001",
"name": "Merchant 1",
"username": "merchant 1",
"balance": 10000000,
"email": "[email protected]",
"phoneNumber": "0812345678910",
"role": "MERCHANT"
}
}
Authenticate a merchant.
Request:
- Method:
POST
- Body:
{
"email": "[email protected]",
"password": "password"
}
Response:
{
"status": "Success",
"code": 200,
"message": "Login Successfully"
}
Register a new customer.
Request:
- Method:
POST
- Body:
{
"name": "Customer 1",
"username": "customer 1",
"email": "[email protected]",
"phoneNumber": "0812345678911",
"password": "password",
"confirmPassword": "password"
}
- Response Body:
{
"meta": {
"status": "Success",
"code": 201,
"message": "Register Successfully",
"createdAt": "Thursday, 25 January 2024 18:57:13 WIB"
},
"data": {
"id": "USR-0002",
"name": "Customer 2",
"username": "customer 2",
"balance": 10000000,
"email": "[email protected]",
"phoneNumber": "0812345678911",
"role": "CUSTOMER"
}
}
Authenticate a customer.
Request:
- Method:
POST
- Body:
{
"email": "[email protected]",
"password": "password"
}
Response:
{
"status": "Success",
"code": 200,
"message": "Login Successfully"
}
Retrieve the profile of the authenticated user.
Request:
- Method:
GET
- Response:
{
"meta": {
"status": "Success",
"code": 200,
"message": "Your profile"
},
"data": {
"id": "USR-0002",
"name": "Customer 2",
"username": "customer 2",
"balance": 10000,
"email": "[email protected]",
"phoneNumber": "0812345678910",
"role": "CUSTOMER"
}
}
Retrieve the balance of the authenticated merchant.
Request:
- Method:
GET
- Response:
{
"meta": {
"status": "Success",
"code": 200,
"message": "Your current balance"
},
"data": {
"balance": 10000000
}
}
Retrieve the balance of the authenticated customers.
Request:
- Method:
GET
- Response:
{
"meta": {
"status": "Success",
"code": 200,
"message": "Your current balance"
},
"data": {
"balance": 10000000
}
}
Retrieve a list of available products.
Request:
- Method:
GET
- Parameters:
- page (How good page you want to access)
- size (How many data do you want to display on one page)
- Response:
{
"meta": {
"status": "Success",
"code": 200,
"message": "Get all products successfully"
},
"data": [
{
"id": "PRD-0001",
"merchant": {
"name": "Merchant 1",
"username": "merchant 1",
"email": "[email protected]",
"phoneNumber": "0812345678910"
},
"productName": "Product A",
"description": "Desc A",
"stock": 90,
"price": 40000,
"createdAt": "2024-01-25T09:19:55Z",
"updatedAt": "2024-01-25T09:19:55Z"
}
],
"paging": {
"page": 1,
"rowsPerPage": 5,
"totalRows": 1,
"totalPages": 1
}
}
Retrieve a specific product by id.
Request:
- Method:
GET
- Parameters: id (Product ID)
- Response:
{
"meta": {
"status": "Success",
"code": 200,
"message": "Get all products successfully"
},
"data": {
"id": "PRD-0001",
"merchant": {
"name": "Merchant 1",
"username": "merchant 1",
"email": "[email protected]",
"phoneNumber": "0812345678910"
},
"productName": "Product A",
"description": "Desc A",
"stock": 90,
"price": 40000,
"createdAt": "2024-01-25T09:19:55Z",
"updatedAt": "2024-01-25T09:19:55Z"
}
}
Retrieve a list of products associated with the authenticated merchant.
Request:
- Method:
GET
- Parameters:
- page (How good page you want to access)
- size (How many data do you want to display on one page)
- Response:
{
"meta": {
"status": "Success",
"code": 200,
"message": "Your products"
},
"data": [
{
"id": "PRD-0001",
"productName": "Product A",
"description": "Desc 1",
"stock": 90,
"price": 40000,
"createdAt": "2024-01-25T09:19:55Z",
"updatedAt": "2024-01-25T09:19:55Z"
}
],
"paging": {
"page": 1,
"rowsPerPage": 5,
"totalRows": 1,
"totalPages": 1
}
}
Add a new product to the inventory of the authenticated merchant.
Request:
- Method:
POST
- Body:
{
"productName": "Product A Mark II",
"description": "Desc Product A Mark II",
"stock": 10,
"price": 10000
}
- Response:
{
"meta": {
"status": "Success",
"code": 201,
"message": "Create product successfully",
"createdAt": "Friday, 2 January 2024 02:36:45 WIB"
},
"data": {
"id": "PRD-0002",
"merchant": {
"name": "Merchant 1",
"username": "merchant 1",
"email": "[email protected]"
},
"productName": "Product A Mark II",
"description": "Desc Product A Mark II",
"stock": 10,
"price": 10000
}
}
Delete product based on ID by authenticated merchant.
Request:
- Method:
DELETE
- Parameters: id (Product ID)
Response:
{
"status": "Success",
"code": 200,
"message": "Delete product successfully"
}
Retrieve the transaction history of the authenticated customer.
Request:
- Method:
GET
- Parameters:
- page (How good page you want to access)
- size (How many data do you want to display on one page)
Response:
{
"meta": {
"status": "Success",
"code": 200,
"message": "Your transactions history"
},
"data": [
{
"id": "TRX-0001",
"transactionDate": "Friday, 26 January 2024",
"transactionType": "DEBIT",
"cashflow": "MONEY_OUT",
"createdAt": "Friday, 26 January 2024 10:52:11 WIB"
}
],
"paging": {
"page": 1,
"rowsPerPage": 5,
"totalRows": 1,
"totalPages": 1
}
}
Retrieve details of a specific transaction of the authenticated customer.
Request:
- Method:
GET
- Parameters: id (Transaction ID)
- Response:
{
"meta": {
"status": "Success",
"code": 200,
"message": "Your transaction history"
},
"data": {
"id": "TRX-0001",
"transactionDate": "Thursday, 25 January 2024",
"transactionType": "DEBIT",
"paidStatus": true,
"cashFlow": "MONEY_OUT",
"createdAt": "Thursday, 25 January 2024 16:12:14 WIB"
}
}
Initiate a new transaction for the authenticated customer.
Request:
- Method:
POST
- Body:
{
"products": [
{
"id": "PRD-0001",
"merchantId": "USR-0001",
"quantity": 1
}
]
}
Top up the balance of the authenticated customer.
Request:
- Method:
POST
- Body:
{
"amount": 150000
}
- Response:
{
"meta": {
"status": "Success",
"code": 200,
"message": "Topup successfully"
},
"data": {
"balance": 1120000
}
}
Transfer a specified amount to another users.
Request:
- Method:
POST
- Body:
{
"toUserId": "USR-0001",
"amount": 150000
}
- Response:
{
"meta": {
"status": "Success",
"code": 200,
"message": "Transfer successfully"
},
"data": {
"balance": 970000
}
}