simple client request send to vendor via mai based on laravel5.8 + mysql + event/listener/jobs
This project only provide a basic structure to show case api call to trigger event > listener > dispatch jobs. There's no JWT validation involved.
- Client makes Requests -> Waits for 5 seconds -> Sends Request to Vendor via Mail
Client make api call to update payment -> send payment details to vendor via mail
Mail set to log
in this project. To see the sent mail, please go to storage/logs/laravel.log
to see the mail content. You can set it up smtp or other driver. Update config/mail.php
accordingly.
Open terminal and navigate to the project folder and run php artisan queue:listen
before you make any api request.
If you already have docker and docker-compose. Open your terminal and go to the project folder.
- run
docker-compose build
- run
docker-compose up
- run
docker ps
to get the container id ofapp
, and rundocker exec -it {container id} sh
to go into the container. - run
php artisan migrate
to install the database - run
php artisan queue:listen
to start the queue worker. - go to postman with
localhost
or127.0.0.0
to access the endpoints.
You will need to have mysql 5.7, composer and other required tools and extensions pre-installed before you can start this project. Check here for the requirement: (https://laravel.com/docs/5.8#installation)
- go to project folder and open
config/database.php
and change the root password and database name accordingly. - open terminal and nagivate to the project folder, run
composer install
to install all the required files - run
php artisan migrate
to install the database - run
php artisan serve
to start the service. - Open another terminal in the same project folder and run
php artisan queue:listen
to start the queue worker. - go to postman with
localhost
or127.0.0.0
to access the endpoints.
client_name (required) vendor_email (required, valid email)
sample response:
{
"client_name": "aaa",
"vendor_email": "vendor@email.com",
"status": "new",
"updated_at": "2019-09-08 09:46:22",
"created_at": "2019-09-08 09:46:22",
"id": 1
}
Please make sure you have started the queue worker. Email will be send (in this project, inside log) after 5 seconds. You will need the id for the next endpoint.
payment_method (required, string) transaction_references (required, string)
sample response:
{
"msg": "Update successfully."
}
Email will be send immediately with updated status: payment_done, payment method, transaction reference, payment date (UTC)