1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-11-29 10:24:20 +01:00

fix stripe coupon creation

This commit is contained in:
Sylvain 2016-08-10 17:48:34 +02:00
parent 4be571e6d2
commit 8a68445d2e

View File

@ -17,13 +17,20 @@ class StripeWorker
def create_stripe_coupon(coupon_id)
coupon = Coupon.find(coupon_id)
Stripe::Coupon.create(
stp_coupon = {
id: coupon.code,
duration: coupon.validity_per_user,
percent_off: coupon.percent_off,
redeem_by: coupon.valid_until.to_i,
max_redemptions: coupon.max_usages,
)
}
unless coupon.valid_until.nil?
stp_coupon[:redeem_by] = coupon.valid_until.to_i
end
stp_coupon
unless coupon.max_usages.nil?
stp_coupon[max_redemptions] = coupon.max_usages
end
Stripe::Coupon.create(stp_coupon)
end
def delete_stripe_coupon(coupon_code)