Cybersource
Платёжный провайдер CyberSource для Medusa v2 с Flex Microform (PCI DSS SAQ-A)
Medusa Payment Cybersource for Medusa
CyberSource payment plugin for Medusa.js v2, built on Flex Microform v2 (PCI DSS SAQ-A compliant).
Features
- Flex Microform v2 — card data is tokenized directly at CyberSource; it never touches your server
- Device Fingerprint (ThreatMetrix) — fraud scoring via device profiling before payment
- Authorization + manual capture from the Medusa admin dashboard
- Auto-capture (sale mode) for instant settlement
- Partial and full refunds
- Zero-amount orders — 100% discounts and free orders are handled automatically (no gateway call)
- Admin widget — CyberSource transaction details panel injected into order detail view
Requirements
| Medusa.js | v2 () |
| Node.js | 18+ |
| CyberSource | Business Center account |
Installation
Environment Variables
Add these to your :
Where to find these values: CyberSource Business Center → Account Management → Transaction Security Keys → Security Keys for the HTTP Signature Security Policy
Configuration
In , add the plugin to both (for the API route) and (for the payment provider):
Plugin Options
| Option | Type | Description |
|---|---|---|
| Required. Your CyberSource Merchant ID | ||
| Required. Shared key ID (HTTP Signature) | ||
| Required. Shared secret key (HTTP Signature) | ||
| or . Default: | ||
| Auto-capture on authorization (sale mode). Default: | ||
| Card networks for Flex. Default: |
Payment Flow
Frontend Integration
1. Load Flex Microform
2. Load Device Fingerprint Script
When the user selects CyberSource as payment method, generate a unique session ID and load the ThreatMetrix script. The same ID must be sent in the authorize request.
3. Initialize Flex
4. Tokenize and Pre-authorize
Call this before :
— Request / Response
Request body:
| Field | Required | Description |
|---|---|---|
| Yes | Medusa payment session ID | |
| Yes | JWT from | |
| No | Session ID used in the ThreatMetrix script URL | |
| No | Billing address object for AVS/fraud checks |
Success response (200):
Declined response (402):
Device Fingerprint
The plugin sends and to the CyberSource Payments API. The flag is required so that CyberSource looks up ThreatMetrix using the raw session ID (your UUID) instead of the default composite key — which would cause a mismatch with what the frontend script registered.
You can verify fingerprint collection is working by checking a transaction in CyberSource Business Center. A successful integration shows a hash under Device Fingerprint ID instead of "Not Submitted".
Capture Modes
Manual Capture (default)
CyberSource authorizes the card on order placement. You capture the funds from the Medusa Admin → Orders → Payment panel. Authorization expires in 5–7 days if not captured.
Auto-Capture (sale mode)
Set . CyberSource processes authorization and capture together; the payment is marked as captured immediately on order placement.
Admin Widget
The plugin injects a CyberSource panel into the order detail page of the Medusa admin (). It shows:
| Field | Description |
|---|---|
| Status badge | Derived display status (see table below) |
| Transaction ID | CyberSource authorization ID |
| Capture ID | Only shown if different from Transaction ID (manual capture) |
| Reconciliation ID | CyberSource reconciliation ID |
| Card | Card brand + last 4 digits |
| Last Refund ID | ID of the last refund issued |
| Last Refund Amount | Amount of the last refund |
Status badge logic:
| Condition | Badge |
|---|---|
| is set | 🔵 REFUNDED |
| + set (auto-capture) | 🟢 CAPTURED |
| (no capture ID) | 🟠 AUTHORIZED |
| 🟢 CAPTURED | |
| ⚫ VOIDED | |
| 🔴 DECLINED |
Admin Refund Route
Medusa's default refund UI has a validation that can block refunds in some edge cases. Add this route to your Medusa store for a direct refund bypass:
Create in your Medusa project:
Call it from your admin UI or custom dashboard:
Development
Linking to a local Medusa store with yalc
After any plugin change, re-run in the plugin directory, then fully restart the Medusa server (yalc updates , hot-reload won't pick it up).
CyberSource Resources
- Business Center — sandbox + production portal
- Flex Microform v2 docs
- Payments API reference
- Sandbox test cards
License
MIT

