Rails: 如何在使用一定量后禁用应用程序
Rails: How to disable app after certain amount of usage
我有一个 Rails/Shopify 应用程序可以处理来自用户的 Shopify 商店的订单。我想要分层计划(例如青铜 < 20 个订单,银 < 100 个订单,金 100+)。
实现它的最佳方法是什么?
1) 我如何跟踪他们使用的是哪个订阅计划,何时更改等?
2) 如何在用户达到限制后禁用该应用程序?
任何指向 articles/tutorials/gems 的链接都可以提供帮助。
我会按照以下方式进行。获得令牌后,您可以访问您所在商店的申请费用。您可以使用
GET /admin/recurring_application_charges/455696195.json
或者像我用的那样
ShopifyAPI::RecurringApplicationCharges.current
这会让您了解用户当前使用的套餐。您可以访问计划的名称等。要跟踪处理了多少订单,我会编写一个控制器并实现一个简单的计数器。每次发送请求时,计数器都会递增。达到限制后,您可以将他重定向到错误页面或其他地方。
要回答问题的第二部分,您可以如上所述访问当前费用并获取所需的所有信息(例如 "billing_on": "2015-03-27T00:00:00+00:00"
)
这是一个包含所有可用字段的示例响应:
HTTP/1.1 200 OK
{
"recurring_application_charge": {
"activated_on": null,
"api_client_id": 755357713,
"billing_on": "2015-03-27T00:00:00+00:00",
"cancelled_on": null,
"created_at": "2015-03-28T13:31:19-04:00",
"id": 455696195,
"name": "Super Mega Plan",
"price": "15.00",
"return_url": "http:\/\/yourapp.com",
"status": "pending",
"test": null,
"trial_days": 0,
"trial_ends_on": null,
"updated_at": "2015-03-28T13:31:19-04:00",
"decorated_return_url": "http:\/\/yourapp.com?charge_id=455696195",
"confirmation_url": "https:\/\/apple.myshopify.com\/admin\/charges\/455696195\/confirm_recurring_application_charge?signature=BAhpBENfKRs%3D--a911ece9470850c96f6c7735c684b8a3f6869594"
}
}
您可以在 https://docs.shopify.com/api/recurringapplicationcharge or https://docs.shopify.com/api/applicationcharge
下找到更多信息
希望我能帮上忙
我有一个 Rails/Shopify 应用程序可以处理来自用户的 Shopify 商店的订单。我想要分层计划(例如青铜 < 20 个订单,银 < 100 个订单,金 100+)。
实现它的最佳方法是什么?
1) 我如何跟踪他们使用的是哪个订阅计划,何时更改等? 2) 如何在用户达到限制后禁用该应用程序?
任何指向 articles/tutorials/gems 的链接都可以提供帮助。
我会按照以下方式进行。获得令牌后,您可以访问您所在商店的申请费用。您可以使用
GET /admin/recurring_application_charges/455696195.json
或者像我用的那样
ShopifyAPI::RecurringApplicationCharges.current
这会让您了解用户当前使用的套餐。您可以访问计划的名称等。要跟踪处理了多少订单,我会编写一个控制器并实现一个简单的计数器。每次发送请求时,计数器都会递增。达到限制后,您可以将他重定向到错误页面或其他地方。
要回答问题的第二部分,您可以如上所述访问当前费用并获取所需的所有信息(例如 "billing_on": "2015-03-27T00:00:00+00:00"
)
这是一个包含所有可用字段的示例响应:
HTTP/1.1 200 OK
{
"recurring_application_charge": {
"activated_on": null,
"api_client_id": 755357713,
"billing_on": "2015-03-27T00:00:00+00:00",
"cancelled_on": null,
"created_at": "2015-03-28T13:31:19-04:00",
"id": 455696195,
"name": "Super Mega Plan",
"price": "15.00",
"return_url": "http:\/\/yourapp.com",
"status": "pending",
"test": null,
"trial_days": 0,
"trial_ends_on": null,
"updated_at": "2015-03-28T13:31:19-04:00",
"decorated_return_url": "http:\/\/yourapp.com?charge_id=455696195",
"confirmation_url": "https:\/\/apple.myshopify.com\/admin\/charges\/455696195\/confirm_recurring_application_charge?signature=BAhpBENfKRs%3D--a911ece9470850c96f6c7735c684b8a3f6869594"
}
}
您可以在 https://docs.shopify.com/api/recurringapplicationcharge or https://docs.shopify.com/api/applicationcharge
下找到更多信息
希望我能帮上忙