# Create Charge — Shift4

> Creates a new charge object. See the documentation

- Key: `shift4-create-charge`
- Type: Action (Write)
- Version: 0.0.2
- App: Shift4 (`shift4`) — https://pipedream.com/apps/shift4.md
- This page (HTML): https://pipedream.com/apps/shift4/actions/create-charge
- Hints: open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/shift4/actions/create-charge/create-charge.mjs

## Description

Creates a new charge object. [See the documentation](https://dev.shift4.com/docs/api#charges-create-a-new-charge)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `customerId` | `string` | No | Identifier of the customer that will be associated with this charge. Options are loaded from the connected account. |
| `amount` | `integer` | Yes | The charge amount in minor units of a given currency. For example, 10€ is represented as '1000'. |
| `currency` | `string` | Yes | The charge currency represented as a three-letter ISO currency code. |
| `type` | `string` | No | The type of the charge. |
| `description` | `string` | No | A description for the charge. |
| `card` | `string` | No | Card token, card details or card identifier. |
| `paymentMethod` | `string` | No | Payment method details or identifier. |
| `flow` | `object` | No | Details specific to the payment method charge. |
| `captured` | `boolean` | No | Whether this charge should be immediately captured. |
| `shipping` | `object` | No | Shipping details. Sample object: {name: "string", address: {line1: "string", line2: "string", zip: "string", city: "string", state: "string", country: "country represented as two-letter ISO country code"}} |
| `billing` | `object` | No | Billing details. Sample object: {name: "string", email: "string", address: {line1: "string", line2: "string", zip: "string", city: "string", state: "string", country: "country represented as two-letter ISO country code"}, vat: "string"} |
| `threeDSecure` | `object` | No | 3D Secure options. |
| `metadata` | `object` | No | Metadata object. |

## Run it

**MCP**

```ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const accessToken = await pd.rawAccessToken

const transport = new StreamableHTTPClientTransport(
  new URL("https://remote.mcp.pipedream.net/v3"),
  {
    requestInit: {
      headers: {
        Authorization: `Bearer ${accessToken}`,
        "x-pd-project-id": process.env.PIPEDREAM_PROJECT_ID!,
        "x-pd-environment": "production",
        "x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
        "x-pd-app-slug": "shift4",
      },
    },
  },
)

const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)

const { tools } = await mcp.listTools()

// listTools() hands your model this tool's input schema, so it can
// fill the arguments itself:
const result = await mcp.callTool({
  name: "shift4-create-charge",
  arguments: {
    customerId: "Customer ID",
    amount: 10,
  },
})
```

**TypeScript**

```ts
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const result = await pd.actions.run({
  id: "shift4-create-charge",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    shift4: { authProvisionId: "apn_xxxxxxx" },
    customerId: "Customer ID",
    amount: 10,
  },
})

console.log(result)
```

**cURL**

```bash
curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
  -H "Content-Type: application/json" \
  -H "X-PD-Environment: production" \
  -H "Authorization: Bearer {access_token}" \
  -d '{
    "external_user_id": "{external_user_id}",
    "id": "shift4-create-charge",
    "configured_props": {
      "shift4": { "authProvisionId": "apn_xxxxxxx" },
      "customerId": "Customer ID",
      "amount": 10
    }
  }'
```

---

- App: https://pipedream.com/apps/shift4.md · All apps: https://pipedream.com/apps
