Skip to content

Loading…

Add Plans API #19

Merged
merged 1 commit into from

2 participants

@2sidedfigure

(closes #4)

This was needed to write the invoice API test.

@abh abh merged commit 78947c1 into stripe:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 3, 2011
  1. @2sidedfigure

    Add Plans API

    2sidedfigure committed
    (closes #4)
Showing with 22 additions and 0 deletions.
  1. +5 −0 README.md
  2. +17 −0 lib/main.js
View
5 README.md
@@ -43,6 +43,11 @@ called with an error code (if any) and then the response.
* `.list(count, offset)` - [list customers](https://stripe.com/docs/api#list_customers)
* `.update_subscription(customer_id, data)` - [update subscription](https://stripe.com/docs/api#update_subscription)
* `.cancel_subscription(customer_id, at_period_end)` - [cancel subscription](https://stripe.com/docs/api#cancel_subscription)
+* `stripe.plans` - create, retrieve, delete and list subscription plans
+ * `.create(plan)` - [create a plan](https://stripe.com/docs/api#create_plan), takes the data as an object
+ * `.retrieve(plan_id)` - [retrieve a plan](https://stripe.com/docs/api#retrieve_plan) by plan id.
+ * `.del(plan_id)` - [delete a plan](https://stripe.com/docs/api#delete_plan)
+ * `.list(count, offset)` - [list plans](https://stripe.com/docs/api#list_plans)
* `stripe.invoices` - [Invoices API](https://stripe.com/docs/api#invoices)
* `.retrieve(invoice_id)` - [retrieve an existing invoice](https://stripe.com/docs/api?lang=curl#retrieve_invoice)
* `.upcoming(customer_id)` - [retrieve the upcoming invoice for a customer](https://stripe.com/docs/api?lang=curl#retrieve_customer_invoice)
View
17 lib/main.js
@@ -144,6 +144,23 @@ module.exports = function (api_key, options) {
del("/v1/customers/" + customer_id + '/subscription', { at_period_end: at_period_end }, cb);
}
},
+ plans: {
+ create: function (data, cb) {
+ post("/v1/plans", data, cb);
+ },
+ retrieve: function(plan_id, cb) {
+ if (!(plan_id && typeof plan_id === 'string')) {
+ cb("plan_id required");
+ }
+ get("/v1/plans/" + plan_id, {}, cb);
+ },
+ del: function(plan_id, cb) {
+ del("/v1/plans/" + plan_id, {}, cb);
+ },
+ list: function(count, offset, cb) {
+ get("/v1/plans", { count: count, offset: offset}, cb );
+ }
+ },
invoices: {
retrieve: function(invoice_id, cb) {
get("/v1/invoices/" + invoice_id, {}, cb);
Something went wrong with that request. Please try again.