-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
441 additions
and
108 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
root = true | ||
|
||
[*] | ||
end_of_line = lf | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.{html,py,json,md}] | ||
charset = utf-8 | ||
|
||
[*.py] | ||
indent_style = space | ||
indent_size = 4 | ||
max_line_length = 119 | ||
|
||
[*.md] | ||
indent_style = space | ||
indent_size = 4 | ||
max_line_length = 119 | ||
|
||
[*.html] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[Makefile] | ||
indent_style = tab | ||
|
||
[*.json] | ||
indent_style = space | ||
indent_size = 2 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[flake8] | ||
max-complexity = 10 | ||
max-line-length = 119 | ||
max-doc-length = 120 | ||
indent-size = 4 | ||
exclude = | ||
.git, | ||
__pycache__, | ||
.github, | ||
docs, | ||
tests | ||
filename = *.py | ||
accept-encodings = utf-8 | ||
inline-quotes = single | ||
multiline-quotes = double |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: Tests&Coverage | ||
|
||
on: | ||
push: | ||
branches: ["sandbox"] | ||
pull_request: | ||
branches: ["main"] | ||
|
||
jobs: | ||
tests: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python-version: ["3.9", "3.10", "3.11", "3.12"] | ||
poetry-version: ["1.8.3"] | ||
os: [ubuntu-latest] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Set Up Poetry | ||
uses: abatilo/actions-poetry@v2 | ||
with: | ||
poetry-version: ${{ matrix.poetry-version }} | ||
- name: Install merchants | ||
run: poetry install --with dev | ||
- name: Run Tests and coverage | ||
run: poetry run coverage run -m pytest | ||
- name: Coverage report (xml) | ||
run: poetry run coverage xml | ||
- name: Coveralls GitHub Action | ||
uses: coverallsapp/github-action@v2 | ||
- name: Run codacy-coverage-reporter | ||
uses: codacy/codacy-coverage-reporter-action@v1 | ||
with: | ||
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} | ||
coverage-reports: "coverage.xml" | ||
language: "python" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,40 @@ | ||
# See https://pre-commit.com for more information | ||
# See https://pre-commit.com/hooks.html for more hooks | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.4.0 | ||
rev: v4.6.0 | ||
hooks: | ||
- id: trailing-whitespace | ||
args: [--markdown-linebreak-ext=md] | ||
- id: end-of-file-fixer | ||
- id: check-yaml | ||
- id: check-toml | ||
- id: check-json | ||
- id: check-added-large-files | ||
args: ['--maxkb=1024'] | ||
- id: check-case-conflict | ||
- id: mixed-line-ending | ||
- repo: https://github.com/pycqa/isort | ||
rev: 5.13.2 | ||
hooks: | ||
- id: isort | ||
args: ["--profile", "black", "--filter-files"] | ||
- repo: https://github.com/psf/black | ||
rev: 24.4.2 | ||
hooks: | ||
- id: black | ||
- repo: https://github.com/asottile/pyupgrade | ||
rev: v3.10.1 | ||
rev: v3.16.0 | ||
hooks: | ||
- id: pyupgrade | ||
- repo: https://github.com/pycqa/isort | ||
rev: 5.12.0 | ||
args: [--py311-plus] | ||
- repo: https://github.com/pre-commit/mirrors-autopep8 | ||
rev: v2.0.4 | ||
hooks: | ||
- id: isort | ||
args: ["--profile", "black", "--filter-files", "--line-length", "100"] | ||
- id: autopep8 | ||
- repo: https://github.com/PyCQA/flake8 | ||
rev: "7.1.0" | ||
hooks: | ||
- id: flake8 | ||
additional_dependencies: | ||
- flake8-comprehensions | ||
- flake8-bugbear | ||
- flake8-polyfill | ||
- toml | ||
exclude: docs\/.* |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
.PHONY: env-info | ||
env-info: | ||
poetry env info | ||
|
||
# MIG_MSG="new thing" make migrations | ||
.PHONY: migrations | ||
migrations: | ||
poetry run flask db migrate -m "${MIG_MSG}" | ||
|
||
.PHONY: upgrade-db | ||
upgrade-db: | ||
poetry run flask db upgrade head | ||
|
||
.PHONY: pre-commit | ||
pre-commit: | ||
poetry run pre-commit autoupdate -j 2 | ||
poetry run pre-commit run --all-files |
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import peewee | ||
|
||
from merchants import settings | ||
from merchants.orm.peewee import MerchantsAccountSettings, MerchantsBaseModel | ||
|
||
db = peewee.SqliteDatabase("./examples/peewee/example.sqlite3") | ||
|
||
|
||
class Payment(MerchantsBaseModel): | ||
content = peewee.TextField() | ||
|
||
class Meta: | ||
database = db | ||
|
||
|
||
class AccountSettings(MerchantsAccountSettings): | ||
class Meta: | ||
database = db | ||
|
||
|
||
def create_database(): | ||
with db: | ||
db.create_tables([Payment, AccountSettings]) | ||
|
||
|
||
create_database() | ||
|
||
# settings.process_on_save = False | ||
settings.load_variants(config=None) | ||
print(f"{settings=}") |
Binary file not shown.
File renamed without changes.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from .config import base_settings as settings | ||
|
||
__all__ = ["settings"] |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
from dataclasses import dataclass, field | ||
|
||
|
||
def _available_integrations() -> list: | ||
return [ | ||
"paypal", | ||
"square", | ||
"stripe", | ||
"payu", | ||
"braintree", # es de paypal | ||
"authorizenet", | ||
"twocheckout", | ||
"verifone", # compró 2checkout | ||
"worldpay", | ||
"fis", # fisglobal.com compro worldpay | ||
"adyen", | ||
"skrill", | ||
"applepay", | ||
"googlepay", | ||
"klarna", | ||
"wepay", | ||
"alipay", | ||
"wix", | ||
] | ||
|
||
|
||
@dataclass | ||
class MerchantsSettings: | ||
available_integrations: list = field(default_factory=_available_integrations) | ||
enabled_accounts: list = field(default_factory=list) | ||
process_on_save: bool = True | ||
|
||
load_from_database: bool = True | ||
|
||
def __post__init__(self): | ||
pass | ||
|
||
def load_variants(self, config: dict) -> list: | ||
from .integrations.dummy import settings as example_settings | ||
|
||
self.enabled_accounts = [ | ||
{ | ||
"example": { | ||
"config": example_settings, | ||
"provider_class": "merchants.integrations.dummy.Provider", | ||
} | ||
}, | ||
] | ||
return self.enabled_accounts | ||
|
||
|
||
base_settings = MerchantsSettings() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from dataclasses import dataclass | ||
|
||
|
||
@dataclass | ||
class ModelStatus: | ||
CREATED: str = "Created" | ||
PROCESSING: str = "Processing" | ||
ERROR: str = "Error" | ||
REJECTED: str = "Rejected" | ||
COMPLETED: str = "Completed" | ||
REFUNDED: str = "Refunded" | ||
REVERSED: str = "Reversed" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
class ProcessError(Exception): | ||
pass |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from ..config import base_settings | ||
|
||
|
||
def local_factory(slug: str): | ||
if slug not in base_settings.available_providers: | ||
raise NotImplementedError(f"The provider {slug} is not supported.") | ||
|
||
return slug | ||
|
||
|
||
def create_provider(slug: str): | ||
if slug not in base_settings.available_providers: | ||
raise NotImplementedError(f"The provider {slug} is not supported.") | ||
|
||
return slug |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from dataclasses import dataclass | ||
|
||
__version__ = "0.1.0" | ||
__merchants_name__ = "dummy" | ||
__merchants_slug__ = "dummy" | ||
|
||
|
||
@dataclass | ||
class Settings: | ||
endpoint: str = "https://api.example.com" | ||
api_key: str = "key_123456" | ||
api_secret: str = "secret_123456" | ||
|
||
|
||
settings = Settings() |
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
__version__ = "0.1.0" | ||
__merchants_name__ = "Stripe" | ||
__merchants_slug__ = "stripe" |
File renamed without changes.
Oops, something went wrong.