A Python package for seamless integration with CCAvenue payment gateway.
- 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
- This package does not yet support iframe integration with CCAvenue. It currently provides basic encryption and decryption functionality for standard integration.
Install the package using pip:
pip install pay_ccavenue
- Import the CCAvenue class:
from pay_ccavenue import CCAvenue
- 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"
)
- Encrypt payment data:
form_data = {
"order_id": "123456",
"amount": "1000.00",
"currency": "INR",
# Add other required fields
}
encrypted_data = ccavenue.encrypt(form_data)
- Decrypt response data:
response_data = {
"encResp": "ENCRYPTED_RESPONSE_FROM_CCAVENUE"
}
decrypted_data = ccavenue.decrypt(response_data)
Set the following environment variables to configure the package:
CCAVENUE_WORKING_KEY
: Your CCAvenue working keyCCAVENUE_ACCESS_CODE
: Your CCAvenue access codeCCAVENUE_MERCHANT_CODE
: Your CCAvenue merchant codeCCAVENUE_REDIRECT_URL
: URL to redirect after successful paymentCCAVENUE_CANCEL_URL
: URL to redirect after cancelled payment
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"
)
encrypt(data: Dict[str, Any]) -> str
: Encrypts the payment datadecrypt(data: Dict[str, str]) -> Dict[str, str]
: Decrypts the response data
Represents the form data required for CCAvenue payment processing. It includes mandatory and optional fields, and provides methods for data manipulation and validation.
merchant_id
: CCAvenue merchant IDorder_id
: Unique order identifiercurrency
: Payment currency (default: "INR")amount
: Payment amountredirect_url
: URL for successful payment redirectioncancel_url
: URL for cancelled payment redirection
For a complete list of fields, refer to the CCavenueFormData
class documentation.
- 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.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
This package is not officially associated with CCAvenue. Use it at your own risk and ensure compliance with CCAvenue's terms of service.