Skip to content

关于 订阅收费

访问范围

需要多个访问范围—请参阅每个端点以了解访问范围要求。

需要访问受保护的客户数据。

该账单 API 提供了一组 RESTful 接口,用于管理应用程序账单信息,包括创建、取消、读取账单和上报使用费。该 API 旨在为Genstore平台上的商家订阅应用程序并使用应用程序等服务。

功能

  1. 创建定期应用程序费用:允许商户定期创建应用程序订阅费用。
  2. 取消定期应用费用:允许商户取消应用程序订阅费用。
  3. 检索单笔费用:允许商户根据订阅费用ID查询费用信息。
  4. 创建使用量费用:允许商户按照使用量创建费用。

调用注意事项

在使用账单 API 时,请注意:

  1. 数据一致性:在创建使用量费用时,如果要避免重复创建,请保证每次请求的 extUniqueId 不一致。

使用场景

以下是账单 API 在实际应用中的几个场景,帮助开发者理解其具体的使用价值:

  • 创建定期应用程序费用:商家可以通过 API 为应用创建定期计费方案,支持按时间、按使用量以及时间与使用量结合的混合计费方式。
  • 取消定期应用费用:商家可以通过 API 接口取消店铺当前的定期订阅费用。
  • 检索单笔费用:商家可以通过 API 检索单个订阅信息,以便了解改订阅产生的完整信息。
  • 创建使用量费用:商户订阅了按使用量计费的应用后,可以通过 API 上报使用量,以生成相应的使用费用。

订阅收费 对象

应用订阅收费对象。

属性

recurringApplicationChargeobject
订阅实体类。
- 收起属性
idnumber
定期收费的 ID。
namestring
定期收费的名字。
pricestring
定期收费的价格。
billingTimestring
向客户收费的日期和时间。
statusstring
定期收款的状态。枚举值:
* pending - 待处理;
* active - 活跃;
* declined - 拒绝;
* expired - 已过期;
* frozen - 冻结;
* cancelled - 已取消;
createTimestring
创建定期应用程序费用的日期和时间。
updateTimestring
上次更新定期应用程序费用的日期和时间。
activatedTimestring
客户激活定期应用程序费用的日期和时间。
returnUrlstring
商家在接受收款后被重定向的 URL。
testboolean
应用程序费用是否为测试交易。
cancelledTimestring
商家取消其定期申请费用的日期和时间。
trialDaysnumber
客户有资格免费试用的天数。
trialEndsTimestring
免费试用结束的日期和时间。
confirmationUrlstring
商家接受或拒绝定期应用程序费用的 URL。
currencystring
定期应用程序费用价格的货币。
bash
{
  "recurringApplicationCharge": {
    "trialEndsTime": "2025-04-01T15:46:46-04:00",
    "trialDays": "5",
    "test": "false",
    "confirmationUrl": "https://jsmith.blaze.com/admin/charges/755357713/1029266966/RecurringApplicationCharge/confirm_recurring_application_charge?signature=BAh7BzoHaWRpBBZeWT06EmF1dG9fYWN0aXZhdGVU--98ef575ea1fff24621e47eaa65e42758f13a3ae5",
    "billingTime": "2025-04-01T15:46:46-04:00",
    "updateTime": "2025-04-01T15:46:46-04:00",
    "createTime": "2025-04-01T15:46:46-04:00",
    "activatedTime": "2025-04-01T15:46:46-04:00",
    "price": "20.0",
    "cancelledTime": "2025-04-01T15:46:46-04:00",
    "name": "Super Duper Plan",
    "currency": "USD",
    "id": "1029266966",
    "returnUrl": "http://super-duper.blaze.com/",
    "status": "pending"
  }
}

POST 创建定期应用程序费用

为应用创建定期计费方案,支持按时间、按使用量以及时间与使用量结合的混合计费方式。

访问范围

需要以下任意访问权限: write_billing

接口

POST /api/202412/recurring_application_charges 

请求参数

recurringApplicationChargeobject
订阅实体类。
- 收起属性
cappedAmountstring
客户可以按使用量计费的限制
termsstring
条款
pricestring
价格
namestring
名字
returnUrlstring
商家在接受收款后被重定向的 URL。
trialDaysnumber
客户有资格免费试用的天数。

响应数据

