# Create Payment Reference — ifthenpay

> Generates a Multibanco or MB WAY payment reference with a specified amount, entity code, and deadline. See the documentation

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

## Description

Generates a Multibanco or MB WAY payment reference with a specified amount, entity code, and deadline. [See the documentation](https://ifthenpay.com/docs/en/)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `paymentMethod` | `string` | Yes | The payment method to use for Ifthenpay (e.g., MB WAY, Multibanco) |
| `mbKey` | `string` | Yes | The key for the Multibanco payment method. |
| `mbWayKey` | `string` | Yes | The key for the MB Way payment method. |
| `orderId` | `string` | Yes | Payment identifier defined by the client (e.g., invoice number, order number, etc.) |
| `amount` | `string` | Yes | The amount to be paid with decimal separator "." |
| `mobileNumber` | `string` | Yes | Place the country code before the mobile number without any spaces (use '#'' to separate the country code from the mobile number - p.e. 351#912345678) |
| `description` | `string` | No | Description of the payment, with a maximum length of 200 characters |
| `url` | `string` | No | URL address, with a maximum length of 200 characters |
| `clientCode` | `string` | No | Client's code, with a maximum length of 200 characters |
| `clientName` | `string` | No | Client's name, with a maximum length of 200 characters |
| `email` | `string` | No | The Client's name. |
| `clientUsername` | `string` | No | Client's username, with a maximum length of 200 characters |
| `clientPhone` | `string` | No | Client's cell phone or phone number, with a maximum length of 200 characters |
| `expiryDays` | `integer` | No | How many days the payment reference is valid for. See the documentation for further details. |

## 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": "ifthenpay",
      },
    },
  },
)

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: "ifthenpay-create-payment-reference",
  arguments: {
    paymentMethod: "Payment Method",
    mbKey: "Mb Key",
  },
})
```

**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: "ifthenpay-create-payment-reference",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    ifthenpay: { authProvisionId: "apn_xxxxxxx" },
    paymentMethod: "Payment Method",
    mbKey: "Mb Key",
  },
})

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": "ifthenpay-create-payment-reference",
    "configured_props": {
      "ifthenpay": { "authProvisionId": "apn_xxxxxxx" },
      "paymentMethod": "Payment Method",
      "mbKey": "Mb Key"
    }
  }'
```

---

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