mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2024-11-28 09:24:24 +01:00
(bug) unable to create Stripe coupon with duration = forever
This commit is contained in:
parent
903a84f802
commit
818b6971ec
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
- Fix a bug: unable to show wallet payment mean for invoice
|
- Fix a bug: unable to show wallet payment mean for invoice
|
||||||
- Fix a bug: PayZen amount of subscription compute error for Coupon validity per user = forever
|
- Fix a bug: PayZen amount of subscription compute error for Coupon validity per user = forever
|
||||||
|
- Fix a bug: unable to create Stripe coupon with duration = forever
|
||||||
- improvement: remove show_username_in_admin_list setting
|
- improvement: remove show_username_in_admin_list setting
|
||||||
- improvement: show invoice payment method in accounting line
|
- improvement: show invoice payment method in accounting line
|
||||||
- [TODO DEPLOY] `rails fablab:setup:build_accounting_lines`
|
- [TODO DEPLOY] `rails fablab:setup:build_accounting_lines`
|
||||||
|
@ -66,7 +66,7 @@ class Stripe::Service < Payment::Service
|
|||||||
stp_coupon[:currency] = Setting.get('stripe_currency')
|
stp_coupon[:currency] = Setting.get('stripe_currency')
|
||||||
end
|
end
|
||||||
|
|
||||||
stp_coupon[:duration] = coupon.validity_per_user == 'always' ? 'forever' : 'once'
|
stp_coupon[:duration] = coupon.validity_per_user
|
||||||
stp_coupon[:redeem_by] = coupon.valid_until.to_i unless coupon.valid_until.nil?
|
stp_coupon[:redeem_by] = coupon.valid_until.to_i unless coupon.valid_until.nil?
|
||||||
stp_coupon[:max_redemptions] = coupon.max_usages unless coupon.max_usages.nil?
|
stp_coupon[:max_redemptions] = coupon.max_usages unless coupon.max_usages.nil?
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
require 'stripe/service'
|
||||||
|
|
||||||
# Correctives for bugs or upgrades migrations tasks
|
# Correctives for bugs or upgrades migrations tasks
|
||||||
namespace :fablab do
|
namespace :fablab do
|
||||||
@ -348,5 +349,18 @@ namespace :fablab do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
desc '[release 6.3.6] fix stripe coupon duration'
|
||||||
|
task stripe_coupon_duration: :environment do |_task, _args|
|
||||||
|
if Setting.get('payment_gateway') == 'stripe'
|
||||||
|
Coupon.where(validity_per_user: 'forever').each do |c|
|
||||||
|
cpn = Stripe::Coupon.retrieve(c.code, api_key: Setting.get('stripe_secret_key'))
|
||||||
|
cpn.delete
|
||||||
|
Stripe::Service.new.create_coupon(c.id)
|
||||||
|
rescue Stripe::InvalidRequestError => e
|
||||||
|
puts "Unable to create coupon #{c.code} on stripe: #{e}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
2
test/fixtures/coupons.yml
vendored
2
test/fixtures/coupons.yml
vendored
@ -16,7 +16,7 @@ two:
|
|||||||
valid_until: <%= 1.month.from_now.utc.strftime('%Y-%m-%d %H:%M:%S.%9N %Z') %>
|
valid_until: <%= 1.month.from_now.utc.strftime('%Y-%m-%d %H:%M:%S.%9N %Z') %>
|
||||||
max_usages: 10
|
max_usages: 10
|
||||||
active: true
|
active: true
|
||||||
validity_per_user: always
|
validity_per_user: forever
|
||||||
|
|
||||||
cash:
|
cash:
|
||||||
name: Cash Code
|
name: Cash Code
|
||||||
|
@ -22,7 +22,7 @@ class CouponTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
test 'two coupons cannot have the same code' do
|
test 'two coupons cannot have the same code' do
|
||||||
c = Coupon.new({ name: 'Summer deals', code: 'SUNNYFABLAB', percent_off: 15, validity_per_user: 'always' })
|
c = Coupon.new({ name: 'Summer deals', code: 'SUNNYFABLAB', percent_off: 15, validity_per_user: 'forever' })
|
||||||
assert c.invalid?
|
assert c.invalid?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user