Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #21 from 2sidedfigure/master

Add Coupons API
  • Loading branch information...
commit 1fe0b3a695df5ab746f388ef60a6bf9c8f88cc42 2 parents 000d959 + af2ceac
@abh abh authored
Showing with 22 additions and 0 deletions.
  1. +5 −0 README.md
  2. +17 −0 lib/main.js
View
5 README.md
@@ -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)
View
17 lib/main.js
@@ -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)
Please sign in to comment.
Something went wrong with that request. Please try again.