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.0.tar.gz (5.9 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.0-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: cashfree_payment-0.1.0.tar.gz
  • Upload date:
  • Size: 5.9 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.0.tar.gz
Algorithm Hash digest
SHA256 18d1853d5a7bcaf986b540a3cac01fa53f59192758fa98382ead63ceb3545dd4
MD5 ade91f4ca6100cb15c0acdba1aae72e8
BLAKE2b-256 40b024c11cb0228b0544ca24a9bcc7bbd625f3a827b178fd4d255664904ac663

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cashfree_payment-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c47400299a31d5b61478697dd6d0a778e80fa92c70565f2188249c35c8ad1313
MD5 a1565016fb39180fab1d28b0645ae052
BLAKE2b-256 ca51a7cfbdd04765b60efe07a3e4bd892e2445fcce83373624896d4137307ff0

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