GitHub Marketplace 购买 web 挂钩有效负载
Web 挂钩 POST
请求具有特殊标头。 有关详细信息,请参阅“web 挂钩递送标头”。 GitHub 不会重新发送失败的递送尝试。 确保您的应用程序可以接收 GitHub 发送的所有 web 挂钩有效负载。
取消和降级在下一个结算周期的第一天生效。 如果新计划在下一个结算周期开始时生效,则将发送降级和取消事件。 新的购买和升级事件会立即生效。 使用 web 挂钩有效负载中的 effective_date
可确定更改何时开始生效。
注:如果您发现任何恶意 GitHub Marketplace 购买或其他恶意行为,请填写报告滥用表单,并提供有关用户的更多信息。
每个 marketplace_purchase
web 挂钩有效负载都含有以下信息:
键 | 类型 | 描述 |
---|---|---|
action | 字符串 | 为生成 web 挂钩而执行的操作。 可以是 purchased 、cancelled 、pending_change 、pending_change_cancelled 或 changed 。 更多信息请参阅下面的 web 挂钩有效负载示例。 注:pending_change 和 pending_change_cancelled 有效负载包含与 changed 有效负载示例中所示键相同的键。 |
effective_date | 字符串 | action 开始生效的日期。 |
sender | 对象 | 执行 action 触发 web 挂钩的人。 |
marketplace_purchase | 对象 | GitHub Marketplace 购买信息。 |
marketplace_purchase
对象含有以下键:
键 | 类型 | 描述 |
---|---|---|
帐户 | 对象 | 与订阅关联的 organization 或 user 帐户。 组织帐户将包含 Organization_billing_email , 这是组织的行政电子邮件地址。 要查找个人帐户的电子邮件地址,您可以使用获取经过身份验证的用户端点。 |
billing_cycle | 字符串 | 可以是 yearly 或 monthly 。 如果 account 所有者拥有免费 GitHub 计划并且购买了免费 GitHub Marketplace 计划,则 billing_cycle 将为 nil 。 |
unit_count | 整数 | 购买的单位数。 |
on_free_trial | 布尔值 | 当 account 处于免费试用期时,该值为 true 。 |
free_trial_ends_on | 字符串 | 免费试用到期日期。 |
next_billing_date | 字符串 | 下一个结算周期开始日期。 如果 account 所有者拥有免费 GitHub.com 计划并且购买了免费 GitHub Marketplace 计划,则 next_billing_date 将为 nil 。 |
plan | 对象 | user 或 organization 购买的计划。 |
plan
对象含有以下键:
键 | 类型 | 描述 |
---|---|---|
id | 整数 | 此计划的唯一标识符。 |
name | 字符串 | 计划的名称。 |
说明 | 字符串 | 此计划的说明。 |
monthly_price_in_cents | 整数 | 此计划的每月价格(以美分为单位)。 例如,每月费用 10 美元的商品将显示价格 1000 美分。 |
yearly_price_in_cents | 整数 | 此计划的每年价格(以美分为单位)。 例如,每月费用 100 美元的商品将显示价格 120000 美分。 |
price_model | 字符串 | 此商品的定价模型。 可以是 flat-rate 、per-unit 或 free 之一。 |
has_free_trial | 布尔值 | 当此商品提供免费试用时,该值为 true 。 |
unit_name | 字符串 | 单位的名称。 如果定价模型不是 per-unit ,则该值为 nil 。 |
bullet | 字符串数组 | 定价计划中设置的项目符号的名称。 |
purchased
事件的 web 挂钩有效负载示例
此示例提供 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
事件的 web 挂钩有效负载示例
计划中的更改包括升级和降级。 此示例表示 changed
、pending_change
和 pending_change_cancelled
事件有效负载。 该操作标识这三个事件中发生了哪一个。
{
"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
事件的 web 挂钩有效负载示例
{
"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"
]
}
}
}