recurringApplicationChargeobject
订阅实体类。
- 收起属性
idnumber
定期收费的 ID。
namestring
定期收费的名字。
pricestring
定期收费的价格。
billingTimestring
向客户收费的日期和时间。
statusstring
定期收款的状态。枚举值:
* pending - 待处理;
* active - 活跃;
* declined - 拒绝;
* expired - 已过期;
* frozen - 冻结;
* cancelled - 已取消;
createTimestring
创建定期应用程序费用的日期和时间。
updateTimestring
上次更新定期应用程序费用的日期和时间。
activatedTimestring
客户激活定期应用程序费用的日期和时间。
returnUrlstring
商家在接受收款后被重定向的 URL。
testboolean
应用程序费用是否为测试交易。
cancelledTimestring
商家取消其定期申请费用的日期和时间。
trialDaysnumber
客户有资格免费试用的天数。
trialEndsTimestring
免费试用结束的日期和时间。
confirmationUrlstring
商家接受或拒绝定期应用程序费用的 URL。
currencystring
定期应用程序费用价格的货币。
bash
curl -X POST \ 
https://{shop}.genmystore.com/api/202412/recurring_application_charges" \ 
-H "X-Genstore-Access-Token: {access_token}" \ 
-H "Content-Type: application/json" \ 
-d '{
	"recurringApplicationCharge":{
		"trialDays":"7",
		"cappedAmount":"100",
		"terms":"$1 for 1000 emails",
		"price":"100.00",
		"name":"Super Duper Expensive action",
		"returnUrl":"http://super-duper.blaze.com"
	}
}'
json
HTTP/1.1 200 OK
{
  "recurringApplicationCharge": {
    "trialEndsTime": "2025-04-01T15:46:46-04:00",
    "trialDays": "5",
    "test": "false",
    "confirmationUrl": "https://jsmith.blaze.com/admin/charges/755357713/1029266966/RecurringApplicationCharge/confirm_recurring_application_charge?signature=BAh7BzoHaWRpBBZeWT06EmF1dG9fYWN0aXZhdGVU--98ef575ea1fff24621e47eaa65e42758f13a3ae5",
    "billingTime": "2025-04-01T15:46:46-04:00",
    "updateTime": "2025-04-01T15:46:46-04:00",
    "createTime": "2025-04-01T15:46:46-04:00",
    "activatedTime": "2025-04-01T15:46:46-04:00",
    "price": "20.0",
    "cancelledTime": "2025-04-01T15:46:46-04:00",
    "name": "Super Duper Plan",
    "currency": "USD",
    "id": "1029266966",
    "returnUrl": "http://super-duper.blaze.com/",
    "status": "pending"
  }
}

DELETE 取消定期应用费用

取消店铺当前的定期订阅费用。

访问范围

需要以下任意访问权限: write_billing

接口

DELETE /api/202412/recurring_application_charges/{chargeId} 

请求参数

{}

响应数据

{}
bash
curl -X DELETE \ 
https://{shop}.genmystore.com/api/202412/recurring_application_charges/{chargeId}" \ 
-H "X-Genstore-Access-Token: {access_token}" \
json
HTTP/1.1 200 OK
{}

GET 检索单笔费用

根据费用 ID 检索单笔费用的详细信息。

访问范围

需要以下任意访问权限: write_billing read_billing

接口

GET /api/202412/recurring_application_charges/{chargeId} 

请求参数

{}

响应数据

recurringApplicationChargeobject
订阅实体类。
- 收起属性
idnumber
定期收费的 ID。
namestring
定期收费的名字。
pricestring
定期收费的价格。
billingTimestring
向客户收费的日期和时间。
statusstring
定期收款的状态。枚举值:
* pending - 待处理;
* active - 活跃;
* declined - 拒绝;
* expired - 已过期;
* frozen - 冻结;
* cancelled - 已取消;
createTimestring
创建定期应用程序费用的日期和时间。
updateTimestring
上次更新定期应用程序费用的日期和时间。
activatedTimestring
客户激活定期应用程序费用的日期和时间。
returnUrlstring
商家在接受收款后被重定向的 URL。
testboolean
应用程序费用是否为测试交易。
cancelledTimestring
商家取消其定期申请费用的日期和时间。
trialDaysnumber
客户有资格免费试用的天数。
trialEndsTimestring
免费试用结束的日期和时间。
confirmationUrlstring
商家接受或拒绝定期应用程序费用的 URL。
currencystring
定期应用程序费用价格的货币。
bash
curl -X GET \ 
https://{shop}.genmystore.com/api/202412/recurring_application_charges/{chargeId}" \ 
-H "X-Genstore-Access-Token: {access_token}" \
json
HTTP/1.1 200 OK
{
  "recurringApplicationCharge": {
    "trialEndsTime": "2025-04-01T15:46:46-04:00",
    "trialDays": "5",
    "test": "false",
    "confirmationUrl": "https://jsmith.blaze.com/admin/charges/755357713/1029266966/RecurringApplicationCharge/confirm_recurring_application_charge?signature=BAh7BzoHaWRpBBZeWT06EmF1dG9fYWN0aXZhdGVU--98ef575ea1fff24621e47eaa65e42758f13a3ae5",
    "billingTime": "2025-04-01T15:46:46-04:00",
    "updateTime": "2025-04-01T15:46:46-04:00",
    "createTime": "2025-04-01T15:46:46-04:00",
    "activatedTime": "2025-04-01T15:46:46-04:00",
    "price": "20.0",
    "cancelledTime": "2025-04-01T15:46:46-04:00",
    "name": "Super Duper Plan",
    "currency": "USD",
    "id": "1029266966",
    "returnUrl": "http://super-duper.blaze.com/",
    "status": "pending"
  }
}