- Clone repository (https://github.com/mahmoudhaggag641/order-payment-api.git)
- Copy
.env.exampleto.envbycp .env.example .envand configure DB and gateway env keys - Run
composer install - Run
php artisan key:generate - Run migrations:
php artisan migrate
You can view the API documentation by.
-
You can visit the following URL in your local environment to see and test all endpoints:
-
Or The
order_payment_api.jsonfile in the root of the repository is exported from previous step/page by clicking onOpenAPI 3.0button. -
And you can Import
order_payment_api.jsoninto Postman or any other tool.
The system uses Strategy Pattern for payment gateways. To add a new gateway:
-
Create a class implementing
PaymentGatewayInterfaceinapp/Services/Payment/. -
Add it to
config/payment.phpundergateways -
Add configuration in
.envif needed -
The
PaymentServicewill automatically pick up method => class mapping.Example shown in
app/Services/Payment/Gateways/Stripe.phpapp/Services/Payment/Gateways/PayPal.php
-
I used webhook way, because it is more secure
server-to-serverand recommended by all payment providers. -
And you can use
/api/payment/{gateway_name}/webhookroute to using it with any payment gateway.
Run php artisan test for feature and unit tests.
