---
updatedAt: 2026-05-13T09:06:01.000Z
---

# Stripe Single Purchase

Stripe's single purchase code action functionality allows you to create a new raw product that can be purchased inside your flow or to use the [price](https://stripe.com/docs/billing/prices-guide#create-prices) of the existing [product](https://dashboard.stripe.com/products).

This functionality also allows you to use key-value based `metadata` objects, which will be sent to your webhook along with payment information.

# Usage Example

```
async payload => {
  const url = await payments.singlePurchase.stripe({
    secret: 'your_stripe_secret',
    key: 'your_stripe_publishable_key',
    collectAddress: true,
    locale: 'nl',
    submitType: 'auto',
    currency: 'usd',
    metadata: {
      MY_KEY: 'MY_VALUE'
    },
    items: [
      // raw products
      {
        price: 1200,
        quantity: 1,
        images: ['https://www.howtogeek.com/wp-content/uploads/2018/09/vac_lede.png'],
        name: 'Audio',
        description: 'Awesome mic'
      },
      {
        price: 1000,
        quantity: 2,
        images: ['https://www.howtogeek.com/wp-content/uploads/2018/09/vac_lede.png'],
        name: 'Video',
        description: 'Awesome cameras'
      },
      // existing product's price
      // PLEASE NOTE YOU CAN'T MIX RAW PRODUCTS WITH EXISTING PRICES
      {
        price: 'price_2XX7x0XXXyxxx6x9x7XxXXXx',
        quantity: 3
      }
    ],
    onSuccess: {
      eventName: 'bought',
      params: [
        new Param('name', 'electronics'),
        new Param('price', '21$')
      ]
    },
    onFailure: {
      eventName: 'not bought',
      params: [ new Param('name', 'electronics') ]
    }
  })
  
  const buttons = new Buttons('Purchase my items')
  buttons.addButton(new Button({
    label: 'Click to purchase',
    type: 'payment',
    value: url
  }))

  const message = new Message(`Purchase items here ${url}`)
  message.addResponse(buttons)

  return message
}
```

# Properties

| Property         | Type      | Example                | Description                                                                                                                                                                                                                                                                                                                              | Required |
| :--------------- | :-------- | :--------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------- |
| `secret`         | `string`  | sk\_test\_XXXXXXXXXXX  | Your Stripe Secret Key                                                                                                                                                                                                                                                                                                                   | Yes      |
| `key`            | `string`  | pk\_test\_XXXXXXXXXXX  | Your Stripe Publishable Key                                                                                                                                                                                                                                                                                                              | Yes      |
| `collectAddress` | `boolean` | true                   | Whether Checkout should collect customer's [address](https://stripe.com/docs/api/checkout/sessions/object#checkout_session_object-billing_address_collection)                                                                                                                                                                            | No       |
| `locale`         | `string`  | nl                     | By default, Checkout detects the locale of the customer’s browser and displays a translated version of the page in their language if it is [supported](https://stripe.com/docs/js/checkout/redirect_to_checkout#stripe_checkout_redirect_to_checkout-options-locale). You can also provide a specific locale for Checkout to use instead | No       |
| `submitType`     | `string`  | donate                 | [Submit the type](https://stripe.com/docs/js/checkout/redirect_to_checkout#stripe_checkout_redirect_to_checkout-options-submitType) of payment session                                                                                                                                                                                   | No       |
| `currency`       | `string`  | eur                    | Currency that should be used in checkout                                                                                                                                                                                                                                                                                                 | Yes      |
| `metadata`       | `object`  | { MY_KEY: 'MY_VALUE' } | The object that will be sent with payment details to your webhook                                                                                                                                                                                                                                                                        | No       |
| `button.label`   | `string`  | Click to Purchase      | Label of the confirmation button                                                                                                                                                                                                                                                                                                         | No       |

# Success and Failure params

You can include `onSuccess` and `onFailure` configurations that will be used in corresponding situations.

| Property    | Type     | Example                           | Description                                                                     | Required |
| :---------- | :------- | :-------------------------------- | :------------------------------------------------------------------------------ | :------- |
| `eventName` | `string` | bought                            | Event name to trigger when items are successfully bought/purchased are rejected | No       |
| `params`    | `array`  | `new Param('productiId', 112234)` | Parameters that are set when the items are bought/purchased are rejected        | No       |

# Items

Multiple select is based on a purchase of several items. Each individual item should contain `price`, `quantity` and `name` properties and can contain `images` and `description` properties.

## Properties

| Property      | Type                 | Example                                    | Description                                                                                     | Required                        |
| :------------ | :------------------- | :----------------------------------------- | :---------------------------------------------------------------------------------------------- | :------------------------------ |
| `price`       | `number` or `string` | `1000` or `price_2XX7x0XXXyxxx6x9x7XxXXXx` | If you're creating a new raw product, use numeric price (the last two digits correspond to .00) | Yes                             |
| `quantity`    | `number`             | 1                                          | Amount of items to be purchased                                                                 | Yes                             |
| `images`      | `Array of strings`   | `["https://.../thumbnail.png"]`            | URLs of images to display alongside corresponding product (if using with the raw product)       | No                              |
| `name`        | `string`             | Microphone                                 | Name of your product                                                                            | Yes (if using with raw product) |
| `description` | \`string\`\`         | Awesome mic                                | Description of your product (if using with the raw product)                                     | No                              |