Pay-Then-Vault
Comprehensive guide to card payment processing patterns including one-time payments, manual capture, 3DS authentication, and recurring payment flows.
Juspay Hyperswitch provides flexible payment processing with multiple flow patterns to accommodate different business needs. The system supports one-time payments, saved payment methods, and recurring billing through a comprehensive API design.
One-Time Payment Patterns
1. Instant Payment (Automatic Capture)
Use Case: Simple, immediate payment processing
Endpoint: POST /payments
Required Fields:
confirm: truecapture_method: "automatic"payment_method
Final Status: succeeded
2. Two-Step Manual Capture
Use Case: Deferred capture (e.g., ship before charging)
Flow:
Authorize:
POST /paymentswithcapture_method: "manual"Status:
requires_captureCapture:
POST /payments/{payment_id}/captureFinal Status:
succeeded
Read more: here
3. Fully Decoupled Flow
Use Case: Complex checkout journeys with multiple modification steps. Useful in headless checkout or B2B portals where data is filled progressively.
Endpoints:
Create:
POST /paymentsUpdate:
POST /payments/{payment_id}Confirm:
POST /payments/{payment_id}/confirmCapture:
POST /payments/{payment_id}/capture(if manual)
4. 3D Secure Authentication Flow
Use Case: Enhanced security with customer authentication
Additional Fields:
authentication_type: "three_ds"
Status Progression: processing → requires_customer_action → succeeded
Read more: here
Recurring Payments and Payment Storage
1. Saving Payment Methods
During Payment Creation:
Add
setup_future_usage: "off_session"or"on_session"Include
customer_idResult:
payment_method_idreturned on success
Understanding setup_future_usage:
on_session: Use when the customer is actively present during the transaction. This is typical for scenarios like saving card details for faster checkouts in subsequent sessions where the customer will still be present to initiate the payment (e.g., card vaulting for e-commerce sites).off_session: Use when you intend to charge the customer later without their active involvement at the time of charge. This is suitable for subscriptions, recurring billing, or merchant-initiated transactions (MITs) where the customer has pre-authorized future charges.
2. Using Saved Payment Methods
Steps:
Initiate: Create payment with
customer_idList: Get saved cards via
GET /customers/payment_methodsConfirm: Use selected
payment_tokenin confirm call
PCI Compliance and payment_method_id
Storing payment_method_id (which is a token representing the actual payment instrument, which could be a payment token, network token, or payment processor token) significantly reduces your PCI DSS scope. Hyperswitch securely stores the sensitive card details and provides you with this token. While you still need to ensure your systems handle payment_method_id and related customer data securely, you avoid the complexities of storing raw card numbers. Always consult with a PCI QSA to understand your specific compliance obligations.
Recurring Payment Flows
3. Customer-Initiated Transaction (CIT) Setup
Read more: here
4. Merchant-Initiated Transaction (MIT) Execution
Read more: here
Status Flow Summary
Notes
Terminal States:
succeeded,failed,cancelled,cancelled_post_capture,partially_captured, andexpiredare terminal states requiring no further action.partially_captured_and_capturableis not terminal: part of the amount is captured and more can be captured (manual_multiple). It becomessucceededonce the captures reach the authorized amount.partially_capturedis the single-capture case, where the remainder can no longer be captured.Capture Methods:
automatic(funds captured immediately),manual(one capture in a separate step),manual_multiple(several partial captures in separate steps), andsequential_automatic(authorization and capture run as sequential operations; effectively the same asautomaticfor most connectors). A fifth value,scheduled, is declared in the API spec but not implemented: payment create and update withcapture_method: scheduledreturn501 Not Implemented. To capture later, usemanualormanual_multiple; see Manual Capture.Authentication: 3DS authentication automatically resumes payment processing after customer completion
MIT Compliance: Off-session recurring payments follow industry standards for merchant-initiated transactions
Refund IDs: Use a distinct
refund_idfor each refund. If a request's outcome is uncertain (a timeout, say), retry with the samerefund_idand check it withGET /refunds/{refund_id}; a newrefund_idcan create a second refund while refundable funds remain. Reusing an existingrefund_idnever creates a second refund. The request is validated like any other first, so it can fail on the refund amount or the refund count; otherwise it is rejected with HTTP 400, codeHE_01("Duplicate refund request. Refund already attempted with the refund ID").
Last updated
Was this helpful?

