Skip to content

Commit 183c516

Browse files
authored
Merge pull request #2 from kdpisda/major-1.0.0
Major 1.0.0
2 parents 2378adb + e9b5647 commit 183c516

16 files changed

Lines changed: 874 additions & 579 deletions
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: '[BUG] '
5+
labels: 'bug'
6+
assignees: ''
7+
8+
---
9+
10+
**Describe the bug**
11+
A clear and concise description of what the bug is.
12+
13+
**To Reproduce**
14+
Steps to reproduce the behavior:
15+
1. Go to '...'
16+
2. Click on '....'
17+
3. Scroll down to '....'
18+
4. See error
19+
20+
**Expected behavior**
21+
A clear and concise description of what you expected to happen.
22+
23+
**Screenshots**
24+
If applicable, add screenshots to help explain your problem.
25+
26+
**Environment (please complete the following information):**
27+
- OS: [e.g. iOS]
28+
- Python version: [e.g. 3.8]
29+
- pay_ccavenue version: [e.g. 1.0.0]
30+
31+
**Additional context**
32+
Add any other context about the problem here.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: '[FEATURE] '
5+
labels: 'enhancement'
6+
assignees: ''
7+
8+
---
9+
10+
**Is your feature request related to a problem? Please describe.**
11+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12+
13+
**Describe the solution you'd like**
14+
A clear and concise description of what you want to happen.
15+
16+
**Describe alternatives you've considered**
17+
A clear and concise description of any alternative solutions or features you've considered.
18+
19+
**Additional context**
20+
Add any other context or screenshots about the feature request here.

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
## Description
2+
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context.
3+
4+
Fixes # (issue)
5+
6+
## Type of change
7+
Please delete options that are not relevant.
8+
9+
- [ ] Bug fix (non-breaking change which fixes an issue)
10+
- [ ] New feature (non-breaking change which adds functionality)
11+
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
12+
- [ ] This change requires a documentation update
13+
14+
## How Has This Been Tested?
15+
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration.
16+
17+
- [ ] Test A
18+
- [ ] Test B
19+
20+
## Checklist:
21+
- [ ] My code follows the style guidelines of this project
22+
- [ ] I have performed a self-review of my own code
23+
- [ ] I have commented my code, particularly in hard-to-understand areas
24+
- [ ] I have made corresponding changes to the documentation
25+
- [ ] My changes generate no new warnings
26+
- [ ] I have added tests that prove my fix is effective or that my feature works
27+
- [ ] New and existing unit tests pass locally with my changes
28+
- [ ] Any dependent changes have been merged and published in downstream modules

.pre-commit-config.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
repos:
22
- repo: https://github.com/asottile/pyupgrade
3-
rev: v2.29.0
3+
rev: v3.15.0
44
hooks:
55
- id: pyupgrade
66
args: ["--py36-plus"]
77
- repo: https://github.com/asottile/reorder_python_imports
8-
rev: v2.6.0
8+
rev: v3.12.0
99
hooks:
1010
- id: reorder-python-imports
1111
- repo: https://github.com/psf/black
12-
rev: 21.10b0
12+
rev: 23.9.1
1313
hooks:
1414
- id: black
1515
- repo: https://github.com/PyCQA/flake8
16-
rev: 4.0.1
16+
rev: 6.1.0
1717
hooks:
1818
- id: flake8
1919
additional_dependencies:
2020
- flake8-bugbear
2121
- flake8-implicit-str-concat
2222
args: [--max-line-length=90]
2323
- repo: https://github.com/pre-commit/pre-commit-hooks
24-
rev: v4.0.1
24+
rev: v4.4.0
2525
hooks:
2626
- id: fix-byte-order-marker
2727
- id: trailing-whitespace

README.md

Lines changed: 98 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,136 @@
11
# pay_ccavenue
22

3-
A simple package to integrate CCAvenue. It can be used for both `iframe` and `seemless` methods.
3+
A Python package for seamless integration with CCAvenue payment gateway.
44

5-
## How to install
5+
## Features
6+
7+
- Easy-to-use API for CCAvenue integration
8+
- Secure encryption and decryption of payment data
9+
- Flexible configuration via environment variables or direct instantiation
10+
- Type hints for better code reliability
11+
12+
## Current Limitations
13+
14+
- This package does not yet support iframe integration with CCAvenue. It currently provides basic encryption and decryption functionality for standard integration.
15+
16+
## Installation
17+
18+
Install the package using pip:
619

720
```bash
821
pip install pay_ccavenue
922
```
1023

11-
## Import
24+
## Quick Start
25+
26+
1. Import the CCAvenue class:
1227

1328
```python
1429
from pay_ccavenue import CCAvenue
1530
```
1631

17-
## Initialize the Package
18-
19-
We can either setup via the environment or by passing the credentials directly to the plugin.
32+
2. Initialize the CCAvenue object:
2033

