Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Checkout.com] Implementation of all functions with test cases #167

Open
wants to merge 24 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
f397f42
Introduces `Response.t` with docs (#119)
oyeb Feb 6, 2018
57c0dbb
Removes payment worker.
oyeb Feb 5, 2018
91e4506
Removed offending (now useless) test case
oyeb Feb 5, 2018
ee9140d
Removed GenServer import. Fixes #8.
oyeb Feb 15, 2018
4799023
Refactored ResponseHandler, for new Response.t
oyeb Feb 9, 2018
470d2fe
Refactored `commit` and corrected avs, cvc result
oyeb Feb 9, 2018
3040499
Correct a few doc examples
oyeb Feb 9, 2018
256072f
Adds changelog, contributing guide and improves mix task (#117)
oyeb Mar 15, 2018
c1847ac
[monei] Test fixes (#116)
oyeb Mar 15, 2018
9df91f3
Fix gringotts.new Option.parse call. (#125)
oyeb Mar 19, 2018
10f5058
Adapts Stripe with the money protocol
oyeb Jan 29, 2018
152e900
Adapted Trexle for new `Response.t`
oyeb Feb 9, 2018
6285c75
[CAMS] Adapt for new Response.t (#120)
oyeb Mar 21, 2018
494a5a3
Format project and migrate to CodeCov (#135)
oyeb Mar 22, 2018
c28bd85
[global-collect] Layout, docs improvements and code refactors (#111)
jyotigautam Mar 30, 2018
b1b7891
Changes for release 1.1.0
ashish173 Apr 22, 2018
59fbac5
Update CHANGELOG.md
ashish173 Apr 22, 2018
f785076
[Paymill] refactor and tests (#152)
anantanant2015 Apr 23, 2018
21c5517
Add clause to catch/handle bad config format (#151)
oyeb Apr 25, 2018
ce714be
Implementation of all functions and its test cases
ravirocx Apr 30, 2018
5714928
Revert "Implementation of all functions and its test cases"
ravirocx Apr 30, 2018
da252f6
implemented all functions with test cases
ravirocx Apr 30, 2018
fca1c67
Added docs
ravirocx May 2, 2018
6ff6f73
improved code readability
ravirocx May 2, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .credo.exs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@

{Credo.Check.Readability.FunctionNames},
{Credo.Check.Readability.LargeNumbers},
{Credo.Check.Readability.MaxLineLength, priority: :low, max_length: 80},
{Credo.Check.Readability.MaxLineLength, priority: :low, max_length: 100},
{Credo.Check.Readability.ModuleAttributeNames},
{Credo.Check.Readability.ModuleDoc},
{Credo.Check.Readability.ModuleNames},
Expand Down
7 changes: 7 additions & 0 deletions .formatter.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[
inputs: [
"{lib,config}/**/*.{ex,exs}", # lib and config
"test/**/*.{ex,exs}", # tests
"mix.exs"
]
]
20 changes: 20 additions & 0 deletions .scripts/inch_report.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

set -e
bold=$(tput bold)
purple='\e[106m'
normal=$(tput sgr0)
allowed_branches="^(master)|(develop)$"

echo -e "${bold}${purple}"
if [ $TRAVIS_PULL_REQUEST = false ]; then
if [[ $TRAVIS_BRANCH =~ $allowed_branches ]]; then
env MIX_ENV=docs mix deps.get
env MIX_ENV=docs mix inch.report
else
echo "Skipping Inch CI report because this branch does not match on /$allowed_branches/"
fi
else
echo "Skipping Inch CI report because this is a PR build"
fi
echo -e "${normal}"
12 changes: 12 additions & 0 deletions .scripts/post-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh
#
# Runs credo and the formatter on the staged files, after the commit is made
# This is purely for notification and will not halt/change your commit.

RED='\033[1;31m'
LGRAY='\033[1;30m'
NC='\033[0m' # No Color

printf "${RED}Running 'mix credo --strict --format=oneline' on project...${NC}\n"
mix credo --strict --format=oneline
echo
50 changes: 50 additions & 0 deletions .scripts/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-commit".

if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi

# If you want to allow non-ASCII filenames set this variable to true.
allownonascii=$(git config --bool hooks.allownonascii)

# Redirect output to stderr.
exec 1>&2

# Cross platform projects tend to avoid non-ASCII filenames; prevent
# them from being added to the repository. We exploit the fact that the
# printable range starts at the space character and ends with tilde.
if [ "$allownonascii" != "true" ] &&
# Note that the use of brackets around a tr range is ok here, (it's
# even required, for portability to Solaris 10's /usr/bin/tr), since
# the square bracket bytes happen to fall in the designated range.
test $(git diff --cached --name-only --diff-filter=A -z $against |
LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0
then
cat <<\EOF
Error: Attempt to add a non-ASCII file name.

This can cause problems if you want to work with people on other platforms.

To be portable it is advisable to rename the file.

If you know what you are doing you can disable this check using:

git config hooks.allownonascii true
EOF
exit 1
fi

# Also run the mix format task, just check though.
exec mix format --check-formatted

27 changes: 21 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,29 @@
language: elixir
elixir:
- 1.5.2

otp_release:
- 20.1
- 20.2
before_install:
- mix local.hex --force
- mix local.rebar --force
- mix deps.get
script:
- mix coveralls.travis --include integration
- set -e
- MIX_ENV=test mix format --check-formatted
- set +e
- mix coveralls.json
after_script:
- MIX_ENV=docs mix deps.get
- MIX_ENV=docs mix inch.report
- bash <(curl -s https://codecov.io/bash)
- bash .scripts/inch_report.sh

matrix:
include:
- elixir: "1.5.3"
script:
- mix coveralls.json
- elixir: "1.6.2"

notifications:
email:
recipients:
- [email protected]
- [email protected]
61 changes: 61 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Changelog

## [`v1.1.0`][tag-1_1_0] (2018-04-22)

### Added

* **api:** Introduces a `Money` protocol ([#71][pr#71])
* **core:** Introduces Response.t ([#119][pr#91])
* **development:** Adds a useful mix task gringotts.new ([#78][pr#78])
* **docs:** Adds changelog, contributing guide ([#117][pr#117])

### Changed

* **api:** Deprecates use of `floats` for money amounts, check issue [#62][iss#62] ([#71][pr#71])
* **core:** Removes payment worker, no application, no worker now after josevalim [pointed it][jose-feedback] ([#118][pr#118])

[iss#62]: https://github.com/aviabird/gringotts/issues/62
[pr#71]: https://github.com/aviabird/gringotts/pulls/71
[pr#118]: https://github.com/aviabird/gringotts/pulls/118
[pr#91]: https://github.com/aviabird/gringotts/pulls/91
[pr#117]: https://github.com/aviabird/gringotts/pulls/117
[pr#78]:https://github.com/aviabird/gringotts/pulls/78
[pr#86]:https://github.com/aviabird/gringotts/pulls/86
[jose-feedback]:https://elixirforum.com/t/gringotts-a-complete-payment-library-for-elixir-and-phoenix-framework/11054/41


## [`v1.0.2`][tag-1_0_2] (2017-12-27)

### Added

* New Gateway: **Trexle**

### Changed

* **api:** Reduced arity of public API calls by 1
- No need to pass the name of the `worker` as argument.

## [`v1.0.1`][tag-1_0_1] (2017-12-23)

### Added

* **docs:** Improved documentation - made consistent accross gateways
* **tests:** Improved test coverage

## [`v1.0.0`][tag-1_0_0] (2017-12-20)

### Added

* **api:** Initial public API release.
* **core:** Single worker architecture, config fetched from `config.exs`
* **api:** Supported Gateways:
- Stripe
- MONEI
- Paymill
- WireCard
- CAMSa

[tag-1_1_0]: https://github.com/aviabird/gringotts/compare/1.1.0...1.0.2
[tag-1_0_2]: https://github.com/aviabird/gringotts/compare/1.0.2...1.0.1
[tag-1_0_1]: https://github.com/aviabird/gringotts/compare/1.0.1...1.0.0
[tag-1_0_0]: https://github.com/aviabird/gringotts/releases/tag/v1.0.0
126 changes: 126 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
# Contributing to [`gringotts`][gringotts]

There are many ways to contribute to `gringotts`,

1. [Integrate a new Payment Gateway][wiki-new-gateway].
2. Expanding the feature coverage of (partially) supported gateways.
3. Moving forward on the [roadmap][roadmap] or on tasks being tracked in the
[milestones][milestones].

We manage our development using [milestones][milestones] and issues so if you're
a first time contributor, look out for the [`good first issue`][first-issues]
and the [`hotlist: community-help`][ch-issues] labels on the [issues][issues]
page.

The docs are hosted on [hexdocs.pm][hexdocs] and are updated for each
release. **You must build the docs locally using `mix docs` to get the bleeding
edge developer docs.**

The article on [Gringott's Architecture][wiki-arch] explains how API calls are
processed.

:exclamation: ***Please base your work on the `dev` branch.***

[roadmap]: https://github.com/aviabird/gringotts/wiki/Roadmap
[wiki-arch]: https://github.com/aviabird/gringotts/wiki/Architecture

# Style Guidelines

We follow
[lexmag/elixir-style-guide](https://github.com/lexmag/elixir-style-guide) and
[rrrene/elixir-style-guide](https://github.com/rrrene/elixir-style-guide) (both
overlap a lot), and use the elixir formatter.

To enforce these, and also to make it easier for new contributors to adhere to
our style, we've provided a collection of handy `git-hooks` under the `.scripts/`
directory.

* `.scripts/pre-commit` Runs the `format --check-formatted` task.
* `.scripts/post-commit` Runs a customised `credo` check.

While we do not force you to use these hooks, you could write your
very own by taking inspiration from ours :smile:

To set the `git-hooks` as provided, go to the repo root,
```sh
cd path/to/gringotts/
```
and make these symbolic links:
```sh
ln -s .scripts/pre-commit .git/hooks/pre-commit
ln -s .scripts/post-commit .git/hooks/post-commit
```

> Note that our CI will fail your PR if you dont run `mix format` in the project
> root.

## General Rules

* Keep line length below 100 characters.
* Complex anonymous functions should be extracted into named functions.
* One line functions, should only take up one line!
* Pipes are great, but don't use them if they are less readable than brackets!

## Writing documentation

All our docs are inline and built using [`ExDocs`][exdocs]. Please take a look
at how the docs are structured for the [MONEI gateway][src-monei] for
inspiration.

[exdocs]: https://github.com/elixir-lang/ex_doc
[src-monei]: https://github.com/aviabird/gringotts/blob/dev/lib/gringotts/gateways/monei.ex

## Writing test cases

> This is WIP.

`gringotts` has mock and integration tests. We have currently used
[`bypass`][bypass] and [`mock`][mock] for mock tests, but we don't recommed
using `mock` as it constrains tests to run serially. Use [`mox`][mox] instead.\
Take a look at [MONEI's mock tests][src-monei-tests] for inspiration.

# PR submission checklist

Each PR should introduce a *focussed set of changes*, and ideally not span over
unrelated modules.

* [ ] Format the project with the Elixir formatter.
```sh
cd path/to/gringotts/
mix format
```
* [ ] Run the edited files through [credo][credo] with the `--strict` flag.
```sh
cd path/to/gringotts/
mix credo --strict
```
* [ ] Check the test coverage by running `mix coveralls`. 100% coverage is not
strictly required.
* [ ] If the PR introduces a new Gateway or just Gateway specific changes,
please format the title like so,\
`[<gateway-name>] <the-title>`

> **Note**
> You can skip the first two steps if you have set up `git-hooks` as we have
> provided!

[gringotts]: https://github.com/aviabird/gringotts
[milestones]: https://github.com/aviabird/gringotts/milestones
[issues]: https://github.com/aviabird/gringotts/issues
[first-issues]: https://github.com/aviabird/gringotts/issues?q=is%3Aissue+is%3Aopen+label%3A"good+first+issue"
[ch-issues]: https://github.com/aviabird/gringotts/issues?q=is%3Aissue+is%3Aopen+label%3A"hotfix%3A+community-help"
[hexdocs]: https://hexdocs.pm/gringotts
[credo]: https://github.com/rrrene/credo

--------------------------------------------------------------------------------

> **Where to next?**
> Wanna add a new gateway? Head to our [guide][wiki-new-gateway] for that.

[wiki-new-gateway]: https://github.com/aviabird/gringotts/wiki/Adding-a-new-Gateway
[bypass]: https://github.com/pspdfkit-labs/bypass
[mock]: https://github.com/jjh42/mock
[mox]: https://github.com/plataformatec/mox
[src-monei-tests]: https://github.com/aviabird/gringotts/blob/dev/test/gateways/monei_test.exs
[gringotts]: https://github.com/aviabird/gringotts
[docs]: https://hexdocs.pm/gringotts/Gringotts.html
Loading