This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'csv' | |
require 'logger' | |
class OfficeMaker | |
attr_reader :input_file, :site_number, :offices, :log, :params | |
def initialize(input_file, site_number, params={}) | |
@input_file = input_file | |
@site_number = site_number | |
@params = params |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def index | |
... | |
... | |
if @site.cc_processing_fee | |
if @site.cc_processing_fee_type == "FLAT RATE" | |
@fee_string = "#{view_context.number_to_currency(@site.cc_processing_fee_amount)}" | |
else # In the above/below lines 'view_context' lets us use helper methods available in the view | |
@fee_string = "#{view_context.number_to_percentage(@site.cc_processing_fee_amount, precision: 2)}" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
... | |
private | |
def generate_processing_fee_warning(site) | |
return unless fee = site.cc_processing_fee | |
flat_rate = site.cc_processing_fee_type == "FLAT RATE" | |
return convert_fee_to_currency(fee) if flat_rate | |
convert_fee_to_percentage(site.cc_processing_fee_amount) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Clients::MakePaymentController < Clients::BaseController | |
def index | |
@site = current_customer.accounts.first.site | |
@customer = current_customer | |
@accounts = current_customer.accounts | |
@current_user = current_user | |
@fee_string = generate_processing_fee_warning(@site) | |
@account_choices = account_choices_for_dropdown | |
@card_types = ["VISA", "MASTERCARD", "AMEX"] | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app | |
├── controllers | |
│ └── clients | |
│ └── make_payment_controller.rb | |
├── models | |
│ ├── account.rb | |
│ ├── credit_card_gateway.rb | |
│ ├── credit_card_transaction.rb | |
│ ├── customer.rb | |
│ ├── payment.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "uri" | |
require "net/http" | |
require 'json' | |
class Clients::MakePaymentController < Clients::BaseController | |
def index | |
@site = current_customer.accounts.first.site | |
@customer = current_customer | |
@accounts = current_customer.accounts | |
@current_user = current_user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RSpec.describe Clients::MakePaymentController, :type => :controller do | |
... | |
... | |
it "creates a new transaction using form params" do | |
allow(CreditCardGateway) | |
.to receive(:payment_from_params) { payment } | |
allow(site).to receive(:credit_card_gateway) { gateway } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
... | |
it "creates a new transaction using form params" do | |
allow(CreditCardGateway) | |
.to receive(:payment_from_params) { payment } | |
allow(site).to receive(:credit_card_gateway) { gateway } | |
allow(payment).to receive(:store_transaction_id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rails_helper' | |
RSpec.describe "client can make credit card payment", :type => :feature do | |
let(:sign_in_page) { ClientsSignInPage.new } | |
let(:make_payment_page) { ClientsMakePaymentPage.new } | |
let(:sign_in) do | |
lambda { |email, password| | |
sign_in_page.visit_page.sign_in(email, password) | |
} | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Clients::MakePaymentController < Clients::BaseController | |
def index | |
@site = current_customer.accounts.first.site | |
@customer = current_customer | |
@accounts = current_customer.accounts | |
@current_user = current_user | |
@fee_string = generate_processing_fee_warning(@site) | |
@account_choices = account_choices_for_dropdown | |
@card_types = ["VISA", "MASTERCARD", "AMEX"] | |
end |
OlderNewer