createCustomer

Creates a customer in Stripe. Under the hood, this action calls the create a customer API endpoint. This function returns a customerToken that you can use to create a charge or subscription.

Configuration

This function type accepts the following parameters:

KeyTypeDefaultDescription
secretKeystring@stripe-secret-keyYour Stripe secret key

Run the following command to add your Stripe secret key:

statickit secrets add stripe-secret-key <your-secret-key> -k <your-deploy-key>

Example

{
"functions": {
"createCustomer": {
"app": "stripe",
"type": "createCustomer"
}
}
}

Arguments

This function type accepts the following client-side arguments when called:

KeyTypeDefaultDescription
namestringThe customer’s full name or business name.
descriptionstringAn arbitrary string that you can attach to a customer object. It is displayed alongside the customer in the dashboard.
emailstringCustomer’s email address. It’s displayed alongside the customer in your dashboard and can be useful for searching and tracking. This may be up to 512 characters.
metadataobjectSet of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to metadata.
sourcestringA payment source token (e.g. generated from Stripe Elements)

Example

import { createClient, createCustomer } from '@statickit/functions';
let client = createClient({ site: '{your-site-id}' });
let { status } = await createCustomer(client, {
source: "tok_XXXXX"
});

Response

Returns a status and the following properties when successful:

KeyTypeDescription
idstringA unique identifier for the customer.
customerTokenstringA unique token to use for performing actions on this customer (like creating a charge)

Sandbox Limits

Only Stripe test keys are permitted on the Sandbox plan. Upgrade to production to use live keys.