@cashfreepayments/agent-skills 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/README.md +214 -0
  2. package/bin/cashfree.js +2 -0
  3. package/dist/config.d.ts +50 -0
  4. package/dist/config.d.ts.map +1 -0
  5. package/dist/config.js +24 -0
  6. package/dist/config.js.map +1 -0
  7. package/dist/generators/index.d.ts +2 -0
  8. package/dist/generators/index.d.ts.map +1 -0
  9. package/dist/generators/index.js +2 -0
  10. package/dist/generators/index.js.map +1 -0
  11. package/dist/generators/utils.d.ts +14 -0
  12. package/dist/generators/utils.d.ts.map +1 -0
  13. package/dist/generators/utils.js +34 -0
  14. package/dist/generators/utils.js.map +1 -0
  15. package/dist/index.d.ts +2 -0
  16. package/dist/index.d.ts.map +1 -0
  17. package/dist/index.js +156 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/templates/crossBorder.d.ts +5 -0
  20. package/dist/templates/crossBorder.d.ts.map +1 -0
  21. package/dist/templates/crossBorder.js +10 -0
  22. package/dist/templates/crossBorder.js.map +1 -0
  23. package/dist/templates/crossBorder.md +264 -0
  24. package/dist/templates/payouts.d.ts +5 -0
  25. package/dist/templates/payouts.d.ts.map +1 -0
  26. package/dist/templates/payouts.js +10 -0
  27. package/dist/templates/payouts.js.map +1 -0
  28. package/dist/templates/payouts.md +332 -0
  29. package/dist/templates/pg.d.ts +5 -0
  30. package/dist/templates/pg.d.ts.map +1 -0
  31. package/dist/templates/pg.js +10 -0
  32. package/dist/templates/pg.js.map +1 -0
  33. package/dist/templates/pg.md +501 -0
  34. package/dist/templates/secure-id.d.ts +5 -0
  35. package/dist/templates/secure-id.d.ts.map +1 -0
  36. package/dist/templates/secure-id.js +10 -0
  37. package/dist/templates/secure-id.js.map +1 -0
  38. package/dist/templates/secure-id.md +215 -0
  39. package/dist/templates/subscriptions.d.ts +5 -0
  40. package/dist/templates/subscriptions.d.ts.map +1 -0
  41. package/dist/templates/subscriptions.js +10 -0
  42. package/dist/templates/subscriptions.js.map +1 -0
  43. package/dist/templates/subscriptions.md +193 -0
  44. package/package.json +49 -0
