Requirements
docker
composer
- Clone the repository from GitHub from
Terminal
.
git clone [email protected]:thihakyaw/payment-integration-test.git
- Get into the project directory.
cd payment-integration-test
- Install packages using
composer
.
composer install
If you are still using the composer
version 1 and faced memory limit issue, please use this command.
COMPOSER_MEMORY_LIMIT=-1 composer install
-
create a new file
.env
in root directory of the project and copy everything inside from.env.example
. For STRIPE_KEY and STRIPE_SECRET values, you can have your own keys from your Stripe account if you prefer to see the customers and payments created on Stripe side. The API keys inside.env.example
is values that are generated from my account. -
In project directory, run this command to setup the project in
docker
. It will take around 5-10 minutes for the first time composing for Laravel project.
- Tip - set up alias in
zsh
for./vendor/bin/sail
follow this guideline or if you are usingbash
, follow the bash alias setup guideline
if you have any mysql service running on localhost with port 3306, please stop that and continue this setup
./vendor/bin/sail up -d
Install composer again using sail command just to make sure every packages required are in sail.
./vendor/bin/sail composer install
I recommend running in development (-d) mode as we are testing this on local machine.
- Generate application key for Laravel before starting for the first time.
./vendor/bin/sail artisan key:generate
- Migrate database following this command
./vendor/bin/sail artisan migrate
Now, we can access the project from localhost
.
Framework - Laravel
Third-party Stripe Library - Laravel Cashier
Database Design
Sequence Diagram
Testing
As this project use Laravel Cashier
package, there is no separated service classes for charging payment. There is no unit test therefore. Instead, I wrote Feature Test
as a user’s perspective.
Note - for feature test, I wanted to use fake name generator and fake email generator rather than hardcoding the name and email but there is something wrong with Faker from Laravel and time is limited, I have to use hard coded values for name and email.
To run the tests, run this command
./vendor/bin/sail artisan test
User Interface
When you start call the http://localhost , you will start to see the checkout component only first. After finished step 1, step 2 component will appear and after finishing the step 2, step 3 component will appear.
- The checkout component. You have to fill in the price not lower than 349$. This is for a test purpose. You can fill any amount that you want to charge for the
Sony WH-1000XM4
. Fill in your name and email and then presscheckout
. You will see payment section - Fill the card information.
Card holder name
can be anyone’s name. For card information testing, you can use these number -
- Visa Card - 4242 4242 4242 4242
- Master Card - 5200828282828210
Expiry Month and Expiry Year can be Any future date
. CVC
and ZIP
number can be any number.
For more Cards to test, check this Stripe Card Testing Page.
- After payment is charger, you will see the payment information including payment status and card information that Stripe has offer
Database Connection Access
In case you want to access database from SequelPro or Workbench, use these credentials.
The credentials are from .env.example
.
host - localhost
port - 3306
username - root
password - password
Postman Collection
Add {{host}} as localhost
in env setup.
Check the PaymentIntegrationTestPostmanCollection.json
from the project root directory.