-
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
7 changed files
with
138 additions
and
55 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 |
---|---|---|
@@ -1,41 +1,39 @@ | ||
# name: Tests&Coverage | ||
name: Tests&Coverage | ||
|
||
# on: | ||
# push: | ||
# branches: ["sandbox"] | ||
# pull_request: | ||
# branches: ["main"] | ||
on: | ||
push: | ||
branches: ["sandbox"] | ||
|
||
# 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@v4 | ||
# - 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" | ||
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@v4 | ||
- 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@v3 | ||
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,7 +1,67 @@ | ||
# merchants | ||
# Merchants | ||
|
||
A gateway platform to process payments | ||
[![PyPI version](https://badge.fury.io/py/merchants.svg)](https://badge.fury.io/py/merchants) | ||
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) | ||
[![Python Versions](https://img.shields.io/pypi/pyversions/merchants.svg)](https://pypi.org/project/merchants/) | ||
[![FastAPI](https://img.shields.io/badge/FastAPI-005571?style=for-the-badge&logo=fastapi)](https://fastapi.tiangolo.com) | ||
[![Downloads](https://pepy.tech/badge/merchants)](https://pepy.tech/project/merchants) | ||
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) | ||
|
||
## Babel | ||
A unified payment processing toolkit for FastAPI applications, inspired by django-payments. | ||
|
||
poetry run pybabel extract merchants/ -o test.pot | ||
## Overview | ||
|
||
Merchants is an all-in-one payment processing solution designed to integrate seamlessly with FastAPI applications. This | ||
modular payment integration system aims to simplify the implementation of various payment gateways and provide a | ||
flexible interface for handling different payment methods. | ||
|
||
## Features | ||
|
||
- Easy integration with FastAPI applications | ||
- Support for multiple payment gateways | ||
- Customizable payment workflows | ||
- Webhook handling for payment status updates | ||
- Extensible architecture for adding new payment providers | ||
- Unified API across different payment services | ||
|
||
## Installation | ||
|
||
```bash | ||
poetry add fastapi-merchants | ||
``` | ||
|
||
## Quick Start | ||
|
||
```python | ||
from fastapi import FastAPI | ||
from fastapi_merchants import Merchants | ||
|
||
app = FastAPI() | ||
merchants = Merchants(app) | ||
|
||
# Configure your payment providers | ||
merchants.add_provider("stripe", api_key="your_stripe_api_key") | ||
merchants.add_provider("paypal", client_id="your_paypal_client_id", client_secret="your_paypal_client_secret") | ||
|
||
# Use Merchants in your routes | ||
@app.post("/create-payment") | ||
async def create_payment(amount: float, currency: str, provider: str): | ||
return await merchants.create_payment(amount, currency, provider) | ||
``` | ||
|
||
## Documentation | ||
|
||
For detailed documentation, please visit [our documentation site](https://mariofix.github.io/fastapi-merchants). | ||
|
||
## License | ||
|
||
Merchants is released under the MIT License. See the [LICENSE](LICENSE) file for more details. | ||
|
||
## Acknowledgements | ||
|
||
This project was inspired by the django-payments library and aims to provide similar functionality for FastAPI | ||
applications, some parts were made with Claude and/or ChatGPT. | ||
|
||
## Changelog | ||
|
||
See the [CHANGELOG](CHANGELOG) file for more details. |
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
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,4 +1,9 @@ | ||
from sqlmodel import Session, create_engine, select | ||
from merchants.config import settings | ||
|
||
engine = create_engine(str(settings.SQLALCHEMY_DATABASE_URI)) | ||
|
||
engine = create_engine( | ||
settings.SQLALCHEMY_DATABASE_URI, | ||
pool_recycle=1800, | ||
pool_pre_ping=True, | ||
) |
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,22 @@ | ||
import pytest | ||
from fastapi.testclient import TestClient | ||
from sqlmodel import Session | ||
from merchants.FastapiApp import app | ||
from merchants.database import engine | ||
|
||
# Create a test client | ||
client = TestClient(app) | ||
|
||
|
||
# Mock database session | ||
@pytest.fixture | ||
def mock_db(): | ||
with Session(engine) as session: | ||
yield session | ||
|
||
|
||
# Test root endpoint | ||
def test_root(): | ||
response = client.get("/") | ||
assert response.status_code == 200 | ||
assert response.json() == {"message": "Hello World"} |