There is a very basic payment processor defined in payment_processor.rb
that reads the contents of payments.csv
and processes each payment.
Imagine, in this very early state of a payment processor that a CSV is generated by customer-facing coworkers and the product manager is tasked with running this ruby script from the command line (ruby payment_processor.rb
).
Currently the only output is the number of payments that have been processed.
The product manager needs more information about the payments that have been processed. We need to generate a report containing:
- The total number of payments processed
- The total dollar amount of payments processed
- The total dollar amounts of payments categorized by card type
Additionally, to protect us from double charging clients we need to update the
payment processor to read payments from an inputs.csv
file (with the same
contents as the legacy CSV in this repository) and upon completion of processing
all of the payments, rename the file, prefixed with a
user-readable timestamp, to help the product manager find previous payment
process runs.
Lastly, the engineer who originally wrote the processor left some failing specs before they were moved onto another project indefinitely. We've reviewed the assertions that those specs make for accuracy and have determined that they also need to be made to pass.
You are welcome to update the existing classes as you see fit. As long as the input file structure stays consistent and the output contains the stated requirements you are free to tweak the internals to fit the design that you best see fit for this growing script.
- Ensure that the correct version of ruby (see .ruby-version) is installed (feel free to use
rbenv, rvm or
any other Ruby version manager)
- Ensure that bundler (>= 2.0) is installed for that Ruby version (
gem install bundler
)
- Ensure that bundler (>= 2.0) is installed for that Ruby version (
- Install the bundled gems (
bundle install
) - You can run the test suite via
bundle exec rspec
- You can run the script via
ruby payment_processor.rb
- Credit Cards should always be exactly 16 digits except for American Express (which is 15)
- Expired cards will not be charged
- Mastercard, Visa and AmEx are the only support card types today
- Completeness
- Interface design/object-oriented design
- Test coverage (there should 0 pending/skipped specs)
- Thoughtful commits
When you are satisfied with your final project to BananaCrystal please create a .zip file with all of the contents of your project (including dotfiles - we need the git history) and submit that file to your BananaCrystal contact. They will be sure to follow up with you on the next steps.
Thank you so much for your time. We recognize that code challenges are time consuming and we really appreciate that you've decided that BananaCrystal is worth that effort.