Payment Intent and Payment Attempt

Core Concepts

Overview

Payment Intent (PI) and Payment Attempt (PA) are the fundamental building blocks of UQPAY's acquiring system. Understanding these concepts is essential for successful integration and payment processing.

Payment Intent (PI)

A Payment Intent represents a customer's intention to make a payment. It serves as the primary container for payment-related information and maintains the overall payment state throughout the transaction lifecycle. It represents a complete collection intent, regardless of whether the collection ultimately succeeds or fails.

Key Characteristics

  • Unique Identifier: Each PI has a unique ID with the prefix PI (e.g., PI1234567890123456789)
  • Order Information: Contains essential order details such as amount, currency, and merchant reference
  • Expiration: Automatically expires after 30 minutes if not completed
  • Persistence: Once created, it continues to exist and can be used for multiple payment attempts
  • Idempotency: Ensures each transaction is only charged once
  • State Tracking: Maintains a complete record of state changes throughout the entire payment process

PaymentIntent Status Reference

StatusDescriptionNext ActionsPhaseWebhook Event
REQUIRES_PAYMENT_METHODInitial state after creation or after failed payment attempt. Waiting for confirm request with payment method.Confirm with payment methodInitialacquiring.payment_intent.created
REQUIRES_CUSTOMER_ACTIONWaiting for customer to complete authentication (3DS verification, QR code scan, etc.). Check next_action for specific instructions.Awaiting the customer to complete the operation specified in the next_action field.Customer Interactionacquiring.payment_intent.requires_action
REQUIRES_CAPTUREAuthorization successful, waiting for capture to complete payment. Funds are authorized but not yet settled.Call capture API (not available yet) to complete full or partial amount paymentAuthorization Complete-
PENDINGProcessing payment with payment provider. No further action required.Wait for resultProcessing-
SUCCEEDEDPayment completed successfully. Transaction is finished.No further action neededFinal state - SUCCEEDEDacquiring.payment_intent.succeeded
CANCELLEDPayment cancelled by merchant request. Payment is closed.No further action neededFinal state - CANCELLEDacquiring.cancel.succeeded
FAILEDPayment failed due to error or system timeout (30 minutes).No further action neededFinal state - FAILEDacquiring.payment_intent.failed

Payment Attempt (PA)

A Payment Attempt represents a specific attempt to process a payment within a Payment Intent. Each PA contains the payment method details and processing results for that specific attempt.

Key Characteristics

  • Unique Identifier: Each PA has a unique ID with the prefix PA (e.g., PA1234567890123456789)
  • Temporary Nature: Represents a single specific payment attempt
  • Retry Capability: Failed attempt can be retried by creating a new payment attempt for the same Payment Intent
  • Detailed Information: Contains specific payment details such as payment method used, error information, etc.

PaymentAttempt Status Reference

