Amazon Q Developer Rules for MoneyGraph: Fintech Compliance Built-In
How Amazon Q enforces financial compliance when generating MoneyGraph code. Learn about our 6 severity-rated rules for KYC, security, and API patterns.
Amazon Q is the go-to AI coding assistant for enterprise and AWS shops. With MoneyGraph SDK v2.2, Amazon Q now enforces financial compliance rules when generating payment code.
The 6 Compliance Rules
Our .amazonq/rules/moneygraph.md file defines six rules with severity levels:
| Rule # | Name | Severity | What It Enforces |
|---|---|---|---|
| 1 | KYC Before Payout | CRITICAL | Never generate payout code without KYC check |
| 2 | No Hardcoded Secrets | CRITICAL | Always use environment variables for API keys |
| 3 | Quote Before Confirm | HIGH | Enforce Quote → Confirm → Payout flow |
| 4 | Idempotency Keys | HIGH | Add idempotency keys to financial operations |
| 5 | Error Handling | MEDIUM | Proper error handling with MoneyGraph types |
| 6 | Environment Safety | MEDIUM | Guard against production mistakes in dev |
Rule 1: KYC Before Payout (CRITICAL)
Amazon Q will never generate payout code without a KYC check:
// Amazon Q always generates this pattern
const kycStatus = await mg.customers.kyc.canPayout(customerId);
if (!kycStatus.allowed) {
throw new Error(`KYC not approved. Status: ${kycStatus.status}`);
}
// Only then: payoutRule 2: No Hardcoded Secrets (CRITICAL)
Amazon Q enforces environment variable usage:
// ✅ Amazon Q generates
const mg = new MoneyGraph({
apiKey: process.env.MONEYGRAPH_SECRET_KEY
});// ❌ Never generates const mg = new MoneyGraph({ apiKey: 'sk_live_abc123' }); ```
Rule 3: Quote Before Confirm (HIGH)
Amazon Q understands rate locking:
const quote = await mg.fx.quote({ from: 'USD', to: 'NGN', amount: 100 });
await mg.fx.confirm(quote.id); // Lock rate for 2 minutesRule 4: Idempotency Keys (HIGH)
For financial operations, Amazon Q adds idempotency:
await mg.payouts.create(params, {
idempotencyKey: `payout_${orderId}_${Date.now()}`
});Rule 5: Error Handling (MEDIUM)
Amazon Q generates proper error handling with MoneyGraph error types:
import { MoneyGraphValidationError, isRetryableError } from '@moneygraph/sdk';try { await mg.payouts.create(params); } catch (error) { if (error instanceof MoneyGraphValidationError) { console.error('Validation failed:', error.fieldErrors); } if (isRetryableError(error)) { // Retry with backoff } } ```
Rule 6: Environment Safety (MEDIUM)
Amazon Q guards against production mistakes:
if (mg.mode === 'live' && process.env.NODE_ENV !== 'production') {
throw new Error('Live mode detected in non-production environment');
}Why This Matters for Enterprise
In regulated fintech environments, a single compliance gap can mean: - Failed audits - Regulatory fines - Service shutdowns
Amazon Q with MoneyGraph rules ensures every generated line of code meets compliance requirements. Your security team will thank you.
Setup
Installation:
``bash
npm install @moneygraph/sdk
``
How It Works: Amazon Q automatically reads .amazonq/rules/moneygraph.md from your project's node_modules/@moneygraph/sdk folder. No additional configuration needed.
Quick Start Prompt
Ask Amazon Q in your IDE:
Create a Lambda function that processes payouts to Kenya using MoneyGraph SDK.Requirements: - Install @moneygraph/sdk - Check customer KYC status before processing - Get API key from AWS Secrets Manager - Route payments via M-Pesa for mobile money - Handle all error codes (KYC_PENDING, QUOTE_EXPIRED, etc.) - Log transactions to CloudWatch - Return proper status codes
Make sure the code passes all MoneyGraph compliance rules. ```
Amazon Q will generate production-ready, compliant code with proper AWS integrations!
Integration with AWS Services
Amazon Q understands how MoneyGraph fits into AWS architectures:
| AWS Service | Use Case | MoneyGraph Integration |
|---|---|---|
| Lambda | Serverless Functions | Use MoneyGraph in payout functions |
| Step Functions | Workflow Orchestration | Orchestrate KYC → Quote → Payout flows |
| Secrets Manager | Secret Storage | Store MONEYGRAPH_SECRET_KEY securely |
| CloudWatch | Monitoring | Track payout success rates and errors |
| API Gateway | REST APIs | Expose MoneyGraph operations via API |
| SQS | Async Processing | Queue payout requests for processing |
Try It
Prompt: "Create a Lambda function that sends payouts to Kenya via mobile money"
What Amazon Q Generates:
- KYC verification check before payout
- Proper error handling with MoneyGraph error types
- AWS Secrets Manager integration for API keys
- Mobile money routing logic for Kenya (M-Pesa)
- CloudWatch logging for transaction monitoring
Amazon Q automatically applies all 6 compliance rules to ensure production-ready, secure code.
Ready to Get Started?
Install MoneyGraph SDK and start building AI-native payment applications today