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.2.tar.gz (6.8 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.2-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: cashfree_payment-0.1.2.tar.gz
  • Upload date:
  • Size: 6.8 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.2.tar.gz
Algorithm Hash digest
SHA256 eef1527402c76e927dfa1091bef1a504690e0ad03fed809cf67bc154e8fe92f8
MD5 1aeced9a11b0abe474fce72f48a769cd
BLAKE2b-256 62faa59e7a07016d2944aa34c39802f693a128a0d05939359c68348be1cb28cb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cashfree_payment-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d19587c9308fb95a7604692fb0d05fe8da6efbcf546e74d6169b94a58100313b
MD5 474138f8557e6e7ca8fd6bf38d799774
BLAKE2b-256 96f2ba1f92a68b3f36f0cbf073ff5cb3cd68e7c5cfc64b11fde7d962cd14b7ba

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