# Collect a payment via Payroc's redirect-based Hosted Payment Page, optionally capturing a pre-authorization afterward.

Collect a payment via Payroc's redirect-based Hosted Payment Page, optionally capturing a pre-authorization afterward.

1. The merchant's website sends the authenticated, signed form POST that redirects the customer's browser to Payroc's Hosted Payment Page - not a documented Payroc REST operationId. This is the load-the-page step: a signed form POST/redirect to the gateway's hosted checkout.

2. The customer submits their payment details on the Payroc-hosted page; the gateway processes the transaction with the processor. The HPP request configures which variant runs here: a plain sale (default, no further step required), a pre-authorization to be captured afterward by captureHostedPreAuthorization, or tokenizing the card to save the customer's payment details for repeat payments.

3. The gateway returns the transaction result to the merchant's receipt/return URL and delivers it by webhook. This is where the merchant obtains the paymentId used by the optional capture step; the gateway returns it to the merchant's return URL and via webhook after the customer completes the HPP - it is not obtained from a REST call in this workflow.

4. OPTIONAL - pre-authorization variant only. After the customer completes the Hosted Payment Page as a pre-authorization, capture the held funds server-side using the paymentId returned to the merchant's return URL / webhook. Sending an amount captures that value; omit amount to capture the full authorized amount. For a plain sale, skip this step - the redirect and webhook already settled the payment. Returns the payment with transactionResult.status reflecting the capture.
 [capturePayment](/api/capture-payment)

## Workflow diagram

```mermaid
flowchart TD
  step0["1. signed form POST · Manual"]
  step1["2. hosted page submit · Manual"]
  step0 --> step1
  step2["3. payment result webhook · Manual"]
  step1 --> step2
  step3["4. capture request · API"]
  step2 --> step3
```
