This is just a simple example of using Snap Midtrans payment without Midtrans Package for Node JS. Feel free to give a Pull Request or issues. Scroll down for Indonesian version of this README.
- Clone this repository
npm installto install all required dependencies.- Install MySQL Community Edition on your local machine
- Change
.env.examplefile to.env, and fill up the rest. npm run devto start the local server. Ornpm run dev:tsto start Typescript server.
- Express - Server handling
- Cors - CORS middleware for Express
- Dotenv - Injecting
process.envwith contents from.envfile - Knex - SQL Query builder
- Mysql - Node JS driver for MySQL
- UUID - Creation of UUID
- Axios - HTTP Request library
- ISO-3166-1 - For converting country name to ISO-3166-1 acceptable country code
src/- Application code in Javascript, withindex.jsbeing the entry point.typescript/- Application code in Typescript, withindex.tsbeing the entry point.test/- This folder contains test file for fetching data to the server.
npm run dev- Starts local server with Javascript code (fromsrc/folder)npm run dev:ts- Starts local server with Typescript code (fromtypescript/folder)npm run lint- Lint all files with ESLintnpm run lint:fix- Fixes all fixable errors with ESLintnpm run build- Compiles typescript files fromtypescript/intodist/
There is no response schema for success attemps as we refer directly from Midtrans' Snap Response.
For failed attemps or 400 and 500 status code, the response schema should be:
{
"message": "Error message"
}- Clone repository ini
npm installuntuk menginstall dependency yang diperlukan.- Install MySQL Community Edition pada komputer Anda
- Ubah
.env.examplemenjadi.env, dan isi file tersebut. npm run devuntuk menjalankan local server. Ataunpm run dev:tsuntuk menjalankan Typescript server.
- Express - Server utama
- Cors - CORS middleware untuk Express
- Dotenv - Memasukan
process.envdengan konten dari file.env - Knex - SQL Query builder
- Mysql - Node JS driver untuk MySQL
- UUID - Menciptakan data UUID
- Axios - HTTP Request
- ISO-3166-1 - Untuk mengubah nama negara menjadi format ISO-3166-1
src/- Kode aplikasi dengan bahasa Javascript, denganindex.jsmenjadi entry point.typescript/- Kode aplikasi dengan bahasa Typescript, denganindex.tsmenjadi entry point.test/- Folder ini berisi file tes untuk mendapatkan data dari server.
npm run dev- Menjalankan local server dalam bahasa Javascript (dari foldersrc/)npm run dev:ts- Menjalankan local server dalam bahasa Typescript (dari foldertypescript/)npm run lint- Mencari kesalahan dengan ESLintnpm run lint:fix- Mengoreksi error yang bisa diselesaikan dengan ESLintnpm run build- Menghimpun file typescript daritypescript/kedist/
Tidak ada skema response untuk percobaan yang sukses sebagaimana kami mengambil skema langsung dari Midtrans Snap Response.
Untuk percobaan yang gagal atau dengan status code 400 dan 500, skema response seharusnya menjadi:
{
"message": "Error message"
}