BigCommerce webhooks listener in rails

2019-08-13 09:32发布

问题:

I'm following the instructions here http://developer.bigcommerce.com/api/webhooks/quickstart to set up webhooks to initiate some third-party order processing. We've been doing this on an hourly batch, real-time webhook triggers will save us a lot of lag time.

I think I've set up the webhook broadcaster, but can't see any evidence that it's being fired- I've created a bunch of new orders and nothing reaches the rails server.

How can I tell if BigCommerce is firing events when / where I expect?

Generated the access token for the given app/user/domain:

curl -XPOST -d '{
  "client_id":"[BigCommerceAppClientId]",
  "client_secret":"[BigCommerceAppSecret]",
  "user":"admin",
  "token":"[adminAPIToken]",
  "store_domain":"https://[myStore].mybigcommerce.com"
}' https://hooks-beta.bigcommerce.com/token 

yields ===>

{
  "access_token":"[webHooksAccessToken]",
  "producer":"store/[myStoreKey]"
}

Subscribed to webhooks for store/events/listener:

curl -XPOST -d '{
  "producer":"store/[myStoreKey]",
  "scope":"store/order/created",
  "deliverymethod":"HTTP_POST",
  "destination":{"url":"http://[myPublicRailsServer]/hooks"}
}' -H 'X-Auth-Client: [BigCommerceAppClientId]' -H 'X-Auth-Token:[X-Auth-Token]' https://hooks-beta.bigcommerce.com

yields ===>

{
  "client_id":"[webHooksAccessToken]",
  "created_at":"2013-06-27T19:57:38+00:00",
  "deliverymethod":"HTTP_POST","destination":{"url":"http://[myPublicRailsServer]/hooks"},
  "id":651,
  "producer":"store/[myStoreKey]",
  "scope":"store/order/created",
  "updated_at":"2013-06-27T19:57:38+00:00"
}

回答1:

I lied. The problem was apparently trying to use https instead of http. Everything works as expected.

Furthermore- BigCommerce provides a hook to check the active clients for a given application:

curl -XGET -H 
  'X-Auth-Client: [BigCommerceAppClientId]' -H 
  'X-Auth-Token: [BigCommerceAppSecret]' 
https://hooks-beta.bigcommerce.com/producer/store/[myStoreKey]