GitHub Marketplace購入webhookのペイロード
webhookのPOST
リクエストには、特別なヘッダがあります。 詳細については「webhookの配信ヘッダ」を参照してください。 GitHubは、失敗した配信の試行を再送信しません。 GitHubが送信したすべてのwebhookのペイロードを、アプリケーションが確実に受信できるようにしてください。
キャンセル及びダウングレードは、次の支払いサイクルの初日に有効になります。 ダウングレードとキャンセルのイベントは、次の支払いサイクルの開始時に新しいプランが有効になったときに送信されます。 新規の購入とアップグレードのイベントは、すぐに開始されます。 変更がいつ始まるかを判断するには、webhookのペイロード中のeffective_date
を使ってください。
ノート: スパムのGitHub Marketplaceでの購入や、その他の悪意ある行為に気づいた場合は、悪用報告フォームにそのユーザの詳しい情報を記入してください。
それぞれのmarketplace_purchase
webhookのペイロードは、以下の情報を持ちます。
キー | 種類 | 説明 |
---|---|---|
action | string | webhookを生成するために行われたアクション。 purchased 、cancelled 、pending_change 、pending_change_cancelled 、changed のいずれかになります。 詳しい情報については、以下のwebhookペイロードの例を参照してください。 ノート: pending_change 及びpending_change_cancelled ペイロードには、changed ペイロードの例に示されているものと同じキーが含まれます。 |
effective_date | string | action が有効になる日付。 |
sender | オブジェクト | webhookをトリガーしたaction を行った人。 |
marketplace_purchase | オブジェクト | GitHub Marketplaceの購入情報。 |
marketplace_purchase
オブジェクトは、以下のキーを持ちます。
キー | 種類 | 説明 |
---|---|---|
アカウント | オブジェクト | サブスクリプションに関連づけられたorganization もしくあはuser アカウント。 Organizationアカウントは、そのOrganizationの管理者のメールアドレスであるorganization_billing_email を含みます。 個人アカウントのメールアドレスを知るには、認証されたユーザの取得エンドポイントが利用できます。 |
billing_cycle | string | yearly もしくはmonthly のいずれかになります。 account の所有者が無料のGitHubのプランを使っており、無料のGitHub Marketplaceプランを購入した場合、billing_cycle はnil になります。 |
unit_count | integer | 購入したユーザ数。 |
on_free_trial | boolean | account が無料トライアル中の場合true になります。 |
free_trial_ends_on | string | 無料トライアルが期限切れになる日付。 |
next_billing_date | string | 次の支払いサイクルが始まる日付。 account の所有者が無料のGitHub.comのプランを使っており、無料のGitHub Marketplaceプランを購入した場合、next_billing_date はnil になります。 |
plan | オブジェクト | user またはorganization が購入したプラン。 |
plan
オブジェクトには以下のキーがあります。
キー | 種類 | 説明 |
---|---|---|
id | integer | このプランの一意の識別子。 |
name | string | プラン名。 |
説明 | string | プランの説明。 |
monthly_price_in_cents | integer | このプランのセント (米国の通貨) 単位の月額。 たとえば、月額10米ドルのリストは1000セントです。 |
yearly_price_in_cents | integer | このプランのセント (米国の通貨) 単位の年額。 たとえば、月額100米ドルのリストは120000セントです。 |
price_model | string | このリストの価格モデル。 flat-rate 、per-unit 、free のいずれかです。 |
has_free_trial | boolean | このリストが無料トライアルを提供する場合はtrue になります。 |
unit_name | string | ユニットの名前。 価格モデルがper-unit でない場合、これはnil になります。 |
bullet | array of strings | 価格プランに設定されている箇条書きの名前。 |
purchased
イベントのサンプルwebhookペイロード
次の例は、purchased
イベントのペイロードを示しています。
{
"action": "purchased",
"effective_date": "2017-10-25T00:00:00+00:00",
"sender": {
"login": "username",
"id": 3877742,
"avatar_url": "https://avatars2.githubusercontent.com/u/3877742?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/username",
"html_url": "https://github.com/username",
"followers_url": "https://api.github.com/users/username/followers",
"following_url": "https://api.github.com/users/username/following{/other_user}",
"gists_url": "https://api.github.com/users/username/gists{/gist_id}",
"starred_url": "https://api.github.com/users/username/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/username/subscriptions",
"organizations_url": "https://api.github.com/users/username/orgs",
"repos_url": "https://api.github.com/users/username/repos",
"events_url": "https://api.github.com/users/username/events{/privacy}",
"received_events_url": "https://api.github.com/users/username/received_events",
"type": "User",
"site_admin": true,
"email": "username@email.com"
},
"marketplace_purchase": {
"account": {
"type": "Organization",
"id": 18404719,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjE=",
"login": "username",
"organization_billing_email": "username@email.com"
},
"billing_cycle": "monthly",
"unit_count": 1,
"on_free_trial": false,
"free_trial_ends_on": null,
"next_billing_date": "2017-11-05T00:00:00+00:00",
"plan": {
"id": 435,
"name": "Basic Plan",
"description": "Basic Plan",
"monthly_price_in_cents": 1000,
"yearly_price_in_cents": 10000,
"price_model": "per-unit",
"has_free_trial": true,
"unit_name": "seat",
"bullets": [
"Is Basic",
"Because Basic "
]
}
}
}
changed
イベントのサンプルwebhookペイロード
プランの変更には、アップグレードとダウンロードがあります。 この例は、changed
、pending_change
、およびpending_change_cancelled
イベントのペイロードを表しています。 このアクションは、これら3つのイベントのうちどれが発生したかを示します。
{
"action": "changed",
"effective_date": "2017-10-25T00:00:00+00:00",
"sender": {
"login": "username",
"id": 3877742,
"avatar_url": "https://avatars2.githubusercontent.com/u/3877742?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/username",
"html_url": "https://github.com/username",
"followers_url": "https://api.github.com/users/username/followers",
"following_url": "https://api.github.com/users/username/following{/other_user}",
"gists_url": "https://api.github.com/users/username/gists{/gist_id}",
"starred_url": "https://api.github.com/users/username/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/username/subscriptions",
"organizations_url": "https://api.github.com/users/username/orgs",
"repos_url": "https://api.github.com/users/username/repos",
"events_url": "https://api.github.com/users/username/events{/privacy}",
"received_events_url": "https://api.github.com/users/username/received_events",
"type": "User",
"site_admin": true,
"email": "username@email.com"
},
"marketplace_purchase": {
"account": {
"type": "Organization",
"id": 18404719,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjE=",
"login": "username",
"organization_billing_email": "username@email.com"
},
"billing_cycle": "monthly",
"unit_count": 10,
"on_free_trial": false,
"free_trial_ends_on": null,
"next_billing_date": "2017-11-05T00:00:00+00:00",
"plan": {
"id": 435,
"name": "Basic Plan",
"description": "Basic Plan",
"monthly_price_in_cents": 1000,
"yearly_price_in_cents": 10000,
"price_model": "per-unit",
"has_free_trial": true,
"unit_name": "seat",
"bullets": [
"Is Basic",
"Because Basic "
]
}
},
"previous_marketplace_purchase": {
"account": {
"type": "Organization",
"id": 18404719,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjE=",
"login": "username",
"organization_billing_email": "username@email.com"
},
"billing_cycle": "monthly",
"on_free_trial": false,
"free_trial_ends_on": null,
"unit_count": 1,
"plan": {
"id": 435,
"name": "Basic Plan",
"description": "Basic Plan",
"monthly_price_in_cents": 1000,
"yearly_price_in_cents": 10000,
"price_model": "per-unit",
"has_free_trial": true,
"unit_name": "seat",
"bullets": [
"Is Basic",
"Because Basic "
]
}
}
}
cancelled
イベントのサンプルwebhookペイロード
{
"action": "cancelled",
"effective_date": "2017-10-25T00:00:00+00:00",
"sender": {
"login": "username",
"id": 3877742,
"avatar_url": "https://avatars2.githubusercontent.com/u/3877742?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/username",
"html_url": "https://github.com/username",
"followers_url": "https://api.github.com/users/username/followers",
"following_url": "https://api.github.com/users/username/following{/other_user}",
"gists_url": "https://api.github.com/users/username/gists{/gist_id}",
"starred_url": "https://api.github.com/users/username/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/username/subscriptions",
"organizations_url": "https://api.github.com/users/username/orgs",
"repos_url": "https://api.github.com/users/username/repos",
"events_url": "https://api.github.com/users/username/events{/privacy}",
"received_events_url": "https://api.github.com/users/username/received_events",
"type": "User",
"site_admin": true,
"email": "username@email.com"
},
"marketplace_purchase": {
"account": {
"type": "Organization",
"id": 28536653,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjE=",
"login": "organizationUsername",
"organization_billing_email": "organizationusername@gmail.com"
},
"billing_cycle": "monthly",
"unit_count": 0,
"on_free_trial": false,
"free_trial_ends_on": null,
"next_billing_date": "2017-11-08T00:00:00+00:00",
"plan": {
"id": 686,
"name": "Premium Plan",
"description": "Premium Plan",
"monthly_price_in_cents": 10000,
"yearly_price_in_cents": 100000,
"price_model": "flat-rate",
"has_free_trial": true,
"unit_name": null,
"bullets": [
"Is Expensive",
"And Flat Rate"
]
}
}
}