forked from stripe-ruby-mock/stripe-ruby-mock
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlive.rb
40 lines (34 loc) · 1014 Bytes
/
live.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
module StripeMock
module TestStrategies
class Live < Base
def create_plan(params={})
raise "create_plan requires an :id" if params[:id].nil?
delete_plan(params[:id])
Stripe::Plan.create create_plan_params(params)
end
def delete_plan(plan_id)
begin
plan = Stripe::Plan.retrieve(plan_id)
plan.delete
rescue Stripe::StripeError => e
# Do nothing; we just want to make sure this plan ceases to exists
end
end
def create_coupon(params={})
delete_coupon create_coupon_params(params)[:id]
super
end
def delete_coupon(id)
begin
coupon = Stripe::Coupon.retrieve(id)
coupon.delete
rescue Stripe::StripeError
# do nothing
end
end
def upsert_stripe_object(object, attributes)
raise UnsupportedRequestError.new "Updating or inserting Stripe objects in Live mode not supported"
end
end
end
end