21-
### Via the environment variables
22-
23-
Set the credentials in the environment variables
34+
```python
35+
# Using environment variables
36+
ccavenue = CCAvenue()
2437

25-
- Set `CCAVENUE_WORKING_KEY` for the `WORKING_KEY`
26-
- Set `CCAVENUE_ACCESS_CODE` for the `ACCESS_CODE`
27-
- Set `CCAVENUE_MERCHANT_CODE` for the `MERCHANT_CODE`
28-
- Set `CCAVENUE_REDIRECT_URL` for the `REDIRECT_URL`
29-
- Set `CCAVENUE_CANCEL_URL` for the `CANCEL_URL`
38+
# Or, passing credentials directly
39+
ccavenue = CCAvenue(
40+
working_key="YOUR_WORKING_KEY",
41+
access_code="YOUR_ACCESS_CODE",
42+
merchant_code="YOUR_MERCHANT_CODE",
43+
redirect_url="YOUR_REDIRECT_URL",
44+
cancel_url="YOUR_CANCEL_URL"
45+
)
46+
```
3047

31-
And then instantiate the `CCAvenue` object as shown below
48+
3. Encrypt payment data:
3249

3350
```python
34-
ccavenue = CCAvenue()
51+
form_data = {
52+
"order_id": "123456",
53+
"amount": "1000.00",
54+
"currency": "INR",
55+
# Add other required fields
56+
}
57+
58+
encrypted_data = ccavenue.encrypt(form_data)
3559
```
3660

37-
### Pasing the credentials directly
61+
4. Decrypt response data:
3862

3963
```python
40-
ccavenue = CCAvenue(WORKING_KEY, ACCESS_CODE, MERCHANT_CODE, REDIRECT_URL, CANCEL_URL)
64+
response_data = {
65+
"encResp": "ENCRYPTED_RESPONSE_FROM_CCAVENUE"
66+
}
67+
68+
decrypted_data = ccavenue.decrypt(response_data)
4169
```
4270

43-
---
71+
## Configuration
4472

45-
**NOTE**
73+
### Environment Variables
4674

47-
You don't need to explicitely pass `WORKING_KEY`, `ACCESS_CODE`, `MERCHANT_CODE`, `REDIRECT_URL`, `CANCEL_URL` in the form data for any of the method i.e. `Iframe` or `seemless`.
75+
Set the following environment variables to configure the package:
4876

49-
---
77+
- `CCAVENUE_WORKING_KEY`: Your CCAvenue working key
78+
- `CCAVENUE_ACCESS_CODE`: Your CCAvenue access code
79+
- `CCAVENUE_MERCHANT_CODE`: Your CCAvenue merchant code
80+
- `CCAVENUE_REDIRECT_URL`: URL to redirect after successful payment
81+
- `CCAVENUE_CANCEL_URL`: URL to redirect after cancelled payment
5082

51-
## To encrypt the data
83+
### Direct Instantiation
5284

53-
`form_data` is the post request body which is a dictionary of the related data for the payment. You don't need to pass the Merchant ID though. Since we have already intiated the package with the correct `MERCHANT_CODE`. `encrypt()` method return the encrypted string that can be ussed directly in the Iframe rendering.
85+
Pass the configuration parameters directly when creating the CCAvenue object:
5486

5587
```python
56-
encrypt_data = ccavenue.encrypt(form_data)
88+
ccavenue = CCAvenue(
89+
working_key="YOUR_WORKING_KEY",
90+
access_code="YOUR_ACCESS_CODE",
91+
merchant_code="YOUR_MERCHANT_CODE",
92+
redirect_url="YOUR_REDIRECT_URL",
93+
cancel_url="YOUR_CANCEL_URL"
94+
)
5795
```
5896

59-
Pass the `encrypt_data` from the above to the view to render the IFrame.
97+
## API Reference
6098

61-
## Decrypt the data received from the CCAvenue
99+
### `CCAvenue` Class
62100

63-
`form_data` is the post request body which is a dictionary of the related data received from the CCAvenue. The `decrypt()` method returns the dictionary of the data received from the CCAvenue.
101+
#### Methods
64102

65-
```python
66-
decrypted_data = ccavenue.decrypt(form_data)
67-
```
103+
- `encrypt(data: Dict[str, Any]) -> str`: Encrypts the payment data
104+
- `decrypt(data: Dict[str, str]) -> Dict[str, str]`: Decrypts the response data
105+
106+
### `CCavenueFormData` Class
107+
108+
Represents the form data required for CCAvenue payment processing. It includes mandatory and optional fields, and provides methods for data manipulation and validation.
109+
110+
#### Important Fields
111+
112+
- `merchant_id`: CCAvenue merchant ID
113+
- `order_id`: Unique order identifier
114+
- `currency`: Payment currency (default: "INR")
115+
- `amount`: Payment amount
116+
- `redirect_url`: URL for successful payment redirection
117+
- `cancel_url`: URL for cancelled payment redirection
118+
119+
For a complete list of fields, refer to the `CCavenueFormData` class documentation.
120+
121+
## Security Considerations
122+
123+
- The package uses AES encryption with CBC mode for secure communication with CCAvenue.
124+
- Ensure that your working key and other sensitive information are kept secure and not exposed in your codebase.
125+
126+
## Contributing
127+
128+
Contributions are welcome! Please feel free to submit a Pull Request.
129+
130+
## License
131+
132+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
68133

69-
# Limitations
134+
## Disclaimer
70135

71-
1. I have not added any tests as of now in the package, but I have tested this out for my project after debugging their given examples and Stackoverflow to simplify it.
72-
2. More detailed documentation.
136+
This package is not officially associated with CCAvenue. Use it at your own risk and ensure compliance with CCAvenue's terms of service.

0 commit comments

Comments
 (0)