Skip to main content

A Python library for Cashfree payment integration with access key management

Project description

Cashfree Payment

A Python library for Cashfree payment integration with access key management.

Installation

pip install cashfree-payment

Requirements

  • Python 3.8+
  • PostgreSQL database with Neon
  • Environment variable: NEON_DATABASE_URL

Quick Start

from cashfree_payment import (
    create_owner,
    owner_login,
    generate_access_key,
    pay,
    list_keys
)

# Create an owner account
owner_id = create_owner('username', 'password')

# Login to get owner_id
owner_id = owner_login('username', 'password')

# Generate an access key (valid for 30 days)
access_key = generate_access_key(owner_id, valid_days=30)

# Make a payment
session_id = pay('your_upi_id@bank', access_key)

# List all your access keys
list_keys(owner_id)

Features

Owner Management

  • create_owner(username, password) - Create a new owner account
  • owner_login(username, password) - Login and get owner ID

Access Key Management

  • generate_access_key(owner_id, valid_days=30, valid_hours=0) - Generate a new access key
  • generate_access_key_custom(owner_id, valid_until_str) - Generate key with custom expiry
  • list_keys(owner_id) - List all access keys for an owner
  • ban_key(owner_id, access_key) - Ban an access key
  • unban_key(owner_id, access_key) - Unban an access key
  • delete_key(owner_id, access_key) - Delete an access key
  • update_key_expiry(owner_id, access_key, new_valid_until_str) - Update key expiry

Payment

  • pay(upi_id, access_key) - Make a payment using UPI ID

Database Setup

Create the required tables in your PostgreSQL database:

CREATE TABLE owners (
    id SERIAL PRIMARY KEY,
    username VARCHAR(255) UNIQUE NOT NULL,
    password_hash VARCHAR(255) NOT NULL
);

CREATE TABLE access_keys (
    id SERIAL PRIMARY KEY,
    key_value VARCHAR(255) UNIQUE NOT NULL,
    owner_id INTEGER REFERENCES owners(id),
    valid_until TIMESTAMP NOT NULL,
    is_active BOOLEAN DEFAULT TRUE
);

CREATE TABLE sessions (
    id SERIAL PRIMARY KEY,
    order_id VARCHAR(255),
    payment_session_id VARCHAR(255),
    amount VARCHAR(50),
    upi_id VARCHAR(255),
    user_ip VARCHAR(50),
    request_count INTEGER DEFAULT 0
);

CREATE TABLE cookies (
    id SERIAL PRIMARY KEY,
    cookie TEXT NOT NULL
);

Environment Variables

Set the following environment variable:

export NEON_DATABASE_URL="postgresql://user:password@host/database"

License

MIT License

Project details


Download files

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

Source Distribution

cashfree_payment-0.1.1.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

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

cashfree_payment-0.1.1-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file cashfree_payment-0.1.1.tar.gz.

File metadata

  • Download URL: cashfree_payment-0.1.1.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for cashfree_payment-0.1.1.tar.gz
Algorithm Hash digest
SHA256 bd32df488fc460e28641356a8e5d9944ca97517a84a806741e1abda5efa4c2c2
MD5 9bc89765d35c8d7d822f8d80cae3be38
BLAKE2b-256 a1a94462c484970f900532879b00d09b95021b836dae3a19a899859e7f40047f

See more details on using hashes here.

File details

Details for the file cashfree_payment-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for cashfree_payment-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ea3adf2240bbfbbeae8de524ab455b2d514edafb7216cc1fda63e8a5bba981e7
MD5 8f0cd4eb267c474fe16f65e254e2ec33
BLAKE2b-256 0f7e74bee146d793a420c0fc648cda974c413a3d6933c99c7fa14167383c313b

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