HSRCPAY Documentation

Business Flow - Payments & Charges

Understand Payment and Charge separation, routing/fallback attempt model, and the business flow of payment operations.

This page explains the high-level map of payment flows and HSRC Pay Payment/Charge domain separation.

Payment is the merchant business goal; Charge is the attempt at provider level. This split makes routing, fallback, retry, capture, refund, void, reporting, and webhook behavior easier to understand.

What is a payment flow?

A payment flow is not only calling endpoints; it is state, provider behavior, risk, routing, and event discipline.

HSRC Pay typically follows:

  1. Payment is created.
  2. Payment Method is selected or collected inside Checkout Session.
  3. Confirm starts execution.
  4. Routing produces provider candidates.
  5. Orchestrator calls provider adapter pay for the selected candidate.
  6. Charge attempt is created.
  7. Result is converted to normalized result model.
  8. Payment state is updated.
  9. Event/webhook is sent to the merchant system.

What is a Payment?

Payment is the merchant payment intent or business record for collecting from a customer. It may correspond to an order, subscription, invoice, or checkout transaction.

Payment carries:

  • Amount and currency
  • Customer or checkout session context
  • Metadata
  • Secure mode and capture preference
  • Overall lifecycle state

Payment is the main payment record the merchant system should see.

What is a Charge?

Charge is the attempt or financial movement representation at provider/rail level. Authorization, capture effect, provider reference, attempt number, routing origin, and refund relationship can be tracked on Charge.

One Payment can have multiple Charge attempts. This model gives critical visibility especially in routing fallback, provider timeout, soft decline, or retry scenarios.

Why are they separate?

QuestionPaymentCharge
What is the business goal?Payment to collect from customerAttempt at provider level
What does merchant report?Single payment/order outcomeAttempt and provider performance
Routing fallback effectPayment stays the sameNew charge attempt may be created
Refund/capture relationshipTop-level payment contextFinancial operation level
Debug valueUser/order stateProvider, attempt, route, and error trace

One payment, multiple charge attempts

Example scenario:

  1. Merchant creates a 1000 TRY Payment.
  2. During confirm the first provider returns soft decline.
  3. Routing engine falls back to second provider.
  4. Payment stays the same.
  5. First Charge declined, second Charge succeeds.
  6. Payment becomes SUCCEEDED (or AUTHORIZED if auto_capture: false).
  7. Merchant sees one Payment; ops can trace two Charge attempts.
{
  "id": "pay_123",
  "status": "SUCCEEDED",
  "charges": [
    { "id": "ch_1", "attempt_no": 1, "status": "DECLINED" },
    { "id": "ch_2", "attempt_no": 2, "status": "CAPTURED" }
  ]
}

Hosted Checkout flow

Hosted Checkout manages user experience inside Checkout Session.

  1. Checkout Session is created.
  2. User arrives at checkout via session URL/token.
  3. Payment Method and required user fields are collected.
  4. Confirm fires in session context.
  5. If 3DS/requires_action is needed, it is managed inside checkout.
  6. Final state is verified with webhook or server-side query.

API-only flow

In API-only model the merchant carries frontend and backend responsibility.

  1. Merchant creates Payment.
  2. Collects Payment Method in its own UI or uses saved method.
  3. Calls Confirm.
  4. If REQUIRES_ACTION arrives, manages redirect with paymentNextAction.url.
  5. Verifies final state with webhook.

Capture/refund/void relationship

  • Capture: Finalizes amount after pre-authorization.
  • Refund: Refund process after successful capture.
  • Void: Cancels authorization that was not captured.

These operations appear in Payment context, but provider/rail level effects are tracked on Charge.

Error/decline behaviors

Successful payment alone is not enough testing. Merchant application must handle these outcomes separately:

  • Hard decline: do not retry; ask user for a different payment method.
  • Soft decline: try fallback or retry when appropriate.
  • Timeout/unknown: proceed with idempotency and status check.
  • Requires action: manage 3DS/redirect/resume flow.

Meaning for merchant reporting

Payment is the merchant main reporting record. Charge is the operational analysis record.

With this split the merchant can:

  • See how many provider attempts were tried for one order.
  • Measure fallback usage rate.
  • Review provider-level decline and timeout distribution.
  • Place refund/capture operations in the correct financial context.

Impact on webhook/event model

Webhook events carry Payment state changes to the merchant system. Charge attempt changes matter for trace and operational visibility.

Best practice: Close merchant order state with Payment events; use Charge attempt traces for incident and provider analysis.

On this page