Skip to main content

Nellika SCB Payment Integration - Hardened C Module (Commercial License Required)

Project description

nell-scb-lib

Python C extension for SCB (Siam Commercial Bank) payment integration with PromptPay QR code generation.

⚠️ IMPORTANT LICENSING INFORMATION

This software is subject to commercial licensing terms and usage fees.

  • This library requires a valid commercial license for production use
  • Usage telemetry data is collected and transmitted to Nellika Consulting Services Ltd.
  • By installing and using this library, you agree to the collection and transmission of usage telemetry
  • For licensing inquiries and pricing information, please contact: sales@nellika.co.th

Copyright © 2024 Nellika Consulting Services Ltd. All rights reserved.


Overview

nell-scb-lib is a high-performance C extension module providing SCB payment integration for Python applications. It handles OAuth token management, QR code generation, and payment status checking through SCB's official API.

Installation

pip install nell-scb-lib

Supported Platforms:

  • Linux x86_64 (manylinux_2_31+)
  • macOS ARM64 (Apple Silicon M1/M2/M3/M4)
  • Python 3.9 through 3.14

Telemetry & Privacy

This library collects the following telemetry data:

  • License key usage and validation events
  • API operation counts (QR creation, token refresh, payment checks)
  • Error rates and types
  • Library version and platform information
  • No sensitive data (API keys, secrets, transaction details, or customer information) is collected

Telemetry helps us:

  • Monitor license compliance
  • Improve library stability and performance
  • Provide better support to our customers

By using this library, you consent to this data collection.

For questions about data collection or to request data deletion, contact: privacy@nellika.co.th


Quick Start

import nell_scb_lib

# Create QR payment (database-driven, recommended)
result = nell_scb_lib.create_qr_by_bank_account(
    bank_account_id=1,
    amount=250.75,
    ref1="P00001",      # Invoice number (max 20 chars)
    ref2="CUST001",     # Customer code (max 12 chars)
    ref3="SCB"          # Optional reference
)

if result['status']['code'] == 1000:
    qr_image = result['data']['qrImage']  # Base64 PNG
    qr_raw = result['data']['qrRawData']  # PromptPay string
    print(f"QR created: {result['data']['transactionId']}")

Environment Variables

Required for database-driven methods:

export PGDATABASE=your_database
export PGHOST=localhost
export PGPORT=5432
export PGUSER=odoo
export PGPASSWORD=your_password  # optional

API Reference

High-Level API (Recommended)

create_qr_by_bank_account(bank_account_id, amount, ref1, ref2, ref3="SCB")

Create SCB QR payment code using bank account ID. Automatically fetches configuration from database and manages token refresh.

Parameters:

  • bank_account_id (str/int): Bank account ID from res.partner.bank
  • amount (float): Payment amount in THB
  • ref1 (str): Reference 1, max 20 characters
  • ref2 (str): Reference 2, max 12 characters
  • ref3 (str, optional): Reference 3, defaults to "SCB"

Returns: dict - SCB API response

{
    "status": {"code": 1000, "description": "Success"},
    "data": {
        "qrRawData": "00020101021230...",
        "qrImage": "iVBORw0KGgoAAAANSUhEUgAA...",
        "transactionId": "..."
    }
}

Example:

result = nell_scb_lib.create_qr_by_bank_account(
    bank_account_id=1,
    amount=250.75,
    ref1="P00001",
    ref2="CUST001"
)

Mid-Level API

create_qr_full(api_key, access_token, qr_create_url, biller_id, amount, ref1, ref2, ref3="SCB")

Create SCB QR code with explicit parameters (requires manual token management).

Parameters:

  • api_key (str): SCB API key
  • access_token (str): Valid OAuth token
  • qr_create_url (str): SCB QR endpoint URL
  • biller_id (str): PromptPay biller ID
  • amount (float): Payment amount in THB
  • ref1 (str): Reference 1, max 20 characters
  • ref2 (str): Reference 2, max 12 characters
  • ref3 (str, optional): Reference 3, defaults to "SCB"

Returns: dict - SCB API response

Example:

# Step 1: Get access token
token_resp = nell_scb_lib.refresh_token(api_key, api_secret, token_url)
access_token = token_resp['data']['accessToken']

# Step 2: Create QR
result = nell_scb_lib.create_qr_full(
    api_key="your_api_key",
    access_token=access_token,
    qr_create_url="https://api.scb/...",
    biller_id="894547854396914",
    amount=100.50,
    ref1="P00001",
    ref2="TEST"
)

