株式会社メタフェイズ

Shopify

Webhook

メタフェイズではShopifyを利用したストア構築を行っています。
今回はWebhookを設定する方法を紹介いたします。

1「設定」をクリックします。

template00.png

2「通知」をクリックします。

webhook03.png

3「Webhookを作成」をクリックします。

webhook00.png

4 各入力欄へ入力し「保存」をクリックします。

※URLは「https」で始まるURLを入力して下さい。

webhook02.png

付録

上記設定では「注文の支払い」時にURLにJSONで注文情報が送信されます。
送信される情報は下記のようなものです。
http header

Host : 送信先ドメイン
X-Forwarded-Host : 送信先ドメイン
X-Forwarded-For : xxx.xxx.xxx.xxx
X-Forwarded-Proto : https
X-Backend : xxx.xxx.xxx
Content-Length : 6502
Content-Type : application/json
X-Shopify-Topic : orders/paid
X-Shopify-Shop-Domain : xxxxxx.myshopify.com
X-Shopify-Order-Id : 123456789
X-Shopify-Test : true
X-Shopify-Hmac-Sha256 : xxxxxxxxxxxxxx
X-Shopify-Webhook-Id : xxxx-xxxx-xxxx-xxxx-xxxx
X-Shopify-Api-Version : 2021-04
Accept-Encoding : gzip;q=1.0,deflate;q=0.6,identity;q=0.3
Accept : */*
User-Agent : Ruby

http body

{
 "id": 820982911946154508,
 "email": "jon@doe.ca",
 "closed_at": null,
 "created_at": "2021-06-21T16:59:36+09:00",
 "updated_at": "2021-06-21T16:59:36+09:00",
 "number": 234,
 "note": null,
 "token": "123456abcd",
 "gateway": null,
 "test": true,
 "total_price": "1805",
 "subtotal_price": "1795",
 "total_weight": 0,
 "total_tax": "0",
 "taxes_included": false,
 "currency": "JPY",
 "financial_status": "voided",
 "confirmed": false,
 "total_discounts": "5",
 "total_line_items_price": "1800",
 "cart_token": null,
 "buyer_accepts_marketing": true,
 "name": "#9999",
 "referring_site": null,
 "landing_site": null,
 "cancelled_at": "2021-06-21T16:59:36+09:00",
 "cancel_reason": "customer",
 "total_price_usd": null,
 "checkout_token": null,
 "reference": null,
 "user_id": null,
 "location_id": null,
 "source_identifier": null,
 "source_url": null,
 "processed_at": null,
 "device_id": null,
 "phone": null,
 "customer_locale": "ja",
 "app_id": null,
 "browser_ip": null,
 "landing_site_ref": null,
 "order_number": 1234,
 "discount_applications": [
   {
     "type": "manual",
     "value": "5.0",
     "value_type": "fixed_amount",
     "allocation_method": "across",
     "target_selection": "explicit",
     "target_type": "line_item",
     "description": "Discount",
     "title": "Discount"
   }
 ],
 "discount_codes": [],
 "note_attributes": [],
 "payment_gateway_names": [
   "visa",
   "bogus"
 ],
 "processing_method": "",
 "checkout_id": null,
 "source_name": "web",
 "fulfillment_status": "pending",
 "tax_lines": [],
 "tags": "",
 "contact_email": "jon@doe.ca",
 "order_status_url": "https:\/\/xxxxxx.myshopify.com\/54097543337\/orders\/123456abcd\/authenticate?key=abcdefg",
 "presentment_currency": "JPY",
 "total_line_items_price_set": {
   "shop_money": {
     "amount": "1800",
     "currency_code": "JPY"
   },
   "presentment_money": {
     "amount": "1800",
     "currency_code": "JPY"
   }
 },
 "total_discounts_set": {
   "shop_money": {
     "amount": "5",
     "currency_code": "JPY"
   },
   "presentment_money": {
     "amount": "5",
     "currency_code": "JPY"
   }
 },
 "total_shipping_price_set": {
   "shop_money": {
     "amount": "10",
     "currency_code": "JPY"
   },
   "presentment_money": {
     "amount": "10",
     "currency_code": "JPY"
   }
 },
 "subtotal_price_set": {
   "shop_money": {
     "amount": "1795",
     "currency_code": "JPY"
   },
   "presentment_money": {
     "amount": "1795",
     "currency_code": "JPY"
   }
 },
 "total_price_set": {
   "shop_money": {
     "amount": "1805",
     "currency_code": "JPY"
   },
   "presentment_money": {
     "amount": "1805",
     "currency_code": "JPY"
   }
 },
 "total_tax_set": {
   "shop_money": {
     "amount": "0",
     "currency_code": "JPY"
   },
   "presentment_money": {
     "amount": "0",
     "currency_code": "JPY"
   }
 },
 "line_items": [
   {
     "id": xxxxx,
     "variant_id": xxxxxx,
     "title": "アイテム1バリエーション無し",
     "quantity": 1,
     "sku": "",
     "variant_title": null,
     "vendor": null,
     "fulfillment_service": "manual",
     "product_id": xxxxxxx,
     "requires_shipping": true,
     "taxable": true,
     "gift_card": false,
     "name": "アイテム1バリエーション無し",
     "variant_inventory_management": "shopify",
     "properties": [],
     "product_exists": true,
     "fulfillable_quantity": 1,
     "grams": 0,
     "price": "900",
     "total_discount": "0",
     "fulfillment_status": null,
     "price_set": {
       "shop_money": {
         "amount": "900",
         "currency_code": "JPY"
       },
       "presentment_money": {
         "amount": "900",
         "currency_code": "JPY"
       }
     },
     "total_discount_set": {
       "shop_money": {
         "amount": "0",
         "currency_code": "JPY"
       },
       "presentment_money": {
         "amount": "0",
         "currency_code": "JPY"
       }
     },
     "discount_allocations": [],
     "duties": [],
     "admin_graphql_api_id": "gid:\/\/shopify\/LineItem\/xxxxxxxxxx",
     "tax_lines": []
   },
   {
     "id": xxxxxxx,
     "variant_id": xxxxxxxxxx,
     "title": "アイテム1バリエーション無し",
     "quantity": 1,
     "sku": "",
     "variant_title": null,
     "vendor": null,
     "fulfillment_service": "manual",
     "product_id": xxxxxxxx,
     "requires_shipping": true,
     "taxable": true,
     "gift_card": false,
     "name": "アイテム1バリエーション無し",
     "variant_inventory_management": "shopify",
     "properties": [],
     "product_exists": true,
     "fulfillable_quantity": 1,
     "grams": 0,
     "price": "900",
     "total_discount": "5",
     "fulfillment_status": null,
     "price_set": {
       "shop_money": {
         "amount": "900",
         "currency_code": "JPY"
       },
       "presentment_money": {
         "amount": "900",
         "currency_code": "JPY"
       }
     },
     "total_discount_set": {
       "shop_money": {
         "amount": "5",
         "currency_code": "JPY"
       },
       "presentment_money": {
         "amount": "5",
         "currency_code": "JPY"
       }
     },
     "discount_allocations": [
       {
         "amount": "5",
         "discount_application_index": 0,
         "amount_set": {
           "shop_money": {
             "amount": "5",
             "currency_code": "JPY"
           },
           "presentment_money": {
             "amount": "5",
             "currency_code": "JPY"
           }
         }
       }
     ],
     "duties": [],
     "admin_graphql_api_id": "gid:\/\/shopify\/LineItem\/xxxxxxx",
     "tax_lines": []
   }
 ],
 "fulfillments": [],
 "refunds": [],
 "total_tip_received": "0.0",
 "original_total_duties_set": null,
 "current_total_duties_set": null,
 "admin_graphql_api_id": "gid:\/\/shopify\/Order\/xxxxxxxx",
 "shipping_lines": [
   {
     "id": xxxxxxxx,
     "title": "Generic Shipping",
     "price": "10",
     "code": null,
     "source": "shopify",
     "phone": null,
     "requested_fulfillment_service_id": null,
     "delivery_category": null,
     "carrier_identifier": null,
     "discounted_price": "10",
     "price_set": {
       "shop_money": {
         "amount": "10",
         "currency_code": "JPY"
       },
       "presentment_money": {
         "amount": "10",
         "currency_code": "JPY"
       }
     },
     "discounted_price_set": {
       "shop_money": {
         "amount": "10",
         "currency_code": "JPY"
       },
       "presentment_money": {
         "amount": "10",
         "currency_code": "JPY"
       }
     },
     "discount_allocations": [],
     "tax_lines": []
   }
 ],
 "billing_address": {
   "first_name": "太郎",
   "address1": "請求通り",
   "phone": "555-555-BILL",
   "city": "横浜市",
   "zip": "221-0054",
   "province": "Tokyo",
   "country": "Japan",
   "last_name": "山田",
   "address2": null,
   "company": "請求会社",
   "latitude": null,
   "longitude": null,
   "name": "山田太郎",
   "country_code": "JP",
   "province_code": "JP-13"
 },
 "shipping_address": {
   "first_name": "太郎",
   "address1": "出荷通り",
   "phone": "555-555-SHIP",
   "city": "横浜市",
   "zip": "221-0054",
   "province": "Tokyo",
   "country": "Japan",
   "last_name": "山田",
   "address2": null,
   "company": "運送会社",
   "latitude": null,
   "longitude": null,
   "name": "山田太郎",
   "country_code": "JP",
   "province_code": "JP-13"
 },
 "customer": {
   "id": xxxxxxxx,
   "email": "john@test.com",
   "accepts_marketing": false,
   "created_at": null,
   "updated_at": null,
   "first_name": "太郎",
   "last_name": "山田",
   "orders_count": 0,
   "state": "disabled",
   "total_spent": "0.00",
   "last_order_id": null,
   "note": null,
   "verified_email": true,
   "multipass_identifier": null,
   "tax_exempt": false,
   "phone": null,
   "tags": "",
   "last_order_name": null,
   "currency": "JPY",
   "accepts_marketing_updated_at": null,
   "marketing_opt_in_level": null,
   "admin_graphql_api_id": "gid:\/\/shopify\/Customer\/xxxxxxxx",
   "default_address": {
     "id": xxxxxxxx,
     "customer_id": xxxxxxxx,
     "first_name": null,
     "last_name": null,
     "company": null,
     "address1": "123 Elm St.",
     "address2": null,
     "city": "Ottawa",
     "province": "Ontario",
     "country": "Canada",
     "zip": "K2H7A8",
     "phone": "123-123-1234",
     "name": "",
     "province_code": "ON",
     "country_code": "CA",
     "country_name": "Canada",
     "default": true
   }
 }
}

情報を受け取る側は受け取った情報の完全性を検証する処理を行って下さい。
参考サイト:https://shopify.dev/apps/webhooks


Shopifyを利用したストアの構築・運用のご相談はお問い合わせフォームより受け付けております。

Share on

その他の記事

  • Strategy

    ECサイトとは?簡単にできる構築方法を実例をもとにご紹介

  • Shopify

    セクションに可変長カスタム入力欄を設置する

  • Shopify

    コレクション内商品のタイトルだけ表示する

トップへ戻る

お問い合わせ

Webサイト制作やWebビジネスに関するお悩みがある方はお気軽にご相談ください。

お問い合わせはこちら

会社案内

社内で検討・回覧したい方向けに、弊社の会社概要や最新の制作実績を掲載した資料を、PDFでご覧いただけます。

ホワイトペーパー

最新のプロジェクトや過去の7,000サイト以上の実績と経験で獲得したWebサイト制作におけるノウハウの一部をホワイトペーパーとして公開しています。