/generate-mapping-for-psp
Create a PSP mapping file by researching a payment processor's API and building a complete JSON mapping.
Usage
/generate-mapping-for-psp [psp-name]
If psp-name is not provided, ask the user which PSP they want to map.
Process
Step 1: Research the PSP
Use web search to find the PSP's API documentation. Search for:
- •
{psp-name} payments API documentation— Find the main API reference - •
{psp-name} API authentication— How to authenticate (API key, bearer token, etc.) - •
{psp-name} payment request fields— Request body for creating a payment - •
{psp-name} error codes decline codes— Full list of error/refusal codes - •
{psp-name} 3D Secure API— How 3DS data is sent and received - •
{psp-name} network token payment— How network tokens (DPAN + cryptogram) are formatted - •
{psp-name} stored payment method token— How to use previously saved cards - •
{psp-name} capture refund void API— Capture, refund, and cancel endpoints - •
{psp-name} recurring payment types— Card-on-file, subscription, unscheduled flags - •
{psp-name} idempotency key header— What header name is used for idempotency - •
{psp-name} API content type encoding— Whether the API uses JSON or form-encoded requests - •
{psp-name} auto capture default behavior— Whether payments are captured automatically by default
Step 2: Confirm with User
Present a summary of what was found:
- •Base URLs (test + production)
- •Authentication method
- •API version
- •Content type (JSON vs form-encoded)
- •Idempotency header name
- •Auto-capture default behavior (does authorize auto-capture?)
- •Refund endpoint pattern (sub-resource of payment vs top-level resource)
- •Status casing (does casing vary across endpoints?)
- •Key differences from existing PSPs (Adyen/Checkout.com)
- •Any gaps in documentation found
Ask the user to confirm before proceeding, and whether they have any additional context (e.g., specific API docs pages, Notion content, or integration guides).
Step 3: Load References
Read these files to understand the schema and conventions:
schema/psp-mapping.schema.json # The schema the mapping must validate against mappings/adyen.json # Reference mapping (complex PSP) mappings/checkout.json # Reference mapping (different patterns) docs/source-types.md # How to map the 5 source types
Step 4: Build the Mapping
Build the mapping file section by section:
- •
psp— Name, display name, base URLs, API version, docs URL, content type, idempotency header - •
authentication— Type, header, config fields with env var suggestions - •
source_types— This is the most important section. For each of the 5 source types:- •
raw_pan: Map card fields to PSP's request format - •
basis_theory_token: Same fields but with{{ token: ... }}expression syntax - •
basis_theory_token_intent: Same but with{{ token_intent: ... }}prefix - •
network_token: Map DPAN + cryptogram to PSP-specific fields (this varies significantly between PSPs) - •
processor_token: Map the PSP's stored payment method ID
- •
- •
operations— Map each operation (authorize, capture, get, confirm, refund, cancel) with request and response field mappings - •
status_mappings— Map every PSP status to a unified status - •
error_mappings— Group all PSP error codes by unified error category - •
amount_format— Minor units vs major units, special currencies - •
recurring— Map recurring types (card_on_file, subscription, unscheduled) - •
three_ds— Map 3DS request and response fields - •
setup— Onboarding steps, required and optional env vars
Step 5: Validate and Write
- •Write the mapping to
mappings/{psp-name}.json - •Validate the file is well-formed JSON
- •Check key sections are populated (source_types has all 5, operations has authorize at minimum)
- •Present a summary to the user
Key Rules
- •Every mapping MUST have all 5 source types, even if the PSP doesn't natively support all of them. Document limitations in comments.
- •Use existing mappings (adyen.json, checkout.json, stripe.json) as the gold standard for conventions.
- •The
request_transformin source types uses dot-notation keys and{{placeholder}}values. - •Error mappings group PSP codes BY unified category (not 1:1 mapping).
- •Status mappings are a flat PSP-status-string to unified-status lookup.
- •The
$schemafield should always be"../schema/psp-mapping.schema.json". - •Network token format varies significantly between PSPs — research this carefully.
- •For Basis Theory proxy transforms, the expression syntax is
{{ token: {id} | json: '$.data.{field}' }}.
Key Gotchas (Learned from Real Integrations)
These are common pitfalls discovered during real PSP integrations. Research each one explicitly:
- •
Status casing varies across endpoints — Some PSPs (e.g., Adyen) return PascalCase from the authorize endpoint (
Received,Pending) but lowercase from capture/refund/cancel endpoints (received,pending). Include both casing variants instatus_mappings. - •
Auto-capture behavior — Some PSPs (e.g., Checkout.com) auto-capture payments by default. If the PSP auto-captures, add
{ "from": "$unified.capture", "to": "{psp_capture_field}", "default": false }to the authorizerequest_mapping. - •
Content type encoding — Most PSPs use JSON, but some (e.g., Stripe) use
application/x-www-form-urlencoded. This requires the SDK to flatten nested objects to bracket notation (e.g.,source[type]=card). Setpsp.content_typecorrectly. - •
Idempotency header name — PSPs use different header names. Set
psp.idempotency_header(e.g.,Idempotency-Keyfor Stripe/Adyen,Cko-Idempotency-Keyfor Checkout.com). - •
Refund as top-level resource — Some PSPs (e.g., Stripe) don't use a sub-resource pattern for refunds. Stripe uses
POST /v1/refundswith the payment ID in the body, notPOST /payments/{id}/refunds. Theoperations.refund.pathmust reflect this. - •
Customer field restrictions — Some PSPs (e.g., Stripe) expect their own customer IDs (e.g.,
cus_xxx) in the customer field, not freeform strings. Document this in the mapping. - •
Default values for required fields — Some PSPs require fields that have a "right default" for the common case. For example, Stripe needs
payment_method_types: ["card"]to avoid requiring areturn_url, andconfirm: true+capture_method: manualfor authorize-only. Use thedefaultfield inrequest_mappingentries.
Example Interaction
User: /generate-mapping-for-psp stripe Claude: I'll research Stripe's Payments API to build a mapping file. [researches Stripe's API docs, error codes, 3DS, network tokens...] Here's what I found about Stripe: - Base URL: https://api.stripe.com (same for test/live, key determines environment) - Auth: Bearer token via Authorization header - API version: 2024-12-18 (set via Stripe-Version header) - Amount: Minor units (cents) - Key difference: Stripe uses form-encoded requests, not JSON Should I proceed with building the mapping? Do you have any additional context? User: Yes, proceed. We use their PaymentIntents API. Claude: [builds mapping section by section, writes to mappings/stripe.json]