refresh_token(api_key, api_secret, token_url)

Refresh SCB OAuth access token.

Parameters:

  • api_key (str): SCB API key
  • api_secret (str): SCB API secret
  • token_url (str): Token endpoint URL

Returns: dict - Token response

{
    "status": {"code": 1000, "description": "Success"},
    "data": {
        "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
        "expiresIn": 1800,
        "tokenType": "Bearer"
    }
}

Low-Level API

create_qr(config_id, amount, reference, channel="ecomm")

Create QR code using config ID from database (legacy method).

Parameters:

  • config_id (str): SCB API configuration ID
  • amount (float): Payment amount
  • reference (str): Payment reference
  • channel (str, optional): Payment channel, defaults to "ecomm"

Returns: dict - SCB API response


check_payment(reference)

Check SCB payment status by reference.

Parameters:

  • reference (str): Payment reference to check

Returns: dict - Payment status

{
    "status": {"code": 1000, "description": "Success"},
    "data": {
        "paymentStatus": "SUCCESS",
        "transactionId": "...",
        "amount": 100.50
    }
}

version()

Get module version string.

Returns: str - Version (e.g., "1.1.0")


Database Schema Requirements

For database-driven methods, these tables are required:

res_partner_bank:

  • Column: scb_biller_id (VARCHAR) - PromptPay biller ID

scb_api_config:

  • Columns: api_key, api_secret, environment, token_url, qr_create_url, payment_inquiry_url
  • Must have active configuration record

Error Handling

All functions raise RuntimeError for failures:

try:
    result = nell_scb_lib.create_qr_by_bank_account(
        bank_account_id=1,
        amount=250.75,
        ref1="P00001",
        ref2="CUST001"
    )
    
    if result['status']['code'] == 1000:
        # Success
        qr_data = result['data']
    else:
        # API error
        print(f"Error: {result['status']['description']}")
        
except RuntimeError as e:
    # System error
    print(f"Failed: {e}")

Response Status Codes

  • 1000: Success
  • 1001: Invalid request
  • 1002: Authentication failed
  • 1003: Insufficient balance
  • 1004: Transaction not found
  • 1005: System error

Always check the status code:

if result['status']['code'] == 1000:
    # Process successful response
    pass
else:
    # Handle error
    error_msg = result['status']['description']

Best Practices

  1. Use High-Level API: Prefer create_qr_by_bank_account() for automatic configuration management
  2. Validate References: Keep ref1 ≤ 20 chars, ref2 ≤ 12 chars
  3. Check Status Codes: Always verify status.code == 1000 before using data
  4. Handle Errors: Wrap API calls in try-except blocks
  5. Environment Setup: Configure PostgreSQL environment variables before use

Features

  • ✅ Native C implementation for high performance
  • ✅ Automatic OAuth token management
  • ✅ Database-driven configuration
  • ✅ PromptPay QR code generation
  • ✅ Payment status checking
  • ✅ Thread-safe operations
  • ✅ Secure API communication (libcurl)
  • ✅ Built-in license management
  • ✅ Usage telemetry for compliance and support

Support & Contact

Legal

Copyright © 2024 Nellika Consulting Services Ltd. All rights reserved.

This software is proprietary and confidential. Unauthorized copying, distribution, or use of this software, via any medium, is strictly prohibited without prior written permission from Nellika Consulting Services Ltd.

For licensing terms and conditions, please contact sales@nellika.co.th

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

nell_scb_lib-1.1.2-cp314-cp314-macosx_14_0_arm64.whl (4.5 MB view details)

Uploaded CPython 3.14macOS 14.0+ ARM64