StatusDescriptionPhaseWebhook Event
INITIATEDThe payment attempt has been created based on the initial request.Initialacquiring.payment_attempt.created
AUTHENTICATION_REDIRECTEDWaiting for customer to complete authentication (3DS verification, QR code scan, etc.).Customer Interaction-
PENDING_AUTHORIZATIONAuthorization request accepted, waiting for payment provider's final result.Processing-
AUTHORIZEDAuthorization successful. Payment will be captured automatically or manually.Authorization Complete-
CAPTURE_REQUESTEDCapture request submitted successfully. Payment is considered complete.Captureacquiring.payment_attempt.capture_requested
SETTLEDUQPAY has received settlement from payment provider.Settlement-
SUCCEEDEDUQPAY has settled funds to your wallet.Final state - SUCCEEDED-
CANCELLEDThe payment attempt has been cancelled. Any authorized funds, if applicable, will be returned to the customer.Final state - CANCELLEDacquiring.payment_attempt.cancelled
EXPIREDThe payment attempt was not completed within the allowed time window and has expired.Final state - EXPIREDacquiring.payment_attempt.cancelled(it's not a typo)
FAILEDPayment attempt failed.Final state - FAILEDacquiring.payment_attempt.failed

API Flow - Payment Sequence Diagram

Overview

This diagram illustrates the complete payment flow including both direct payment and delayed confirmation payment modes, with API calls, webhooks, and state transitions.

The payment flow supports two modes to accommodate different merchant integration scenarios:

  • Direct Payment: Suitable for scenarios where payment method information is available at order creation time
  • Delayed Confirmation: Ideal for scenarios where payment method selection happens after order creation, allowing for order modifications before payment confirmation

Sequence Diagram

sequenceDiagram
    participant Consumer as Consumer
    participant Merchant as Merchant System
    participant UQPAY as UQPAY System

    Note over Consumer,UQPAY: Direct Payment Mode
    Consumer->>Merchant: Place order with payment method info
    Merchant->>UQPAY: Create a PaymentIntent (with payment_method)
    UQPAY-->>Merchant: acquiring.payment_intent.created
    UQPAY-->>Merchant: acquiring.payment_attempt.created
    
    alt Payment Success
        UQPAY->>UQPAY: Process payment
        Note right of UQPAY: PA: CAPTURE_REQUESTED<br/>PI: SUCCEEDED
        UQPAY-->>Merchant: acquiring.payment_intent.succeeded
        UQPAY-->>Merchant: acquiring.payment_attempt.capture_requested
        Merchant->>Consumer: Payment successful
    else Payment Failed
        UQPAY->>UQPAY: Process payment
        Note right of UQPAY: PA: FAILED<br/>PI: REQUIRES_PAYMENT_METHOD
        UQPAY-->>Merchant: acquiring.payment_attempt.failed
        Merchant->>Consumer: Payment failed
    end

    Note over Consumer,UQPAY: Delayed Confirmation Payment Mode
    Consumer->>Merchant: Place order only (no payment method info)
    Merchant->>UQPAY: Create a PaymentIntent (without payment_method)
    Note right of UQPAY: PI: REQUIRES_PAYMENT_METHOD
    UQPAY-->>Merchant: acquiring.payment_intent.created
    
    Note over Merchant,UQPAY: Optional: Update order information
    Merchant->>UQPAY: Update a PaymentIntent (amount, currency, etc.)
    UQPAY->>Merchant: PaymentIntent updated
    
    Consumer->>Merchant: Select payment method & enter details
    Merchant->>UQPAY: Confirm a PaymentIntent
    Note right of UQPAY: PA: INITIATED
    UQPAY-->>Merchant: acquiring.payment_attempt.created
    
    alt Payment Success
        UQPAY->>UQPAY: Process payment
        Note right of UQPAY: PA: CAPTURE_REQUESTED<br/>PI: SUCCEEDED
        UQPAY-->>Merchant: acquiring.payment_intent.succeeded
        UQPAY-->>Merchant: acquiring.payment_attempt.capture_requested
        Merchant->>Consumer: Payment successful
    else Payment Failed
        UQPAY->>UQPAY: Process payment
        Note right of UQPAY: PA: FAILED<br/>PI: REQUIRES_PAYMENT_METHOD
        UQPAY-->>Merchant: acquiring.payment_attempt.failed
        Merchant->>Consumer: Payment failed
    end

    Note over Consumer,UQPAY: Cancellation Scenarios
    alt System Auto-Close (30min timeout)
        UQPAY->>UQPAY: Auto-close expired PI
        Note right of UQPAY: PI: FAILED
        UQPAY-->>Merchant: acquiring.payment_intent.failed
    else Merchant Initiated Cancel
        Merchant->>UQPAY: Cancel a PaymentIntent
        UQPAY->>UQPAY: Cancel payment
        Note right of UQPAY: PA: CANCELLED<br/>PI: CANCELLED
        UQPAY-->>Merchant: acquiring.cancel.succeeded
        UQPAY-->>Merchant: acquiring.payment_attempt.cancelled
    end