This is a take home test from Detikcom. It is an API for payment services. This API allow us to create and get payment transaction details.
- Clone Repository
Git clone https://github.com/fakriardian/detikcom.git
- Install package
composer install
- Setup environment for database at env.php
$variables = [
'DB_HOST' => 'localhost',
'DB_USERNAME' => 'root',
'DB_PASSWORD' => '',
'DB_NAME' => 'test',
'DB_PORT' => 3306,
];
- Create database
php ./src/db/createDatabase.php
- Migration table
./vendor/bin/phinx migrate -e development
- Seeder table
./vendor/bin/phinx seed:run -s TTransactionSeeder
- Run server
php -S localhost:8000
- Update transaction
php ./transaction-cli.php {references_id} {status}
- create transaction
curl --location --request POST 'http://localhost:8000/create' \
--header 'Content-Type: application/json' \
--data-raw '{
"invoice_id": "INV-20211025",
"item_name": "sepatu",
"amount": 200000,
"payment_type": "credit_card",
"customer_name": "uxi",
"merchant_id": "a8706902-6cd0-42ea-a7a2-83316521ab61"
}'
- get detail transaction
curl --location --request GET 'http://localhost:8000/status?references_id=ac79dba1-8bed-48ca-9e03-beb48c754fd9&merchant_id=a8706902-6cd0-42ea-a7a2-83316521ab61'
- get all transaction
curl --location --request GET 'http://localhost:8000/status'