mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-08-10 00:01:09 -04:00
Coupon support.
This commit is contained in:
parent
96a3233620
commit
94d8bdf681
@ -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
|
||||
|
@ -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")
|
||||
{
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user