# Create a client-side payment intent, returning the client secret, publishable key, customer id, amount and currency

Operation ID: `connectors.stripeCreatePaymentIntent`

Create a client-side payment intent, returning the client secret, publishable key, customer id, amount and currency.

## Public method

`createPaymentIntent`

Signature: `connectors.stripe.createClient(config).createPaymentIntent(body)`

Return type: `Promise<StripePaymentIntentResponse>`

## Authentication

Classification: **AUTHENTICATED**

Schemes: `bearerAuth`

## Prerequisites

None documented.

## HTTP

`POST /connectors/stripe/create-payment-intent`

## Path parameters

None.

## Query parameters

None.

## Body parameters

| Name | Type | Required | Format | Allowed values | Default | Nullable | Description |
|---|---|---:|---|---|---|---:|---|
| `body` | [`StripeCreatePaymentIntentRequest`](../models/StripeCreatePaymentIntentRequest.md) | Yes |  |  |  | No |  |

Request model: [`StripeCreatePaymentIntentRequest`](../models/StripeCreatePaymentIntentRequest.md)

## Request example

```json
{
  "amount": 500,
  "currency": "usd",
  "email": "patient@example.com",
  "mode": "sandbox",
  "product_id": "prod_smoke",
  "publishable_key": "example-publishable_key",
  "reference_id": "ref_smoke",
  "secret_key": "example-api-key",
  "session_id": "sess_smoke",
  "tenant_id": "tenant_smoke",
  "user_id": "user_smoke"
}
```

## Success responses

| Status | Shape | Content type | Description |
|---|---|---|---|
| `200` | [`PaymentOperationResult`](../models/PaymentOperationResult.md) | application/json | Successful response |

## Success response examples

### 200

```json
{
  "data": {
    "amount": 500,
    "currency": "usd",
    "reference_id": "ref_smoke",
    "session_id": "sess_smoke",
    "stripe_customer_id": "example-stripe_customer_id",
    "stripe_payment_intent_id": "example-stripe_payment_intent_id"
  },
  "success": true
}
```

## Common errors

| Status | Shape | Content type | Description |
|---|---|---|---|
| `400` | [`StandardErrorResponse`](../models/StandardErrorResponse.md) | application/json | Connector validation rejected the payload, or a required field was missing or of the wrong type. |
| `401` | [`StandardErrorResponse`](../models/StandardErrorResponse.md) | application/json | The HealthCloud bearer token is missing or invalid, or the vendor rejected the supplied connector credentials. |
| `500` | [`StandardErrorResponse`](../models/StandardErrorResponse.md) | application/json | The connector failed unexpectedly. |
| `502` | [`StandardErrorResponse`](../models/StandardErrorResponse.md) | application/json | The vendor returned an application or transport-level failure. |
| `504` | [`StandardErrorResponse`](../models/StandardErrorResponse.md) | application/json | The vendor did not respond within the connector timeout. |

## Error examples

### 400 — Invalid request

```json
{
  "error": "Invalid request"
}
```

### 401 — Authorization required

```json
{
  "error": "Authorization required"
}
```

### 500 — Internal error

```json
{
  "error": "Internal error"
}
```

### 502 — Upstream vendor error

```json
{
  "error": "Upstream vendor error"
}
```

### 504 — Upstream timeout

```json
{
  "error": "Upstream timeout"
}
```

## NodeJS / TypeScript implementation

```ts
import { HCSDK } from "@healthcloudai/hc-sdk";
import type { StripeCreatePaymentIntentRequest } from "@healthcloudai/hc-sdk";
```

```ts
const body = {
  "amount": 500,
  "currency": "usd",
  "email": "patient@example.com",
  "mode": "sandbox",
  "product_id": "prod_smoke",
  "publishable_key": "example-publishable_key",
  "reference_id": "ref_smoke",
  "secret_key": "example-api-key",
  "session_id": "sess_smoke",
  "tenant_id": "tenant_smoke",
  "user_id": "user_smoke"
};

const result = await connectors.stripe.createClient(config).createPaymentIntent(body);
```

## cURL

```bash
curl -X POST \
  -H 'Authorization: Bearer <ACCESS_TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '{"amount":500,"currency":"usd","email":"patient@example.com","mode":"sandbox","product_id":"prod_smoke","publishable_key":"example-publishable_key","reference_id":"ref_smoke","secret_key":"example-api-key","session_id":"sess_smoke","tenant_id":"tenant_smoke","user_id":"user_smoke"}' \
  'https://dev-api-connectors.health.cloud/connectors/stripe/create-payment-intent'
```

## Notes

None.

## Prepared Test Console scenario

No canonical scenario is currently associated.

## Real response

No approved real integration response is currently published. Unapproved candidates are never rendered as examples.
