#21 Laravel API Tutorial | Laravel Webhook API | Update Stock via Laravel Webhook | Stock Webhook
HTML-код
- Опубликовано: 19 окт 2024
- 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 :- 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 B...
Webhook and API's are almost same or we can say both are in actual API's right ?
There is some difference in both. If you need to receive data or notifications in real-time, you should look to use webhooks. But if there isn't a time-sensitive need for the data or notifications, or your integration requirements extend beyond POST requests, REST APIs are likely a better approach.
Hi, can you plz make stripe webhook criteria when we use subscriptions ?
Hi thanks for the suggestion... I will try to do in new Laravel 10 series
This tutorial is consists of eCommerce laravel 8 project series
???
This series is still at the starting phase covering all types of Api's that can be used in Laravel websites and very soon going to start API's for E-commerce series.. It's going to be biggest and deepest online Laravel API's series that will cover everything..
@@StackDevelopers
u r awesome really
and when can u begin at b2b series
Very soon with Laravel 9 launch
Please also make videos on OOPS CONCEPT
Can you plz do " stripe webhook integration laravel with cron job alerts subscription stripe flow" ?
Sure we will do it in Laravel 10 series..
why you don't use illuminate\Support\Facades\Http dude?
Where? Please elaborate.
@@StackDevelopers curl is php native library, and you can use illuminate\Support\Facades\Http for Laravel Project
@@VanVangka Exactly
i want the repo ::c
Please join as a member to get source code
ruclips.net/channel/UCExO2i-tLU1NyVZD6zOJQlwjoin
exception "Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException"
file "C:\\xampp\\htdocs\\blogfood\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\AbstractRouteCollection.php"
line 43
e error change password keyup function time aa ahi hai plz help
What are you trying to do? Send me more details and always try to debug your code..