#21 Laravel API Tutorial | Laravel Webhook API | Update Stock via Laravel Webhook | Stock Webhook
Автор: Stack Developers
Загружено: 2021-07-03
Просмотров: 9010
Описание:
In Part-21 of Laravel 8 API Tutorial, we will continue working for Stock Management that we will do with Laravel Webhook API this time.
In this video, we will work on Laravel Webhook or we can say Laravel Webhook API to update the stock at client database from the server but server will call client API when there is update in stock.
There is no 3rd party Stock API link that we need to call with Curl but we will create our own API link that we will provide to 3rd party to hit that API URL whenever there is any change like update in stock.
Steps for creating Stock Webhook API in Laravel :-
1) Create Tables :-
Create products table with below columns :-
id, name, status, created_at, updated_at
Create products_attributes table with below columns :-
id, `product_id, sku, size, price, stock, created_at, updated_at
Insert some dummy products and attributes into the tables.
2) Create Route :-
Now, create post route for webhook in api.php file like below :-
// Webhook POST API - Update Stock
Route::post('update-products-stock','APIController@updateProductsStock');
3) Create updateProductsStock function :-
Now create updateProductsStock function at APIController to update stock of the products at products_attributes table. We will check Authorization first and then update stock of all items provided in json request send by the 3rd party.
Headers :-
Authorization : Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkFtaXQgR3VwdGEiLCJpYXQiOjE1MTYyMzkwMjJ9.cNrgi6Sso9wvs4GlJmFnA4IqJY4o2QEcKXgshJTjfNg
POST :- http://127.0.0.1:8000/api/update-products-stock
Body: Raw data
{
"items":[
{
"sku" :"BCT-S",
"stock" :23
},
{
"sku" :"RCT-S",
"stock" :45
}
]
}
#laravelapitutorial #laravel8api #laravelapitypes #laravelapiexamples #laravelapi #laravelwebhook
Learn to make e-commerce website in Laravel 6 / 7 / 8 :-
• Laravel Tutorial for Beginners | Advance E...
Повторяем попытку...

Доступные форматы для скачивания:
Скачать видео
-
Информация по загрузке: