diff --git a/app/controllers/card_controller.rb b/app/controllers/card_controller.rb deleted file mode 100644 index 1e2b6730d4f..00000000000 --- a/app/controllers/card_controller.rb +++ /dev/null @@ -1,71 +0,0 @@ -# frozen_string_literal: true - -class CardController < ApplicationController - before_action :require_login - before_action :require_card, only: :show - before_action :require_subscription, only: :show - - def show - @card = current_user.card - end - - def new; end - - # rubocop:disable Metrics/MethodLength - def create - begin - token = params[:idempotency_token] - customer = Card.new.create(current_user, params[:stripeToken], token) - Subscription.new.create(customer['id'], "#{token}-subscription") - current_user.customer_id = customer['id'] - current_user.save(validate: false) - - flash[:notice] = 'カードを登録しました。' - logger.info '[Payment] カードを登録しました。' - rescue Stripe::CardError => e - current_user.customer_id = nil - current_user.save(validate: false) - flash[:alert] = "カード情報に不備があります。:#{e.message}" - logger.warn "[Payment] カード情報に不備があります。:#{e.message}" - rescue StandardError => e - current_user.customer_id = nil - current_user.save(validate: false) - flash[:alert] = "カード登録に失敗しました。運営会社までお問い合わせください。:#{e.message}" - logger.warn "[Payment] カード登録に失敗しました。運営会社までお問い合わせください。:#{e.message}" - end - - if flash[:alert] - redirect_to new_card_url - else - redirect_to card_url - end - end - # rubocop:enable Metrics/MethodLength - - def edit; end - - def update - begin - Card.new.update(current_user.customer_id, params[:stripeToken]) - - flash[:notice] = 'カードを編集しました。' - logger.info '[Payment] カードを編集しました。' - rescue Stripe::CardError => e - current_user.customer_id = nil - current_user.save(validate: false) - flash[:alert] = "カード情報に不備があります。:#{e.message}" - logger.warn "[Payment] カード情報に不備があります。:#{e.message}" - rescue StandardError => e - current_user.customer_id = nil - current_user.save(validate: false) - flash[:alert] = "カード編集に失敗しました。運営会社までお問い合わせください。:#{e.message}" - logger.warn "[Payment] カード編集に失敗しました。運営会社までお問い合わせください。:#{e.message}" - end - - if flash[:alert] - redirect_to edit_card_url - else - redirect_to card_url - end - end -end diff --git a/app/views/card/_notice.html.slim b/app/views/application/_card_notice.html.slim similarity index 100% rename from app/views/card/_notice.html.slim rename to app/views/application/_card_notice.html.slim diff --git a/app/views/application/_user_menu.html.slim b/app/views/application/_user_menu.html.slim index 48ee21b58e5..8961c636015 100644 --- a/app/views/application/_user_menu.html.slim +++ b/app/views/application/_user_menu.html.slim @@ -6,17 +6,9 @@ li.header-dropdown__item = link_to edit_current_user_path, class: 'header-dropdown__item-link' do | 登録情報変更 - - if !current_user.adviser? && !current_user.mentor? && !current_user.trainee? - - if current_user.card? + - if current_user.card? li.header-dropdown__item = link_to 'お支払い情報', billing_portal_path, method: :post, class: 'header-dropdown__item-link' - li.header-dropdown__item - = link_to 'クレジットカード情報', card_path, class: 'header-dropdown__item-link' - li.header-dropdown__item - = link_to 'クレジットカード変更', edit_card_path, class: 'header-dropdown__item-link' - - else - li.header-dropdown__item - = link_to 'クレジットカード登録', new_card_path, class: 'header-dropdown__item-link' li.header-dropdown__item = link_to logout_path, class: 'header-dropdown__item-link' do | ログアウト diff --git a/app/views/card/_form.html.slim b/app/views/card/_form.html.slim deleted file mode 100644 index 8e6c50d7eba..00000000000 --- a/app/views/card/_form.html.slim +++ /dev/null @@ -1,18 +0,0 @@ -- method = action == :new ? 'post' : 'put' -= javascript_include_tag 'https://js.stripe.com/v3/' -= form_with url: card_path, method: method, local: true, id: 'payment-form' do |_| - = hidden_field_tag :idempotency_token, SecureRandom.uuid - .form__items - .form-item - label.a-form-label(for='card-element') カード番号 - #card-element.a-text-input - .a-form-help - p - | 対応ブランド:Visa、Master、JCB、Diners、Amex - br - | プリペイドのクレジットカードは登録できない場合があります。 - #card-errors(role='alert') - .form-actions - ul.form-actions__items - li.form-actions__item.is-main - = submit_tag 'カードを登録', class: 'a-button is-lg is-warning is-block' diff --git a/app/views/card/edit.html.slim b/app/views/card/edit.html.slim deleted file mode 100644 index 317a6b966c6..00000000000 --- a/app/views/card/edit.html.slim +++ /dev/null @@ -1,16 +0,0 @@ -- title 'クレジットカード変更' - -header.page-header - .container - .page-header__inner - h2.page-header__title - = title - -.page-body - .auth-form.is-sign-up.a-card.is-in-app - header.auth-form__header - h1.auth-form__title - | クレジットカード変更 - .auth-form__body - = render 'form', action: :edit - = render 'notice' diff --git a/app/views/card/new.html.slim b/app/views/card/new.html.slim deleted file mode 100644 index 7776560a236..00000000000 --- a/app/views/card/new.html.slim +++ /dev/null @@ -1,17 +0,0 @@ -- if current_user.card? - - title 'クレジットカード変更' -- else - - title 'クレジットカード登録' - -header.page-header - .container - .page-header__inner - h2.page-header__title = title - -.auth-form.is-sign-up.is-in-app - .a-card - header.auth-form__header - h1.auth-form__title = title - .auth-form__body - = render 'form', action: :new -= render 'notice' diff --git a/app/views/card/show.html.slim b/app/views/card/show.html.slim deleted file mode 100644 index dcc43e32305..00000000000 --- a/app/views/card/show.html.slim +++ /dev/null @@ -1,28 +0,0 @@ -- title '登録済クレジットカード' - -header.page-header - .container - .page-header__inner - h2.page-header__title = title - -.auth-form.is-sign-up.a-card.is-in-app - .a-card - header.auth-form__header - h1.auth-form__title - | 登録済クレジットカード - .auth-form__body - .form__items - .form-item - .a-text-input.is-inputed.is-align-center - | #{@card['brand']} **** **** **** #{@card['last4']} #{format('%02d', @card['exp_month'].to_i)}/#{@card['exp_year']} - .form-actions - ul.form-actions__items - li.form-actions__item.is-main - = link_to 'カード変更', edit_card_path, class: 'a-button is-lg is-warning is-block' - .auth-form__footer - .next-settlement-time - h2.next-settlement-time__title - | 次回決済日時 - .next-settlement-time__time - = l Time.zone.at(current_user.subscription['current_period_end']) -= render 'notice' diff --git a/app/views/users/form/_card.html.slim b/app/views/users/form/_card.html.slim index 4580ae83ac6..0ad0442450f 100644 --- a/app/views/users/form/_card.html.slim +++ b/app/views/users/form/_card.html.slim @@ -8,4 +8,4 @@ br | プリペイドのクレジットカードは登録できない場合があります。 #card-errors(role='alert') - = render '/card/notice' + = render 'card_notice' diff --git a/config/routes.rb b/config/routes.rb index 6831ceee8fc..6a3fb569f66 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -24,7 +24,6 @@ draw :reports resources :announcements resource :retirement, only: %i(show new create), controller: "retirement" - resource :card, only: %i(show new create edit update), controller: "card" resource :current_user, only: %i(edit update), controller: "current_user" do resource :password, only: %i(edit update), controller: "current_user/password" end