osiset / laravel -shopify- webhook中的用户身份验证

发布于 2025-01-29 03:36:26 字数 750 浏览 3 评论 0原文

我是Shopify应用程序开发的新手。我想在Laravel作业中进行Admin API调用,这是触发Webhook通知时。

以下是应用程序流的详细信息:

  1. 客户在收到订单创建
  2. Webhook通知时触发商户订单中创建
  3. 订单- 我想通过类型使用费用拨打计费API。

我遇到的主要问题是如何在Webhook中对用户进行身份验证。我知道使用$ shop = auth :: user()在shopify管理中身份验证用户; $ shopapi = $ shop-> api() - > rest('get','/admin/shop.json'prion.jesh'prion.json'proh但是这个献祭在Laravel工作处理方法中起作用。

我当时想保存生成的访问权限“ $ shop = auth :: user(); $ shopapi = $ shop-> api()”。但是我似乎找不到访问access_token并将其保存到数据库中的方法,以便我可以使用相同的access_token来制作计费API请求。 这是最好的方法。 Access_Token有任何有效期吗?

如果也有任何最佳方法,请建议您。

谢谢

I am new to shopify app development. I want to make ADMIN API call in Laravel Jobs that is when webhook notification is triggered.

Here is the details of app flow:

  1. Customer creates order in merchant shop
  2. Order-create webhook is triggered
  3. When order-create webhook notification is received I want to call billing api with type usage charge.

The main problem I have is how to authenticate user in webhook. I know to authenticate the user within Shopify admin using $shop = Auth::user(); $shopApi = $shop->api()->rest('GET', '/admin/shop.json')['body']['shop'];. But this donot work in Laravel Job handle method.

I was thinking to save the access-token that is generated " $shop = Auth::user(); $shopApi = $shop->api()". But I can't seem to find the way to access the access_token and save it into the database so that I can use same access_token to make billing api requests.
enter image description here
Is this approach the best approach. Does access_token has any expiry date?

Please recommend if there is any best approach as well.

Thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

陌若浮生 2025-02-05 03:36:26

我假设您想从作业类访问用户。因此,在每个工作类中的此软件包中,您可以轻松找到Shopdomain $ this-> Shopdomain。因此,只需从各自的商店域中获取用户的数据:

$shop = User::where('name', $this->shopDomain)->first();

如果有商店:

$shopApi = $shop->api()->rest('GET', '/admin/shop.json')['body']['shop'];

我希望这对您有所帮助。如果有任何问题,请在此处发表评论。

I am assuming that you want to access user from job class. So in this package in every job class, you can easily found the shopDomain $this->shopDomain. So then just get the data of the user from that respective shopDomain:

$shop = User::where('name', $this->shopDomain)->first();

If there is a shop then:

$shopApi = $shop->api()->rest('GET', '/admin/shop.json')['body']['shop'];

I hope this will help you. If there is any issue, please comment here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文