@@ -0,0 +1,215 @@
1
+ ---
2
+ name: Cashfree Secure ID
3
+ description: Use this to see Secure ID documentation and API references
4
+ ---
5
+
6
+ # Cashfree Secure ID Integration
7
+
8
+ ```markdown
9
+ # Cashfree Secure ID Integration Skills
10
+
11
+ ## Overview
12
+ Cashfree Secure ID is a comprehensive identity verification and fraud prevention suite for the Indian market. It includes bank verification, PAN, GSTIN, Aadhaar, DigiLocker, Video KYC, and biometric verification.
13
+
14
+ ## API Endpoints
15
+ - **Production**: https://api.cashfree.com/verification
16
+ - **Sandbox**: https://sandbox.cashfree.com/verification
17
+
18
+ ## Authentication
19
+ All API requests require headers:
20
+ - `X-Client-Id`: Your client ID from Merchant Dashboard
21
+ - `X-Client-Secret`: Your secret key from Merchant Dashboard
22
+ - `X-Cf-Signature` (optional): Required if 2FA with public key is enabled
23
+
24
+ ## Backend Integration
25
+
26
+ ### 1. Bank Account Verification (Sync)
27
+ POST /bank-account/sync
28
+ ```json
29
+ {
30
+ "bank_account": "026291800001191",
31
+ "ifsc": "YESB0000262",
32
+ "name": "John Doe",
33
+ "phone": "9999999999"
34
+ }
35
+ ```
36
+
37
+ ### 2. PAN Verification
38
+ POST /pan
39
+ ```json
40
+ {
41
+ "pan": "ABCPV1234D",
42
+ "name": "John Doe"
43
+ }
44
+ ```
45
+
46
+ ### 3. GSTIN Verification
47
+ POST /gstin
48
+ ```json
49
+ {
50
+ "GSTIN": "29AAICP2912R1ZR",
51
+ "business_name": "Business Name"
52
+ }
53
+ ```
54
+
55
+ ### 4. Name Match
56
+ POST /name-match
57
+ ```json
58
+ {
59
+ "verification_id": "ABC00123",
60
+ "name_1": "JOHN DOE",
61
+ "name_2": "JOHN DOE"
62
+ }
63
+ ```
64
+
65
+ ### 5. Face Match
66
+ POST /face-match (multipart/form-data)
67
+ - verification_id: string
68
+ - first_image: file
69
+ - second_image: file
70
+ - threshold: "0.75"
71
+
72
+ ### 6. Generate KYC Link
73
+ POST /form
74
+ ```json
75
+ {
76
+ "name": "John Doe",
77
+ "phone": "9999999999",
78
+ "email": "test@cashfree.com",
79
+ "template_name": "Aadhaar_verification",
80
+ "link_expiry": "2025-06-01",
81
+ "notification_types": ["sms"],
82
+ "verification_id": "ABC00123"
83
+ }
84
+ ```
85
+
86
+ ## Webhook Configuration
87
+
88
+ ### Setup
89
+ 1. Log in to Merchant Dashboard > Developers > Webhooks (under Secure ID)
90
+ 2. Add publicly accessible HTTPS webhook URL
91
+ 3. Click "Test & Add Webhook"
92
+
93
+ ### Webhook Events
94
+ - `KYC_LINK_ACTION_PERFORMED`: Verification performed via link
95
+ - `KYC_LINK_SUCCESS`: All verifications completed
96
+ - `KYC_LINK_EXPIRED`: Link expired
97
+ - `RPD_BANK_ACCOUNT_VERIFICATION_SUCCESS/FAILURE/EXPIRED`: Reverse penny drop events
98
+ - `E_SIGN_VERIFICATION_SUCCESS/FAILURE/EXPIRED`: E-sign events
99
+
100
+ ### Webhook Signature Verification (MANDATORY)
101
+ Headers received:
102
+ - `x-webhook-signature`: HMAC-SHA256 signature
103
+ - `x-webhook-timestamp`: Unix timestamp
104
+
105
+ Verification process:
106
+ 1. Concatenate: timestamp + rawBody
107
+ 2. Generate HMAC-SHA256 with client secret
108
+ 3. Base64 encode the hash
109
+ 4. Compare with x-webhook-signature
110
+
111
+ ### Node.js Signature Verification
112
+ ```javascript
113
+ const crypto = require("crypto");
114
+
115
+ function verifyWebhookSignature(req) {
116
+ const ts = req.headers["x-webhook-timestamp"];
117
+ const rawBody = req.rawBody; // Must use raw body, not parsed JSON
118
+ const secretKey = "<client-secret>";
119
+ const signStr = ts + rawBody;
120
+ const computed = crypto.createHmac("sha256", secretKey).update(signStr).digest("base64");
121
+ return computed === req.headers["x-webhook-signature"];
122
+ }
123
+ ```
124
+
125
+ ### Python Signature Verification
126
+ ```python
127
+ import base64, hashlib, hmac
128
+
129
+ def verify_signature(request):
130
+ raw_body = request.data.decode('utf-8')
131
+ timestamp = request.headers['x-webhook-timestamp']
132
+ signature = request.headers['x-webhook-signature']
133
+
134
+ sign_data = timestamp + raw_body
135
+ computed = base64.b64encode(
136
+ hmac.new(b"<client-secret>", sign_data.encode(), hashlib.sha256).digest()
137
+ ).decode()
138
+ return computed == signature
139
+ ```
140
+
141
+ ### IPs to Whitelist
142
+ Sandbox: 52.66.25.127, 15.206.45.168
143
+ Production: 52.66.101.190, 3.109.102.144, 18.60.134.245, 18.60.183.142
144
+ Port: 443 (HTTPS)
145
+
146
+ ## Frontend Integration (DigiLocker React Native SDK)
147
+
148
+ ### Installation
149
+ ```bash
150
+ npm install @cashfreepayments/react-native-digilocker
151
+ # iOS: cd ios && pod install
152
+ ```
153
+
154
+ ### Setup
155
+ ```jsx
156
+ import { DigiLockerProvider, useDigiLocker } from '@cashfreepayments/react-native-digilocker';
157
+
158
+ function App() {
159
+ return (
160
+ <DigiLockerProvider>
161
+ {/* App content */}
162
+ </DigiLockerProvider>
163
+ );
164
+ }
165
+
166
+ // Usage
167
+ const { verify } = useDigiLocker();
168
+ verify(url, redirectUrl, {
169
+ userFlow: 'signin',
170
+ onSuccess: (data) => console.log(data),
171
+ onError: (error) => console.error(error),
172
+ onCancel: () => console.log('cancelled')
173
+ });
174
+ ```
175
+
176
+ ## Test Data (Sandbox Only)
177
+ - OTP for all requests: 111000
178
+ - Valid PAN: ABCPV1234D, AZJPG7110R
179
+ - Valid GSTIN: 29AAICP2912R1ZR
180
+ - Valid Bank Account: 026291800001191 (IFSC: YESB0000262)
181
+ - Valid Aadhaar: 655675523712
182
+
183
+ ## Error Handling
184
+ All APIs return standard error structure:
185
+ ```json
186
+ {
187
+ "code": "error_code",
188
+ "message": "Error description",
189
+ "type": "validation_error"
190
+ }
191
+ ```
192
+
193
+ Common HTTP status codes: 400 (validation), 401/403 (auth), 422 (unprocessable), 429 (rate limit), 500/502 (server)
194
+
195
+ ## Rate Limits
196
+ - Standard APIs: 100 TPM
197
+ - Medium APIs (PAN Sync, DigiLocker): 200 TPM
198
+ - Bulk operations: 5 TPM
199
+
200
+ ## Best Practices
201
+ 1. Always verify webhook signatures before processing
202
+ 2. Use raw request body for signature verification
203
+ 3. Implement idempotency for webhook handlers (duplicates possible)
204
+ 4. Route API calls through backend to avoid CORS errors
205
+ 5. Store client secrets securely, never expose in frontend
206
+ 6. Use oldest active client secret for webhook signature verification
207
+ ```
208
+
209
+ This skills file covers the key Secure ID APIs, webhook setup, signature verification in multiple languages, frontend SDK integration, and test data. For more details, see:
210
+
211
+ ```suggestions
212
+ (Getting Started with Secure ID)[/api-reference/vrs/getting-started]
213
+ (Webhook Signature Verification)[/api-reference/vrs/webhook-signature-verification]
214
+ (Test Data for Integration)[/api-reference/vrs/data-to-test-integration]
215
+ ```
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Subscriptions skill template
3
+ */
4
+ export declare function getSubscriptionsSkillTemplate(): string;
5
+ //# sourceMappingURL=subscriptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscriptions.d.ts","sourceRoot":"","sources":["../../src/templates/subscriptions.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,wBAAgB,6BAA6B,IAAI,MAAM,CAGtD"}
@@ -0,0 +1,10 @@
1
+ import * as fs from "fs";
2
+ import * as path from "path";
3
+ /**
4
+ * Subscriptions skill template
5
+ */
6
+ export function getSubscriptionsSkillTemplate() {
7
+ const templatePath = path.join(__dirname, "subscriptions.md");
8
+ return fs.readFileSync(templatePath, "utf8");
9
+ }
10
+ //# sourceMappingURL=subscriptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscriptions.js","sourceRoot":"","sources":["../../src/templates/subscriptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAI7B;;GAEG;AACH,MAAM,UAAU,6BAA6B;IACzC,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,kBAAkB,CAAC,CAAC;IAC9D,OAAO,EAAE,CAAC,YAAY,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;AACjD,CAAC"}
@@ -0,0 +1,193 @@
1
+ ---
2
+ name: Cashfree Subscriptions
3
+ description: Use this to see Subscriptions documentation and API references
4
+ ---
5
+
6
+ # Cashfree Subscriptions Integration
7
+
8
+ ## Overview
9
+ This skills file covers Cashfree Payments Subscriptions integration including backend APIs, frontend SDKs, and webhook handling for recurring payments.
10
+
11
+ ## Backend Integration
12
+
13
+ ### Step 1: Create a Plan
14
+ ```bash
15
+ curl --request POST \
16
+ --url https://sandbox.cashfree.com/pg/plans \
17
+ --header 'accept: application/json' \
18
+ --header 'content-type: application/json' \
19
+ --header 'x-api-version: 2025-01-01' \
20
+ --header 'x-client-id: YOUR_CLIENT_ID' \
21
+ --header 'x-client-secret: YOUR_CLIENT_SECRET' \
22
+ --data '{
23
+ "plan_id": "plan_premium",
24
+ "plan_name": "Premium Plan",
25
+ "plan_type": "PERIODIC",
26
+ "plan_currency": "INR",
27
+ "plan_max_amount": 1000,
28
+ "plan_recurring_amount": 100,
29
+ "plan_intervals": 1,
30
+ "plan_interval_type": "MONTH"
31
+ }'
32
+ ```
33
+
34
+ ### Step 2: Create a Subscription
35
+ ```bash
36
+ curl --request POST \
37
+ --url https://sandbox.cashfree.com/pg/subscriptions \
38
+ --header 'accept: application/json' \
39
+ --header 'content-type: application/json' \
40
+ --header 'x-api-version: 2025-01-01' \
41
+ --header 'x-client-id: YOUR_CLIENT_ID' \
42
+ --header 'x-client-secret: YOUR_CLIENT_SECRET' \
43
+ --data '{
44
+ "subscription_id": "sub_unique_id",
45
+ "customer_details": {
46
+ "customer_name": "John Doe",
47
+ "customer_email": "john@example.com",
48
+ "customer_phone": "9999999999"
49
+ },
50
+ "plan_details": {
51
+ "plan_id": "plan_premium"
52
+ },
53
+ "authorization_details": {
54
+ "authorization_amount": 1,
55
+ "authorization_amount_refund": true
56
+ },
57
+ "subscription_meta": {
58
+ "return_url": "https://yoursite.com/return",
59
+ "notification_channel": ["EMAIL", "SMS"]
60
+ },
61
+ "subscription_expiry_time": "2028-12-24T14:15:22Z"
62
+ }'
63
+ ```
64
+
65
+ ### Step 3: Get Subscription Status
66
+ ```bash
67
+ curl --request GET \
68
+ --url https://sandbox.cashfree.com/pg/subscriptions/{subscription_id} \
69
+ --header 'x-api-version: 2025-01-01' \
70
+ --header 'x-client-id: YOUR_CLIENT_ID' \
71
+ --header 'x-client-secret: YOUR_CLIENT_SECRET'
72
+ ```
73
+
74
+ ### Step 4: Raise a Charge
75
+ ```bash
76
+ curl --request POST \
77
+ --url https://sandbox.cashfree.com/pg/subscriptions/pay \
78
+ --header 'accept: application/json' \
79
+ --header 'content-type: application/json' \
80
+ --header 'x-api-version: 2025-01-01' \
81
+ --header 'x-client-id: YOUR_CLIENT_ID' \
82
+ --header 'x-client-secret: YOUR_CLIENT_SECRET' \
83
+ --data '{
84
+ "subscription_id": "sub_unique_id",
85
+ "payment_id": "payment_001",
86
+ "payment_type": "CHARGE",
87
+ "payment_amount": 100,
88
+ "payment_schedule_date": "2024-11-30T14:15:22Z"
89
+ }'
90
+ ```
91
+
92
+ ## Frontend Integration (JavaScript)
93
+
94
+ ### Initiate Subscription Checkout
95
+ ```javascript
96
+ const cashfree = Cashfree({
97
+ mode: "sandbox" // or "production"
98
+ });
99
+
100
+ document.getElementById("payButton").addEventListener("click", function() {
101
+ cashfree.subscriptionsCheckout({
102
+ subsSessionId: "subscription_session_id_from_backend",
103
+ redirectTarget: "_blank"
104
+ }).then(function(result) {
105
+ if (result.error) {
106
+ console.error(result.error.message);
107
+ }
108
+ });
109
+ });
110
+ ```
111
+
112
+ ## Webhook Handling
113
+
114
+ ### Webhook Events
115
+ - `SUBSCRIPTION_STATUS_CHANGE` - Subscription status updates (ACTIVE, ON_HOLD, COMPLETED, etc.)
116
+ - `SUBSCRIPTION_AUTH_STATUS` - Authorization completion (success/failed)
117
+ - `SUBSCRIPTION_PAYMENT_SUCCESS` - Successful recurring payment
118
+ - `SUBSCRIPTION_PAYMENT_FAILED` - Failed payment
119
+ - `SUBSCRIPTION_PAYMENT_CANCELLED` - Cancelled payment
120
+ - `SUBSCRIPTION_REFUND_STATUS` - Refund status updates
121
+
122
+ ### Sample Webhook Payload (SUBSCRIPTION_PAYMENT_SUCCESS)
123
+ ```json
124
+ {
125
+ "data": {
126
+ "payment_id": "12345",
127
+ "cf_payment_id": "67890",
128
+ "subscription_id": "sub12345",
129
+ "cf_subscription_id": "sub67890",
130
+ "payment_amount": 200,
131
+ "payment_status": "SUCCESS",
132
+ "authorization_details": {
133
+ "authorization_status": "ACTIVE",
134
+ "payment_method": "upi"
135
+ }
136
+ },
137
+ "event_time": "2024-07-20T11:16:10+05:30",
138
+ "type": "SUBSCRIPTION_PAYMENT_SUCCESS"
139
+ }
140
+ ```
141
+
142
+ ### Webhook Signature Verification
143
+ ```javascript
144
+ const crypto = require('crypto');
145
+
146
+ function verifyWebhookSignature(timestamp, rawBody, signature, secretKey) {
147
+ const signedPayload = timestamp + rawBody;
148
+ const expectedSignature = crypto
149
+ .createHmac('sha256', secretKey)
150
+ .update(signedPayload)
151
+ .digest('base64');
152
+
153
+ return expectedSignature === signature;
154
+ }
155
+
156
+ // Usage in Express.js
157
+ app.post('/webhook', express.raw({type: 'application/json'}), (req, res) => {
158
+ const timestamp = req.headers['x-webhook-timestamp'];
159
+ const signature = req.headers['x-webhook-signature'];
160
+
161
+ if (verifyWebhookSignature(timestamp, req.body.toString(), signature, CLIENT_SECRET)) {
162
+ const event = JSON.parse(req.body);
163
+ // Process webhook based on event.type
164
+ res.status(200).send('OK');
165
+ } else {
166
+ res.status(401).send('Invalid signature');
167
+ }
168
+ });
169
+ ```
170
+
171
+ ## Subscription Lifecycle States
172
+ - **INITIALISED** - Created, awaiting customer authorisation
173
+ - **BANK_APPROVAL_PENDING** - Customer authorised, bank confirmation pending
174
+ - **ACTIVE** - Ready for payment collection
175
+ - **ON_HOLD** - Paused due to failed payment
176
+ - **PAUSED** - Merchant paused the subscription
177
+ - **COMPLETED** - Subscription cycle completed
178
+ - **CANCELLED** - Merchant cancelled
179
+ - **CUSTOMER_CANCELLED** - Customer cancelled at bank
180
+
181
+ ## Environment URLs
182
+ - **Sandbox**: `https://sandbox.cashfree.com`
183
+ - **Production**: `https://api.cashfree.com`
184
+
185
+ ---
186
+
187
+ This covers the complete integration flow from the [Cashfree Hosted Checkout](/payments/subscription/hosted-checkout), [Subscription Webhooks](/api-reference/payments/previous/v2023-08-01/subscription/webhooks), and [Create Subscription](/payments/subscription/create) documentation pages.
188
+
189
+ ```suggestions
190
+ (Subscription Introduction)[/payments/subscription/introduction]
191
+ (Cashfree Hosted Checkout)[/payments/subscription/hosted-checkout]
192
+ (Subscription Webhooks)[/api-reference/payments/previous/v2023-08-01/subscription/webhooks]
193
+ ```
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@cashfreepayments/agent-skills",
3
+ "version": "0.0.1",
4
+ "description": "CLI tool to add Cashfree MCP configurations to AI coding assistants",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "bin": {
8
+ "cashfree": "./bin/cashfree.js"
9
+ },
10
+ "scripts": {
11
+ "build": "tsc && npm run copy-templates",
12
+ "copy-templates": "node -e \"require('fs-extra').copySync('src/templates', 'dist/templates', { filter: (src) => src.endsWith('.md') || src === 'src/templates' })\"",
13
+ "dev": "tsc -w",
14
+ "test": "vitest",
15
+ "prepublishOnly": "npm run build"
16
+ },
17
+ "keywords": [
18
+ "cashfree",
19
+ "mcp",
20
+ "model-context-protocol",
21
+ "cli",
22
+ "cursor",
23
+ "claude-code",
24
+ "copilot",
25
+ "ai-coding"
26
+ ],
27
+ "author": "Cashfree Payments",
28
+ "license": "MIT",
29
+ "dependencies": {
30
+ "chalk": "^5.3.0",
31
+ "commander": "^12.1.0",
32
+ "fs-extra": "^11.2.0",
33
+ "inquirer": "^9.2.15"
34
+ },
35
+ "devDependencies": {
36
+ "@types/fs-extra": "^11.0.4",
37
+ "@types/inquirer": "^9.0.7",
38
+ "@types/node": "^20.11.0",
39
+ "typescript": "^5.3.3",
40
+ "vitest": "^1.2.0"
41
+ },
42
+ "engines": {
43
+ "node": ">=18.0.0"
44
+ },
45
+ "files": [
46
+ "dist",
47
+ "bin"
48
+ ]
49
+ }