Skip to content

Commit

Permalink
Add Coupons API
Browse files Browse the repository at this point in the history
  • Loading branch information
2sidedfigure committed Dec 19, 2011
1 parent 000d959 commit af2ceac
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ called with an error code (if any) and then the response.
* `.update(invoice_item_id, updates)` - [update a invoice item](https://stripe.com/docs/api#update_invoiceitem); `updates` is an object with new parameters
* `.del(invoice_item_id)` - [delete a invoice item](https://stripe.com/docs/api#delete_invoiceitem)
* `.list(customer_id, count, offset)` - [list invoice items](https://stripe.com/docs/api#list_invoiceitems); all parameters are optional
* `stripe.coupons` - create, retrieve, delete and list coupons
* `.create(coupon)` - [create a coupon](https://stripe.com/docs/api#create_coupon), takes the data as an object
* `.retrieve(coupon_id)` - [retrieve a coupon](https://stripe.com/docs/api#retrieve_coupon) by coupon id.
* `.del(coupon_id)` - [delete a coupon](https://stripe.com/docs/api#delete_coupon)
* `.list(count, offset)` - [list coupons](https://stripe.com/docs/api#list_coupons)
* `stripe.token` - [Tokens API](https://stripe.com/docs/api#tokens)
* `.create(card_data)` - [create a token](https://stripe.com/docs/api#create_token)
* `.retrieve(token_id)` - [retrieve a card token](https://stripe.com/docs/api#retrieve_token)
Expand Down
17 changes: 17 additions & 0 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,23 @@ module.exports = function (api_key, options) {
get("/v1/invoiceitems", { customer: customer_id, count: count, offset: offset}, cb );
}
},
coupons: {
create: function (data, cb) {
post("/v1/coupons", data, cb);
},
retrieve: function(coupon_id, cb) {
if (!(coupon_id && typeof coupon_id === 'string')) {
cb("coupon_id required");
}
get("/v1/coupons/" + coupon_id, {}, cb);
},
del: function(coupon_id, cb) {
del("/v1/coupons/" + coupon_id, {}, cb);
},
list: function(count, offset, cb) {
get("/v1/coupons", { count: count, offset: offset}, cb );
}
},
token: {
create: function (data, cb) {
post("/v1/tokens", data, cb)
Expand Down

0 comments on commit af2ceac

Please sign in to comment.