Metadata-Version: 2.1
Name: peachpayments-partner-marshmallow
Version: 0.2.8
Summary: PeachPayments Partner Marshmallow library contains Marshmallow schemas to help integrate PeachPayments with their partners.
Home-page: https://gitlab.com/peachpayments/peachpayments-partner-marshmallow/
License: MIT
Author: PeachPayments
Author-email: support@peachpayments.com
Requires-Python: >=3.9,<4.0
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Financial and Insurance Industry
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Utilities
Classifier: Typing :: Typed
Requires-Dist: iso4217 (>=1.6.20180829,<2.0.0)
Requires-Dist: marshmallow (==3.13.0)
Requires-Dist: peachpayments-partner (>=0.1.11,<0.2.0)
Project-URL: Repository, https://gitlab.com/peachpayments/peachpayments-partner-marshmallow/
Description-Content-Type: text/markdown

# PeachPayments Partner Marshmallow Library

## Overview

**PeachPayments Partner Marshmallow Library** is a platform-agnostic Python package to help Payment Service Providers in integrating with PeachPayments. This library provides functionality to validate request and response data using Marshmallow Python library.

**Source Code**: https://gitlab.com/peachpayments/peach-partner-marshmallow/

---
### Key terms
|   Term	                    |   Definition	|
|---------------------------- |--------------	|
|   Partner API		            |   A service provided by Peach Payments to enable Payment Service Providers to become available on the Peach Platform |
|   Payment Service Provider	|   A payment service provider who integrates with the Partner API	|
|   Outbound API call	        |   API calls sent from Partner API to the Payment Service Provider  |
|   Inbound API call		      |   API calls sent from Payment Service Provider to Partner API    |

## Usage
Package requires Python 3.9+

### Installation
```sh
# pip
$ pip3 install peachpayments-partner-marshmallow
```
```sh
# poetry
$ poetry add peachpayments-partner-marshmallow
```

### Field validation

Payment Service Provider receives a debit request from PeachPayments.

```python
# ... imports
from peachpayments_partner_marshmallow.validator import validate_debit_request, validate_debit_response


def debit(db: Session, data: dict):
    request_validation = validate_debit_request(data)
    if not request_validation["valid"]:
        raise HttpJSONError(request_validation["response"])

    # Store a transaction in a database
    # Prepare the response to PeachPayments in the `response_fields` dictionary

    response_validation = validate_debit_response(response_fields)
    if not response_validation["valid"]:
        raise Exception("Badly formatted response fields")

    return HttpResponse(response_fields)
```