nell_scb_lib-1.1.2-cp313-cp313-macosx_14_0_arm64.whl (4.5 MB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

nell_scb_lib-1.1.2-cp312-cp312-manylinux_2_38_x86_64.whl (7.2 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.38+ x86-64

nell_scb_lib-1.1.2-cp312-cp312-manylinux_2_34_x86_64.whl (6.9 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

nell_scb_lib-1.1.2-cp312-cp312-macosx_14_0_arm64.whl (4.5 MB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

nell_scb_lib-1.1.2-cp311-cp311-macosx_14_0_arm64.whl (4.5 MB view details)

Uploaded CPython 3.11macOS 14.0+ ARM64

nell_scb_lib-1.1.2-cp310-cp310-manylinux_2_34_x86_64.whl (6.9 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

nell_scb_lib-1.1.2-cp310-cp310-macosx_14_0_arm64.whl (4.5 MB view details)

Uploaded CPython 3.10macOS 14.0+ ARM64

nell_scb_lib-1.1.2-cp39-cp39-macosx_14_0_arm64.whl (4.5 MB view details)

Uploaded CPython 3.9macOS 14.0+ ARM64

File details

Details for the file nell_scb_lib-1.1.2-cp314-cp314-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for nell_scb_lib-1.1.2-cp314-cp314-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 18947cfc5bf7e5be94cba51d434a3ebb873ab09963717b7ac17fd57fa8117974
MD5 aafe99f1c40fbf0b02534c8fe5973eef
BLAKE2b-256 a7513d99f4ade167a1948c31a3aa72797a9d65c9df167cacf8f95c8f4f2db54d

See more details on using hashes here.

File details

Details for the file nell_scb_lib-1.1.2-cp313-cp313-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for nell_scb_lib-1.1.2-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 fa48d6d0f0333ad87385ede7b57e04b407f3b21fc4fcad3a0f23d104469d7d56
MD5 28e2cf2ba1e15d2c55909a700c25a460
BLAKE2b-256 704553d1a3e7fccd03c85382636ad83897a976ac837d1f1a96d32156ef3aeeaa

See more details on using hashes here.

File details

Details for the file nell_scb_lib-1.1.2-cp312-cp312-manylinux_2_38_x86_64.whl.

File metadata

File hashes

Hashes for nell_scb_lib-1.1.2-cp312-cp312-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 d4f8c4eb9a6b232df586e8e8c56b989d2b5131ed4f946a22f60cb4b719bad352
MD5 4b1a9011dab5dfdf0037945b13e1be27
BLAKE2b-256 f94d6a749f3a7e2e6f4466cd523eab5c0dc2967a4401db845c1218c117137958

See more details on using hashes here.

File details

Details for the file nell_scb_lib-1.1.2-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for nell_scb_lib-1.1.2-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 76941cebc6c08dc65aa90bf8e544df89378c30e90f04b92502cc9780736eaf09
MD5 56db145a8816f078eec54f6cff64fac1
BLAKE2b-256 c6131c5e51be90f34f021d2a6f21fa03120dcf82066973956846c8bdfc31bdc7

See more details on using hashes here.

File details

Details for the file nell_scb_lib-1.1.2-cp312-cp312-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for nell_scb_lib-1.1.2-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 be9f17dff157a57743c206ad46cbf60b30d6d98dd1d3416cd2587078cd1117b7
MD5 47d6f09e19610249ea882882974fdb49
BLAKE2b-256 13c0c4e47e947c4919a4680767bceed27d22b6b659733f97621051ebc50239ee

See more details on using hashes here.

File details

Details for the file nell_scb_lib-1.1.2-cp311-cp311-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for nell_scb_lib-1.1.2-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 c871435cd3cbbda17a479305a66c455e745e5f38c16f997adbd5226f0465fbd7
MD5 638601ee07e38d8b959459ae54461854
BLAKE2b-256 784d5b6c2c1b72d6b4060ee18869a37a0ea5ff4f79c71ff4c0c3bd4b909478ac

See more details on using hashes here.

File details

Details for the file nell_scb_lib-1.1.2-cp310-cp310-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for nell_scb_lib-1.1.2-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 57ec5aabec68356bd8ecc1125c0f88e4c9640aadf7f14bda62192e76d6a8fda6
MD5 dce141d0c75d5a6b46041c6dcadca41d
BLAKE2b-256 6d689af74ae4ec9e1be618a95350cd3967a1a52b35c93bf18126f2bf66997b65

See more details on using hashes here.

File details

Details for the file nell_scb_lib-1.1.2-cp310-cp310-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for nell_scb_lib-1.1.2-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 1b3b025892e31aab430d7d4f62c7a238fc6729c4987d1a3bacf49008bdb4e102
MD5 7fbc7d57366fcdf40df092a419bcb127
BLAKE2b-256 54fcd3c563e6d7ecd8e29b5651c37b2f6b7e2660c98ba8c71aae9e2c2cec6fe3

See more details on using hashes here.

File details

Details for the file nell_scb_lib-1.1.2-cp39-cp39-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for nell_scb_lib-1.1.2-cp39-cp39-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 b9f22f1bb677d37a607abf011570154ba56ed1b4e6303441bed214ca8a611995
MD5 17d70fc3a48da16b2750e9b191fa37dc
BLAKE2b-256 1071fa3c58a31feb4a21fb4265d7367e6aae668b9812355f1a65a60e1a601f3d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page