Skip to Content
Docs

Sessions and transactions

Understand the difference between SDK-driven sessions and API-driven transactions in Pay.com.

Pay.com separates sessions (checkout interactions that Pay.com.js runs) from transactions (the payment objects that move money). The two show up separately in the dashboard's activity views and in the webhooks you receive.

Sessions

A session represents a customer's checkout interaction managed by Pay.com.js. When you embed Pay.com.js on your frontend, every customer interaction goes through a session. There are three types:

Session typePurposeEndpoint
Payment sessionCollect a payment from the customerPOST /v1/sessions/payment
Setup sessionVerify and save a payment method without chargingPOST /v1/sessions/setup
Tokenization sessionCollect card details and turn them into a card token (tok_card_), without chargingPOST /v1/sessions/tokenization

Your server creates a session via the API and receives a client_secret. You pass the client_secret to Pay.com.js on your frontend, and Pay.com.js renders the checkout UI, handles payment method collection, manages 3D Secure challenges, and processes the payment. On success, a payment session creates an underlying transaction: a charge or a hold.

client_secret is returned only on the initial session creation response. It isn't included in GET /v1/sessions/payment/{id} or list responses. If you lose it or it expires, call POST /v1/sessions/payment/{id}/refresh to get a new one.

To update a session after creation, use PATCH /v1/sessions/payment/{id}. When updating amount, you must include currency in the same request body. Omitting currency returns a 400 error. Use GET /v1/sessions/payment/{id} to check the session status, linked charge, and amount. This endpoint doesn't return client_secret.

Sessions support multiple payment attempts. If a customer's first attempt fails (wrong card, insufficient funds, and so on), the session stays open and the customer can try again with a different payment method. Each failed attempt is recorded as a payment attempt object, but no charge is created until a payment succeeds.

StatusMeaning
openThe session is active. The customer can still attempt to pay.
completedPayment succeeded. The session contains a reference to the created charge or hold.
completed_partiallyThe payment was approved for less than the requested amount.
requires_partial_approval_actionA server-to-server partial approval is waiting for you to confirm or cancel it. See handle partial approvals.
failedThe session reached max_attempts (default 5) declined attempts, or its duration elapsed without a successful payment.
  1. Session created
  2. Payment attempt 1
    • Charge or hold created, Succeeded
      • Session completed
    • Payment attempt 2, Declined
      • Charge or hold created, Succeeded
        • Session completed
      • More attempts, up to max_attempts, Declined
        • failed, Attempts used up or session expired

In this example, the dashboard shows one completed session, one failed payment attempt, and one successful charge.

For step-by-step instructions on taking a payment with Pay.com.js, see Universal checkout and Headless checkout.

Transactions

Transactions are the actual payment objects that move money. They exist whether you use Pay.com.js or the API:

Transaction typeWhat it representsCreated by
ChargeA payment that captures fundsSDK session (on success) or direct API call
HoldAn authorization that reserves fundsSDK session with capture: false or direct API call
RefundA return of funds from a chargeAPI call or dashboard action
PayoutA transfer of funds to a customerAPI call or dashboard action

When you work directly with the Pay.com API (server-to-server), there are no sessions involved. You create transactions directly via endpoints like POST /v1/charges or POST /v1/holds. In this flow, both successful and failed transactions appear as charge or hold objects in your activity log. There's no session wrapper, and there are no payment attempt objects.

For step-by-step instructions on creating a charge via the API, see the Create a charge guide.

Side-by-side comparison

A declined payment ends differently on each path. In a session, the attempt is recorded and the session stays open. With the API, the charge or hold itself fails.

  1. Session created
  2. Payment attempted
    • Charge or hold created, Succeeded
      • Session completed
    • Attempt recorded, session stays open, Declined
AspectSDK path (sessions)API path (direct)
Failed paymentsRecorded as payment attempts. No charge is created.Recorded as failed charges or holds
Multiple retriesHandled automatically within the sessionYou manage retry logic yourself
3D SecureManaged by Pay.com.js automaticallyYou handle the authentication flow via linked authentication sessions
PCI requirementsSAQ-A (Universal checkout) or SAQ-A-EP (Headless checkout, tokenization)Full PCI DSS (SAQ-D) only if sending raw card details
Dashboard viewSessions and Transactions tabsTransactions tab only
Customer experiencePay.com manages the UI, error handling, and retriesYou build and control the entire experience

Dashboard activity

When you open the Activity tab in the Pay.com dashboard, you'll see two sub-tabs for merchants using Pay.com.js: Sessions (showing all payment sessions and setup sessions with their statuses) and Transactions (showing all charges, holds, refunds, and payouts). For API-only merchants, only the Transactions tab is visible, since there are no sessions.

A completed payment session always links to the underlying charge or hold it created. You can navigate between them in the dashboard or retrieve the reference via the API.

Combining SDK and API

You aren't limited to one integration path. Many merchants use both. For example, they use Pay.com.js for the first payment, to collect card details securely and create a stored payment method, then the API with that stored payment method for later or recurring payments.

Both paths share the same token vault, payment methods, and settlement accounts. A payment method created through Pay.com.js can be used in API calls, and the other way around. For more on recurring payment flows, see save a payment method and create recurring charges.

Was this page helpful?