Pine Labs Online P3P Seller SDK (Python)
Python SDK for Pine Labs Online P3P seller integrations. It mirrors
@pine-labs-online/p3p-seller-sdk, creates mandates, generates HTTP 402
payment challenges, verifies buyer credentials, captures payments through P3P,
and builds Payment-Receipt headers.
Installation
pip install pinelabs-p3p-seller-sdk[flask]
pip install pinelabs-p3p-seller-sdk[fastapi]
Import module: pinelabs_p3p_seller. Requires Python 3.9 or newer.
Config
from pinelabs_p3p_seller import (
P3PEnvironment,
PaymentGateway,
PaymentMethod,
PluralSellerConfig,
)
config = PluralSellerConfig(
clientId="...",
clientSecret="...",
challengeSecretKey="...",
env=P3PEnvironment.SANDBOX,
paymentGateway=PaymentGateway.PineLabsOnline,
availablePaymentMethods=[PaymentMethod.UpiSbmd, PaymentMethod.Crypto],
)
clientId and clientSecret are used internally for POST /api/auth/v1/token.
The SDK caches and refreshes bearer tokens before expiry. env selects the
Pine Labs host used for auth and /mpp/v1/* service calls.
Mandates
from pinelabs_p3p_seller import Amount, CreateMandateOptions, PluralP3P
p3p = PluralP3P.create(config)
mandate = p3p.create_mandate(CreateMandateOptions(
mobileNumber="9876543210",
customerReference="9876543210",
amount=Amount(value=100000, currency="INR"),
paymentMethod=PaymentMethod.UpiSbmd,
validityInDays=20,
))
This maps to POST /mpp/v1/pre-authorize and sends
customer.mobile_number.
Paid Resource Flow
from flask import Flask, jsonify
from pinelabs_p3p_seller import Amount, ChargeOptions
from pinelabs_p3p_seller.flask_mw import payment_required
app = Flask(__name__)
@app.get("/api/premium")
@payment_required(config, ChargeOptions(
amount=Amount(value=50000, currency="INR"),
resource="/api/premium",
))
def premium():
return jsonify({"data": "premium content"})
The middleware reads P3P-Credential: Payment <payload>, not Authorization,
so it does not conflict with application bearer auth.
Capture
from pinelabs_p3p_seller import CaptureOptions
result = p3p.capture(CaptureOptions(
token="MPP_TOK_123",
amount=Amount(value=50000, currency="INR"),
paymentMethod=PaymentMethod.UpiSbmd,
customerReference="9876543210",
mobileNumber="9876543210",
challengeId="ch_123",
merchantOrderReference="order-123",
))
The debit body uses customer.mobile_number, payment_amount,
payment_token, and challenge_id. The SDK sends Idempotency-Key and
Request-Hash headers and does not send Merchant-ID.
Generic Middleware Helper
from pinelabs_p3p_seller.server.middleware import decide_payment
decision = decide_payment(
credential_header=request.headers.get("P3P-Credential"),
config=config,
charge_options=ChargeOptions(
amount=Amount(value=50000, currency="INR"),
resource="/api/premium-data",
),
)
License
MIT
Metadata
Release files for pinelabs-online-mpp-server-sdk 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pinelabs_online_mpp_server_sdk-0.1.2.tar.gz | 25.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pinelabs_online_mpp_server_sdk-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 57.2 kB
Release files / pinelabs_online_mpp_server_sdk-0.1.2.tar.gz
| Download URL | pinelabs_online_mpp_server_sdk-0.1.2.tar.gz |
|---|---|
| Size | 25.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a9473b229ea830f4e5fb20286c213a9f37ee6d88abaf56e4b6bc866cab3d4e37
|
|
BLAKE2b-256 checksum How to use checksums |
cbdbfc43be31b05e5a510d60168b1a9f66b27944440e81fa476cb65e867f245d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.4
|
Release files / pinelabs_online_mpp_server_sdk-0.1.2-py3-none-any.whl
| Download URL | pinelabs_online_mpp_server_sdk-0.1.2-py3-none-any.whl |
|---|---|
| Size | 32.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8af502bff9f1d5bc8207ddfbc0a57ca47486b0ea092f3ffa6795dc6dd746760a
|
|
BLAKE2b-256 checksum How to use checksums |
b2d04d4b42044882be87c4e716ddb53728e8bb50372e35fb9ba659e1e2d0d634
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.4
|