Skip to main content

pay_ccavenue

A Python package for seamless integration with CCAvenue payment gateway.

Features

  • Easy-to-use API for CCAvenue integration
  • Secure encryption and decryption of payment data
  • Flexible configuration via environment variables or direct instantiation
  • Type hints for better code reliability

Current Limitations

  • This package does not yet support iframe integration with CCAvenue. It currently provides basic encryption and decryption functionality for standard integration.

Installation

Install the package using pip:

pip install pay_ccavenue

Quick Start

  1. Import the CCAvenue class:
from pay_ccavenue import CCAvenue
  1. Initialize the CCAvenue object:
# Using environment variables
ccavenue = CCAvenue()

# Or, passing credentials directly
ccavenue = CCAvenue(
    working_key="YOUR_WORKING_KEY",
    access_code="YOUR_ACCESS_CODE",
    merchant_code="YOUR_MERCHANT_CODE",
    redirect_url="YOUR_REDIRECT_URL",
    cancel_url="YOUR_CANCEL_URL"
)
  1. Encrypt payment data:
form_data = {
    "order_id": "123456",
    "amount": "1000.00",
    "currency": "INR",
    # Add other required fields
}

encrypted_data = ccavenue.encrypt(form_data)
  1. Decrypt response data:
response_data = {
    "encResp": "ENCRYPTED_RESPONSE_FROM_CCAVENUE"
}

decrypted_data = ccavenue.decrypt(response_data)
  1. Handle Webhook/Notification:
# In your webhook endpoint
webhook_payload = request.form  # Get the POST data
webhook_data = ccavenue.process_webhook(webhook_payload)

if webhook_data.order_status == "Success":
    print(f"Order {webhook_data.order_id} was successful")
    print(f"Tracking ID: {webhook_data.tracking_id}")
    print(f"Bank Ref: {webhook_data.bank_ref_no}")
elif webhook_data.risk_status == "High":
    print(f"Warning: High risk transaction {webhook_data.tracking_id}")
    print(f"Reason: {webhook_data.risk_reason}")

Configuration

Environment Variables

Set the following environment variables to configure the package:

  • CCAVENUE_WORKING_KEY: Your CCAvenue working key
  • CCAVENUE_ACCESS_CODE: Your CCAvenue access code
  • CCAVENUE_MERCHANT_CODE: Your CCAvenue merchant code
  • CCAVENUE_REDIRECT_URL: URL to redirect after successful payment
  • CCAVENUE_CANCEL_URL: URL to redirect after cancelled payment

Direct Instantiation

Pass the configuration parameters directly when creating the CCAvenue object:

ccavenue = CCAvenue(
    working_key="YOUR_WORKING_KEY",
    access_code="YOUR_ACCESS_CODE",
    merchant_code="YOUR_MERCHANT_CODE",
    redirect_url="YOUR_REDIRECT_URL",
    cancel_url="YOUR_CANCEL_URL"
)

API Reference

CCAvenue Class

Methods

  • encrypt(data: Dict[str, Any]) -> str: Encrypts the payment data
  • decrypt(data: Dict[str, str]) -> Dict[str, str]: Decrypts the response data
  • process_webhook(response_body: Dict[str, str]) -> CCavenueWebhookData: Decrypts and processes webhook data

CCavenueFormData Class

Represents the form data required for CCAvenue payment processing. It includes mandatory and optional fields, and provides methods for data manipulation and validation.

Important Fields

  • merchant_id: CCAvenue merchant ID
  • order_id: Unique order identifier
  • currency: Payment currency (default: "INR")
  • amount: Payment amount
  • redirect_url: URL for successful payment redirection
  • cancel_url: URL for cancelled payment redirection

For a complete list of fields, refer to the CCavenueFormData class documentation.

Security Considerations

  • The package uses AES encryption with CBC mode for secure communication with CCAvenue.
  • Ensure that your working key and other sensitive information are kept secure and not exposed in your codebase.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Disclaimer

This package is not officially associated with CCAvenue. Use it at your own risk and ensure compliance with CCAvenue's terms of service.

Metadata

Release files for pay_ccavenue 1.1.0

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

Source distribution (sdist)

Source distribution for pay_ccavenue 1.1.0
File Size Uploaded
pay_ccavenue-1.1.0.tar.gz 6.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pay_ccavenue 1.1.0
File Interpreter ABI Platform
pay_ccavenue-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 15.6 kB

Release files / pay_ccavenue-1.1.0.tar.gz

Download URL pay_ccavenue-1.1.0.tar.gz
Size 6.6 kB
Tags Source
SHA-256 checksum
How to use checksums
661eb89f3721fcc4a2a2cb58ec1144649f3c9688d5ba68c127b3ee876f41c543
BLAKE2b-256 checksum
How to use checksums
aeda01643d92e11821e0d2dbfa449109c6e62a7889699a26042dcfb6f4892e4b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.3.1 CPython/3.12.1 Linux/6.11.0-1018-azure

Release files / pay_ccavenue-1.1.0-py3-none-any.whl

Download URL pay_ccavenue-1.1.0-py3-none-any.whl
Size 9.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b64dfb8ab0dbc3036bc9656c3b17bece8d93d1044f01df6a95ac6bc7e7f4c5a6
BLAKE2b-256 checksum
How to use checksums
737bcfb825cf17b2ab6415de67207cf146b4793c05028062497ead53131c9a0d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.3.1 CPython/3.12.1 Linux/6.11.0-1018-azure

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.0

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

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