# Prepare a card payment (v1)

```http
POST https://secure.yoprint.com/v1/api/store/{team_slug}/sales_order/{hash_id}/payment/{payment_gateway}/pre_execute
```

- Status: legacy, deprecated
- API version: v1
- Operation ID: `v1_public_sales_order_payment_gateway_pre_execute`
- Section: Invoices and payments › [Payments](https://developer.yoprint.com/reference/payments.md)
- Web page: https://developer.yoprint.com/reference/payments/v1-sales-order-payment-gateway-pre-execute/
- Authentication: `Authorization: Bearer YOUR_API_KEY`

> **Legacy (deprecated).** A newer operation does this better: use [Prepare a card payment](https://developer.yoprint.com/reference/payments/v2-sales-order-payment-gateway-pre-execute.md) (`POST /v2/api/store/{team_slug}/v2/sales_order/{hash_id}/payment/{payment_gateway}/pre_execute`) instead. Its answers say so in the `Deprecation` and `X-YoPrint-Successor` headers.

The older path for preparing a card payment. It runs exactly the same code as Prepare a card payment (`v2.public.sales_order.payment.gateway.pre_execute`): use that one.

## Permission

Any member of the team.

## Path parameters

- `team_slug` (string, required): Your team slug, shown as Team ID next to your API key in Profile. Example `your-team`.
- `hash_id` (string, required): The sales order's or quote's `id` (a hash id). The `ord_` unique key and the order number do not work here. Example `V4keXwwxMQyXw7`.
- `payment_gateway` (string, required): The payment gateway. One of: `"stripe"`, `"square"`, `"square_v2"`, `"paypal"`, `"authorize_net"`, `"charge_it_pro"`. Example `stripe`.

## Request body

Content type `application/json`, required.

Fields:

- `amount` (integer, required): The amount to charge. Send a whole number of thousandths: `12500` is 12.50. Required for every gateway.
- `internal_id` (string (uuid) | null, optional): `charge_it_pro` only, optional: a UUID to use as the pending payment's `internal_id`. Anything that isn't a UUID is refused with 422 "The internal id must be a valid UUID."
- `locking_token` (string | null, optional): `charge_it_pro` only: your one-time token for this payment.
- `skip_terminal` (boolean, optional): `charge_it_pro` only.
- `surcharge` (decimal pair, optional): Optional card surcharge included in `amount`, read only when the team charges one. It must not be negative; it is taken off `amount` for the minimum check. `{ "value": 1250, "dp": 2 }` is 12.50 (see https://developer.yoprint.com/concepts/money-and-quantities.md).

### Example request

```bash
curl -X POST 'https://secure.yoprint.com/v1/api/store/your-team/sales_order/V4keXwwxMQyXw7/payment/stripe/pre_execute' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Accept: application/json' \
  -H 'X-Yoprint-Decimal-Format: exact-v1' \
  -H 'Content-Type: application/json' \
  -d '{
    "amount": 85000
  }'
```

## Response

`200` Successful response.

Fields:

- `data` (object, required): What the gateway needs next; `stripe` shown. Other gateways return their own fields.
  - `client_secret` (string, optional): `stripe`: the secret for Stripe.js.
  - `payment_intent_id` (string, optional): `stripe`: the payment intent to confirm.
- `status` (integer, required)
- `success` (boolean, required)

Example response:

```json
{
  "data": {
    "client_secret": "client-secret-from-stripe",
    "payment_intent_id": "pi_example_1001"
  },
  "status": 200,
  "success": true
}
```

## Errors

- `401` The API key is missing or wrong (`unauthenticated`).
- `403` You are not allowed to do this. `api_access_not_in_plan`: your team's plan doesn't include API access (Pro and above, with an active subscription or trial), so every request answers this until the team upgrades. When your role lacks the permission the operation needs, the body is only `{"message": "Insufficient Permission"}`. Other refusals use the error envelope, with `unauthorized` or `user_is_not_authorized`.
- `404` Not found. `page_not_found`: the team slug is unknown, you are not a member of the team, or an id in the path is not one of this team's. `code: null`, with a message that starts "No query results for": there is no record with that id.
  - When: An unknown `{payment_gateway}` or order (`page_not_found` or "No query results for …"). Fix: Use one of the gateway names.
- `422` The request was refused and changed nothing. `validation_failed` lists what to fix in `error.fields`; other codes name a business rule, explained in `error.message`. A few checks answer with only `{"message": "..."}`. An operation that calls another service (a payment provider, a carrier, an accounting app) can answer `connect_timeout` ("Please retry again") when that service does not answer in time: the change may or may not have happened there, so read the record back before you retry.
  - When: `square_v2` without a Square v2 connection (`gateway_not_setup`), `square` when the team's old Square connection is switched off (`using_deprecated_old_square_gateway`), a missing gateway field, the provider refused (for example `payment_capture_failed`), or a Shopify order deleted in Shopify (`shopify_order_deleted_externally`). Fix: Connect the gateway in Settings and send its fields.
  - When: The gateway has no first step (`square`, `square_v2`, `paypal`, `authorize_net`): `payment_pre_execute_failed` "Pre Execution Not Supported". Fix: Call Charge a card directly.
  - When: `amount` is missing or not a whole number (`validation_failed`), less than 1.00 after the surcharge (`payment_below_minimum`), or the surcharge is negative (`payment_surcharge_invalid`). Fix: Send at least 1.00 (`1000`) in thousandths.
  - When: A valid order id that no longer exists: "Cannot Start Transaction: Sales Order Not Found". Fix: Check the order id.

## Related

- [Prepare a card payment](https://developer.yoprint.com/reference/payments/v2-sales-order-payment-gateway-pre-execute.md): `POST /v2/api/store/{team_slug}/v2/sales_order/{hash_id}/payment/{payment_gateway}/pre_execute`
