A simple PayMongo API wrapper for Python.
Project description
PayMongo Service (Python)
A simple and lightweight Python wrapper for the PayMongo API that allows developers to create payment intents, methods, and attach them using Python code.
Features
- Create Payment Intents
- Create Payment Methods
- Attach a Payment Method to an Intent
- Supports both
cardandgcash - Supports environment variable or direct secret key assignment
Installation
Install via pip:
pip install paymongo-wrapper
Setup
You can either:
1. Use environment variables (recommended):
Create a .env file:
PAYMONGO_SECRET_KEY=sk_test_your_secret_key
PAYMONGO_PUBLIC_KEY=pk_test_your_public_key
PAYMONGO_RETURN_URL=http://127.0.0.1:8000/
Then load them using python-dotenv:
from dotenv import load_dotenv
load_dotenv()
2. Declartion
from paymongo_wrapper import PayMongoService
paymongo = PayMongoService(
secret_key="sk_test_your_secret_key",
return_url="http://127.0.0.1:8000/"
)
intent = paymongo.create_payment_intent(100.00)
3(Optional). Or directly modify the variables in service.py:
PAYMONGO_SECRET_KEY = "sk_test_your_secret_key"
PAYMONGO_PUBLIC_KEY = "pk_test_your_public_key"
PAYMONGO_RETURN_URL = "http://127.0.0.1:8000/"
Usage
from paymongo_wrapper import PayMongoService
paymongo = PayMongoService()
# Step 1: Create a Payment Intent
intent = paymongo.create_payment_intent(amount=100) # PHP 100.00
payment_intent_id = intent['data']['id']
# Step 2: Create a Payment Method
method = paymongo.create_payment_method(
method_type="gcash",
details={"phone": "09171234567"}
)
payment_method_id = method['data']['id']
# Step 3: Attach the Payment Method to the Intent
result = paymongo.attach_payment_intent(payment_intent_id, payment_method_id)
print(result)
Exception Handling
The library raises custom exceptions:
PaymentIntentErrorPaymentMethodErrorAttachIntentError
Wrap your logic in try-except blocks if needed.
Contributing
Contributions are welcome. Please open an issue or pull request.
License
This project is licensed under the MIT License. See LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file paymongo_wrapper-1.1.1.tar.gz.
File metadata
- Download URL: paymongo_wrapper-1.1.1.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
57826d3f9007917687b432db8fa7ffffc7fda013b0b5b6747fc7379e8adfd5e7
|
|
| MD5 |
9c0446ac2342e75c3372da736e799b54
|
|
| BLAKE2b-256 |
799f07a413cada7e15acca44a49736ba808614930b371613bdc56179c42deab7
|
File details
Details for the file paymongo_wrapper-1.1.1-py3-none-any.whl.
File metadata
- Download URL: paymongo_wrapper-1.1.1-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f0d1b0058b694ef582dc0765abcc16885305af596b138b8fb0b99ed443ce4193
|
|
| MD5 |
b56fc43b88e4a9339b4d998354769bc3
|
|
| BLAKE2b-256 |
5a57951b48e9e32389dff560983c2ef6e63bfe4532226b46487d759fd297ac9c
|