Coupon support.

This commit is contained in:
Sheena Pakanati 2011-10-11 22:06:51 -07:00
parent 96a3233620
commit 94d8bdf681
3 changed files with 25 additions and 1 deletions

View File

@ -50,7 +50,8 @@ module Stripe
'customer' => Customer,
'invoiceitem' => InvoiceItem,
'invoice' => Invoice,
'plan' => Plan
'plan' => Plan,
'coupon' => Coupon
}
case resp
when Array
@ -424,6 +425,12 @@ module Stripe
include Stripe::APIOperations::List
end
class Coupon < APIResource
include Stripe::APIOperations::Create
include Stripe::APIOperations::Delete
include Stripe::APIOperations::List
end
class Token < APIResource
include Stripe::APIOperations::Create
end

View File

@ -99,6 +99,16 @@ def test_card(params={})
}.merge(params)
end
def test_coupon(params={})
{
:duration => 'repeating',
:duration_in_months => 3,
:percent_off => 25,
:id => "co_test_coupon",
:object => "coupon"
}.merge(params)
end
#FIXME nested overrides would be better than hardcoding plan_id
def test_subscription(plan_id="gold")
{

View File

@ -318,6 +318,13 @@ class TestStripeRuby < Test::Unit::TestCase
context "card tests" do
end
context "coupon tests" do
should "create should return a new coupon" do
@mock.expects(:post).once.returns(test_response(test_coupon))
c = Stripe::Coupon.create
assert_equal "co_test_coupon", c.id
end
end
context "error checking" do
should "404s should raise an InvalidRequestError" do