forked from stripe-ruby-mock/stripe-ruby-mock
-
Notifications
You must be signed in to change notification settings - Fork 1
/
live.rb
51 lines (43 loc) · 1.37 KB
/
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
41
42
43
44
45
46
47
48
49
50
51
module StripeMock
module TestStrategies
class Live < Base
def create_product(params={})
params = create_product_params(params)
raise "create_product requires an :id" if params[:id].nil?
delete_product(params[:id])
Stripe::Product.create params
end
def delete_product(product_id)
product = Stripe::Product.retrieve(product_id)
Stripe::Plan.list(product: product_id).each(&:delete) if product.type == 'service'
product.delete
rescue Stripe::StripeError => e
# do nothing
end
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)
plan = Stripe::Plan.retrieve(plan_id)
plan.delete
rescue Stripe::StripeError => e
# do nothing
end
def create_coupon(params={})
delete_coupon create_coupon_params(params)[:id]
super
end
def delete_coupon(id)
coupon = Stripe::Coupon.retrieve(id)
coupon.delete
rescue Stripe::StripeError
# do nothing
end
def upsert_stripe_object(object, attributes)
raise UnsupportedRequestError.new "Updating or inserting Stripe objects in Live mode not supported"
end
end
end
end