Skip to main content

Pine Labs Online P3P Buyer SDK (Python)

Python SDK for Pine Labs Online P3P buyer clients. It mirrors @pine-labs-online/p3p-buyer-sdk, intercepts HTTP 402 Payment Required responses, creates customer-scoped P3P payment credentials, and retries paid requests.

Installation

pip install pinelabs-p3p-buyer-sdk

Import module: pinelabs_p3p_buyer. Requires Python 3.9 or newer.

Quick Start

from pinelabs_p3p_buyer import (
    BuyerRuntimeContext,
    P3PEnvironment,
    PaymentGateway,
    PaymentMethod,
    PluralBuyer,
    PluralBuyerConfig,
)

buyer = PluralBuyer.create(PluralBuyerConfig(
    env=P3PEnvironment.SANDBOX,
    paymentGateway=PaymentGateway.PineLabsOnline,
    selectedPaymentMethod=PaymentMethod.UpiSbmd,
))

response = buyer.get(
    "https://seller.example.com/api/premium",
    context=BuyerRuntimeContext(
        customerKey="customer-api-token",
        customerReference="9876543210",
        mobileNumber="9876543210",
    ),
)
print(response.json())
buyer.close()

Customer identity is runtime context, not static SDK config. This lets one buyer instance safely serve many customers.

402 Flow

  1. Your code calls buyer.get(url, context=...).
  2. The seller returns HTTP 402 with WWW-Authenticate: Payment <challenge>.
  3. The SDK decodes the challenge and validates paymentGateway == "PINE LABS ONLINE".
  4. The SDK calls POST /api/v1/customer/mpp/token with:
    • X-Customer-Key: <context.customerKey>
    • customer.mobile_number
    • challenge_id
    • payment_amount.value in minor units
  5. The SDK retries the seller with P3P-Credential: Payment <credential>.
  6. The seller captures the payment and may return Payment-Receipt.

Direct Token API

from pinelabs_p3p_buyer import Amount, CreateTokenOptions, PaymentMethod

token = buyer.methods.create_token(CreateTokenOptions(
    customerKey="customer-api-token",
    customerReference="9876543210",
    mobileNumber="9876543210",
    challengeId="ch_...",
    paymentAmount=Amount(value=50000, currency="INR"),
    paymentMethod=PaymentMethod.UpiSbmd,
))

The buyer SDK no longer creates mandates. Mandate/pre-authorization creation is handled by the seller SDK.

Supported Methods

  • PaymentMethod.UpiSbmd -> "SBMD" / UPI ReservePay
  • PaymentMethod.Crypto -> "CRYPTO"

Error Handling

from pinelabs_p3p_buyer import P3PChallengeError, P3PError, P3PNetworkError

try:
    response = buyer.get(url, context=runtime_context)
except P3PChallengeError as err:
    ...
except P3PNetworkError as err:
    ...
except P3PError as err:
    print(err.code, err.http_status, err.details)

License

MIT

Metadata

Release files for pinelabs-online-mpp-client-sdk 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pinelabs-online-mpp-client-sdk 0.1.3
File Size Uploaded
pinelabs_online_mpp_client_sdk-0.1.3.tar.gz 19.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pinelabs-online-mpp-client-sdk 0.1.3
File Interpreter ABI Platform
pinelabs_online_mpp_client_sdk-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 41.7 kB

Release files / pinelabs_online_mpp_client_sdk-0.1.3.tar.gz

Download URL pinelabs_online_mpp_client_sdk-0.1.3.tar.gz
Size 19.1 kB
Tags Source
SHA-256 checksum
How to use checksums
346b0b2aa9380673bfc433165d463e6e38c14765dc0283e16dd0cbc3b213aad5
BLAKE2b-256 checksum
How to use checksums
38fb5f9b01644d2335a07a46b8fd212025cd4842fb432bca6ee8bc7c151137b2
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_client_sdk-0.1.3-py3-none-any.whl

Download URL pinelabs_online_mpp_client_sdk-0.1.3-py3-none-any.whl
Size 22.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1a995acedf3b4c754f7869e481e63f86ef84fbb088dc500a7a72e3f80541cd80
BLAKE2b-256 checksum
How to use checksums
b769beabc75fe04e758e53483b07c8812212d35d8a1d47be066cda67bc437e75
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page