Stripe Data Connector

The Stripe Data Connector allows you to create and manage payments using the Stripe Checkout API. It also provides core functionality for interacting with Stripe.

Constructor

Stripe(apiKey, accountIdopt) → {object}

We recommend that you create a Data Connector Configuration called "Stripe" via the Verj.io Runtime Environment's Administration Application.

A Stripe Data Connector is then available at connectors.verjio.stripe using that configuration.

If you are unable to do that, you may use this constructor to create a new Stripe Data Connector.

This constructor accepts an API key and, optionally, an account identifier.

Parameters:
Name Type Attributes Description
apiKey string  

API key.

accountId string <optional>

Account ID.

See:
Returns:
object

The Stripe Data Connector.

Members

account

Accounts are used for to integrate with Stripe Connect.

Accessible via connectors.verjio.stripe.account.

See:

checkout

The checkout object contains methods for creating Stripe Checkout sessions.

Accessible via connectors.verjio.stripe.checkout.

See:

customer

Stripe allows you to create records of your customers. You can store various details about them and track previous purchases.

A customer is required when creating a Stripe Checkout session.

Accessible via connectors.verjio.stripe.customer.

See:

helpers

A collection of helper methods for formatting and querying API data.

Accessible via connectors.verjio.stripe.helpers.

paymentIntent

Payment intents are used to collect payment from a customer.

Accessible via connectors.verjio.stripe.paymentIntent.

See:

price

Stripe allows you to create prices for use with one or more products. This allows you to manage the cost of multiple products quickly and consistently.

Accessible via connectors.verjio.stripe.price.

See:

product

A product represents a single item, service or other billable entity. Products are used for billing customers. You can assign multiple prices to a product.

A product can be used when making line items.

Accessible via connectors.verjio.stripe.product.

See:

subscription

Subscriptions are used to charge customers on a recurring basis.

Accessible via connectors.verjio.stripe.subscription.

See:

subscriptionSchedule

Subscription schedules are used to gain control over when a subscription is billed and renews.

Accessible via connectors.verjio.stripe.subscriptionSchedule.

See:

webhook

Webhooks are used to create and manage endpoints that are notified about events that happen in your Stripe account. Webhook endpoints are used by Stripe.checkout.create for handling successful and cancelled payments.

You should re-use webhook endpoints for multiple checkout sessions and other uses. It is good practise to remove any webhook endpoints that are no longer used.

Accessible via connectors.verjio.stripe.webhook.

See:

request

The request object contains methods for querying requests to and from the Stripe API.

Accessible via connectors.verjio.stripe.request.

Functions

account.create(type, parametersopt) → (nullable) {object}

Creates a new account.

Custom accounts must specify a capabilities parameter.

Parameters:
Name Type Attributes Description
type StripeAccountType  

The account type.

parameters object <optional>

Additional parameters that describe the account. A capabilities parameter is required for a custom type.

Returns:
object

Details of the new account. Returns null if the account type or parameters are invalid.

Example:
// Create a standard acccount
connectors.verjio.stripe.account.create(stripe.account.types.STANDARD);

account.delete(id) → (nullable) {object}

Deletes an account, specified by their ID.

This action cannot be undone.

Parameters:
Name Type Description
id string

The ID of the account to delete.

Returns:
object

Response object from the Stripe API. Returns null if the ID is omitted.

account.get(id) → (nullable) {object}

Retrieves an existing account using their ID.

Parameters:
Name Type Description
id string

The ID of the account to retrieve.

Returns:
object

Details of the requested account. Returns null if the ID is omitted.

account.list(limitopt, startingAfteropt) → {object}

Lists all the accounts.

Optional pagination parameters may be supplied.

Parameters:
Name Type Attributes Description
limit number <optional>

The number of results to fetch.

startingAfter string <optional>

The object ID to use as a cursor to begin fetching from.

Returns:
object

Response object from the Stripe API.

account.update(id, parametersopt) → (nullable) {object}

Updates an existing account using their ID.

Parameters:
Name Type Attributes Description
id string  

The ID of the account to update.

parameters object <optional>

Account parameters to update.

Returns:
object

Response object from the Stripe API. Returns null if the ID is omitted.

checkout.create(customerId, description, successUrl, cancelUrl, lineItemsopt, paymentMethodTypesopt, modeopt) → (nullable) {object}

Creates a new checkout session, used for processing Stripe Checkout incoming payments. An identifier is included in the returned object that should be passed to the Checkout page to identify the session.

Note that a small delay (<100ms) is required before the Checkout URL can be used. This delay is usually occupied by storing the identifier in the database.

Parameters:
Name Type Attributes Default Description
customerId string    

ID of the customer being billed.

description string    

A description of purchase or invoice. This is displayed alongside the payment form.

successUrl string    

The webhook callback URL for successful payment.

cancelUrl string    

The webhook callback URL for cancelled payment.

lineItems Array.<object> <optional> []

The invoice line items, as defined by makeLineItem, makePriceLineItem or makeProductLineItem.

paymentMethodTypes Array.<Stripe.StripePaymentMethods> <optional> ['card']

Array of accepted payment methods.

mode Stripe.StripeSessionModes <optional> payment

The payment mode. The default is to accept payments. Other options exist.

See:
Returns:
object

Details of the checkout session, including unique identifier. Returns null if one or more required parameters are omitted.

Examples:
// Create a new customer
// Alternatively, fetch the ID of an existing customer
var customer = connectors.verjio.stripe.customer.create({
	name: 'Alice Nowak',
	email: 'alicen@example.com'
});

// Create a line item for each product in the invoice
// Note that you could use existing products and prices
// with makeProductLineItem and makePriceLineItem
var items = [
	 connectors.verjio.stripe.helpers.makeLineItem('Organic ice cream (450ml)', 4.99, 1),
	 connectors.verjio.stripe.helpers.makeLineItem('Frozen fudge brownie (150g)', 2.99, 3)
];

// Set up a checkout session for the customer, specifying the line item(s)
var checkoutSession = connectors.verjio.stripe.checkout.create(
	customer.id,
	'Your online purchase from Sandy\'s ice cream parlour',
	'https://sandy.verj.cloud/api/checkout/callback/success',
	'https://sandy.verj.cloud/api/checkout/callback/cancel',
	items
);

// Redirect the user to the Stripe Checkout page
// A callback will be made depending on the outcome of the checkout
form.gotoUrl(checkoutSession.url, null);
// Create a new recurring price for the product
// This could be created in advance for each subscription tier
var price = connectors.verjio.stripe.price.create(product.id, {
  unit_amount_decimal: 999
  recurring: {
    interval: 'month',
    interval_count: 1
  }
});

// Create a line item for the subsription product using the recurring price, defined above
var items = [
  connectors.verjio.stripe.helpers.makePriceLineItem(price.id, 1),
];

// Set up a checkout session for the customer, specifying the subscription line item(s)
// The customer will authorise the payment for this and future invoices
var checkoutSession = connectors.verjio.stripe.checkout.create(
	customer.id,
	'Your new subscription from Sandy\'s ice cream parlour',
	'https://sandy.verj.cloud/api/checkout/callback/success',
	'https://sandy.verj.cloud/api/checkout/callback/cancel',
	items
);

// Redirect the user to the Stripe Checkout page, as usual
form.gotoUrl(checkoutSession.url, null);

checkout.get(sessionId) → (nullable) {object}

Retrieves details of a checkout session.

Parameters:
Name Type Description
sessionId string

ID of the checkout session

Returns:
object

details of the checkout session. Returns null if the ID is omitted.

customer.create(parametersopt) → {object}

Creates a new customer and returns details.

Parameters:
Name Type Attributes Description
parameters object <optional>

Parameters that describe the customer.

Returns:
object

Details of the newly-created customer.

customer.delete(id) → (nullable) {object}

Deletes a customer, specified by their ID.

This action cannot be undone.

Parameters:
Name Type Description
id string

The ID of the customer to delete.

Returns:
object

Response object from the Stripe API. Returns null if the ID is omitted.

customer.get(id) → (nullable) {object}

Retrieves an existing customer using their ID.

Parameters:
Name Type Description
id string

The ID of the customer to retrieve.

Returns:
object

Details of the requested customer. Returns null if the ID is omitted.

customer.list(limitopt, startingAfteropt) → {object}

Lists all the customers.

Optional pagination parameters may be supplied.

Parameters:
Name Type Attributes Description
limit number <optional>

The number of results to fetch.

startingAfter string <optional>

The object ID to use as a cursor to begin fetching from.

Returns:
object

Response object from the Stripe API.

customer.search(query, limitopt, pageopt, parametersopt) → {object}

Search existing customers using the specified query.

Optional pagination parameters may be supplied.

Parameters:
Name Type Attributes Default Description
query string    

The search query.

limit number <optional> 10

The number of results to fetch.

page string <optional>  

The page cursor. This is included in the response object as next_page.

parameters object <optional>  

Additional parameters to include.

See:
Returns:
object

Response object from the Stripe API.

customer.update(id, parametersopt) → (nullable) {object}

Updates an existing customer using their ID.

Parameters:
Name Type Attributes Description
id string  

The ID of the customer to update.

parameters object <optional>

Customer parameters to update.

Returns:
object

Response object from the Stripe API. Returns null if the ID is omitted.

paymentIntent.cancel(id, reasonopt) → (nullable) {object}

Cancels an existing payment intent using their ID.

Parameters:
Name Type Attributes Description
id string  

The ID of the payment intent to cancel.

reason string <optional>

The cancellation reason.

See:
Returns:
object

Details of the cancelled payment intent. Returns null if the ID is omitted.

paymentIntent.capture(id, parametersopt) → (nullable) {object}

Captures funds from an existing, uncaptured payment intent using their ID. The status of the payment intent must be requires_capture.

Parameters:
Name Type Attributes Description
id string  

The ID of the payment intent to capture.

parameters object <optional>

Additional parameters to include with request.

See:
Returns:
object

Details of the captured payment intent. Returns null if the ID is omitted.

paymentIntent.confirm(id, parametersopt) → (nullable) {object}

Confirms a payment intent and initiate a payment from the customer.

Parameters:
Name Type Attributes Description
id string  

The ID of the payment intent to confirm.

parameters object <optional>

Additional parameters to include with request.

See:
Returns:
object

Details of the captured payment intent. Returns null if the ID is omitted.

paymentIntent.create(amount, parametersopt) → (nullable) {object}

Creates a new payment intent.

Parameters:
Name Type Attributes Description
amount int  

The amount to collect. This uses the smallest currency unit, e.g. pence or cents.

parameters object <optional>

Additional parameters to include with request.

See:
Returns:
object

Details of the new payment intent. Returns null if one or more required parameters are omitted or invalid.

paymentIntent.get(id) → (nullable) {object}

Retrieves an existing payment intent using their ID.

Parameters:
Name Type Description
id string

The ID of the payment intent to retrieve.

Returns:
object

Details of the requested payment intent. Returns null if the ID is omitted.

paymentIntent.list(limitopt, startingAfteropt, parametersopt) → {object}

Lists all the payment intents.

Optional pagination parameters may be supplied.

Parameters:
Name Type Attributes Description
limit number <optional>

The number of results to fetch.

startingAfter string <optional>

The object ID to use as a cursor to begin fetching from.

parameters object <optional>

Additional parameters to include with request.

See:
Returns:
object

Response object from the Stripe API.

paymentIntent.search(query, limitopt, pageopt, parametersopt) → {object}

Search existing payment intents using the specified query.

Optional pagination parameters may be supplied.

Parameters:
Name Type Attributes Default Description
query string    

The search query.

limit number <optional> 10

The number of results to fetch.

page string <optional>  

The page cursor. This is included in the response object as next_page.

parameters object <optional>  

Additional parameters to include.

See:
Returns:
object

Response object from the Stripe API.

paymentIntent.update(id, parametersopt) → (nullable) {object}

Updates an existing payment intent using their ID.

Parameters:
Name Type Attributes Description
id string  

The ID of the payment intent to update.

parameters object <optional>

Payment intent parameters to update.

Returns:
object

Response object from the Stripe API. Returns null if the ID is omitted.

price.create(productId, parametersopt) → (nullable) {object}

Creates a new price for an existing product.

Parameters:
Name Type Attributes Description
productId string  

The ID of the product.

parameters object <optional>

Additional parameters that describe the price. A unit_amount or custom_unit_amount parameter is required. The custom_unit_amount parameter should be an object with a property enabled set to true. A currency parameter is required if the default currency has not been set.

Returns:
object

Details of the new price. Returns null if one or more required parameters are omitted or invalid.

Examples:
// Create a price using the default currency
var price = connectors.verjio.stripe.price.create(product.id, {
	unit_amount_decimal: 499
});
// Creates a recurring price for a monthly subscription
// The interval and interval_count can be changed to adjust the billing frequency
var recurringPrice = connectors.verjio.stripe.price.create(product.id, {
  unit_amount_decimal: 999
  recurring: {
    interval: 'month',
    interval_count: 1
  }
});
// Create a variable-price price using the custom_unit_amount parameter
// The currency is manually set to USD
var price = connectors.verjio.stripe.price.create(monthlyDonationProduct.id, {
	currency: 'USD',
	custom_unit_amount: {
		enabled: true,
		preset: 5, 
		minimum: 1
	}
});

price.delete(id) → (nullable) {object}

Deletes a price, specified by their ID.

This action cannot be undone.

Parameters:
Name Type Description
id string

The ID of the price to delete.

Returns:
object

Response object from the Stripe API. Returns null if the ID is omitted.

price.get(id) → (nullable) {object}

Retrieves an existing price using their ID.

Parameters:
Name Type Description
id string

The ID of the price to retrieve.

Returns:
object

Details of the requested price. Returns null if the ID is omitted.

price.list(limitopt, startingAfteropt) → {object}

Lists all the prices.

Optional pagination parameters may be supplied.

Parameters:
Name Type Attributes Description
limit number <optional>

The number of results to fetch.

startingAfter string <optional>

The object ID to use as a cursor to begin fetching from.

Returns:
object

Response object from the Stripe API.

price.update(id, parametersopt) → (nullable) {object}

Updates an existing price using their ID.

Parameters:
Name Type Attributes Description
id string  

The ID of the product to update.

parameters object <optional>

Price parameters to update.

Returns:
object

Response object from the Stripe API. Returns null if the ID is omitted.

product.create(name, parametersopt) → (nullable) {object}

Creates a new product.

Parameters:
Name Type Attributes Description
name string  

The name of the product.

parameters object <optional>

Additional parameters that describe the product.

Returns:
object

Details of the new product. Returns null if the name is omitted.

Example:
// Create a product to represent a tub of ice cream
// Prices will appear as 'per tub' at checkout
var product = connectors.verjio.stripe.product.create('Organic ice cream', {
  description: 'A 450ml tub of delicious, home made organic ice cream.',
  unit_label: 'tub'
});

product.delete(id) → (nullable) {object}

Deletes a product, specified by their ID.

This action cannot be undone.

Parameters:
Name Type Description
id string

The ID of the product to delete.

Returns:
object

Response object from the Stripe API. Returns null if the ID is omitted.

product.get(id) → (nullable) {object}

Retrieves an existing product using their ID.

Parameters:
Name Type Description
id string

The ID of the product to retrieve.

Returns:
object

Details of the requested product. Returns null if the ID is omitted.

product.list(limitopt, startingAfteropt) → {object}

Lists all the products.

Optional pagination parameters may be supplied.

Parameters:
Name Type Attributes Description
limit number <optional>

The number of results to fetch.

startingAfter string <optional>

The object ID to use as a cursor to begin fetching from.

Returns:
object

Response object from the Stripe API.

product.update(id, parametersopt) → (nullable) {object}

Updates an existing product using their ID.

Parameters:
Name Type Attributes Description
id string  

The ID of the product to update.

parameters object <optional>

Product parameters to update.

Returns:
object

Response object from the Stripe API. Returns null if the ID is omitted.

request.isFromStripe(header, requestBody, secret) → {boolean}

Determines if a request was sent by the Stripe API. This performs several verification steps to determine the authenticity of incoming requests. This method should be used when processing Stripe Checkout webhooks.

This method checks that the message signature is valid and that the timestamp falls within the allowed window.

If the request was not verified, you should return an HTTP 401 code to the sender. Upon receipt of an HTTP 401 code, Stripe will alert and retry. This behaviour may resolve the issue as a new request, with a new timestamp, will be made.

Parameters:
Name Type Description
header object

The request headers.

requestBody object

The request body.

secret string

The secret key for your webhook endpoint. This is returned as the secret property when creating a webhook endpoint via webhook.create. This can also be found in the webhook settings in the Stripe Developer Dashboard.

See:
Returns:
boolean

Request validity - true if the request was from Stripe, false otherwise.

Example:
// Called from inside a REST Service endpoint event
if (!connectors.verjio.stripe.request.isFromStripe(
	form.rest.requestHeaders,
	form.rest.requestBody,
	webhook.secret
)) {
  form.rest.setResponseStatus(401);
}

subscription.cancel (id) → (nullable) {object}

Cancels a subscription immediately.

Customers won't be charged again for this subscription.

Parameters:
Name Type Description
id string

The ID of the subscription to cancel.

Returns:
object

Response object from the Stripe API. Returns null if the ID is omitted.

subscription.create(customerId, lineItems, parametersopt) → (nullable) {object}

Creates a new subscription for a specified customer.

A subscription is made up of one or more line items.

Parameters:
Name Type Attributes Description
customerId string  

The ID of the customer.

lineItems Array.<object>  

The line items being subscribed to.

parameters object <optional>

Additional parameters to include.

See:
Returns:
object

Details of the new subscription. Returns null if the name is omitted.

subscription.get(id) → (nullable) {object}

Retrieves an existing subscription using their ID.

Parameters:
Name Type Description
id string

The ID of the subscription to retrieve.

Returns:
object

Details of the requested subscription. Returns null if the ID is omitted.

subscription.list(parametersopt, limitopt, startingAfteropt) → {object}

Lists all the subscriptions. The subscriptions may be filtered by customer, price or otherwise.

By default cancelled subscriptions are not returned.

Optional pagination parameters may be supplied.

Parameters:
Name Type Attributes Description
parameters object <optional>

Additional parameters to include such as filters.

limit number <optional>

The number of results to fetch.

startingAfter string <optional>

The object ID to use as a cursor to begin fetching from.

See:
Returns:
object

Response object from the Stripe API.

subscription.resume (id, parametersopt) → (nullable) {object}

Resumes a paused subscription.

Parameters:
Name Type Attributes Description
id string  

The ID of the subscription to resume.

parameters object <optional>

Additional parameters to include.

See:
Returns:
object

Response object from the Stripe API. Returns null if the ID is omitted.

subscription.search(query, limitopt, pageopt, parametersopt) → {object}

Search existing subscriptions using the specified query.

Optional pagination parameters may be supplied.

Parameters:
Name Type Attributes Default Description
query string    

The search query.

limit number <optional> 10

The number of results to fetch.

page string <optional>  

The page cursor. This is included in the response object as next_page.

parameters object <optional>  

Additional parameters to include.

See:
Returns:
object

Response object from the Stripe API.

subscription.update(id, parametersopt) → (nullable) {object}

Updates an existing subscription using their ID.

Parameters:
Name Type Attributes Description
id string  

The ID of the subscription to update.

parameters object <optional>

Subscription parameters to update.

Returns:
object

Response object from the Stripe API. Returns null if the ID is omitted.

subscriptionSchedule.cancel(id) → (nullable) {object}

Cancels a subscription schedule, specified by their ID.

This action cannot be undone.

Parameters:
Name Type Description
id string

The ID of the subscription schedule to cancel.

Returns:
object

Response object from the Stripe API. Returns null if the ID is omitted.

subscriptionSchedule.create(customerId, phases, startDateopt, endDateopt, statusopt) → (nullable) {object}

Creates a new subscription schedule for the specified customer.

Parameters:
Name Type Attributes Default Description
customerId string    

The ID of the customer to create the subscription schedule for.

phases Array.<object>    

Array of one or more subscription phases.

startDate Date | number | string <optional> now

Timestamp of subscription start or the string now. Defaults to now.

endDate Date | number | string <optional>  

Timestamp of subscription end or the string now. The subscription will continue indefinitely if not specified.

status object <optional>  

Additional parameters.

See:
Returns:
object

Response object from the Stripe API. Return null if the customer or phases were omitted.

subscriptionSchedule.get(id) → (nullable) {object}

Retrieves an existing subscription schedule using its ID.

Parameters:
Name Type Description
id string

The ID of the subscription schedule to retrieve.

Returns:
object

Details of the requested customer. Returns null if the ID is omitted.

subscriptionSchedule.list(customerIdopt, limitopt, startingAfteropt) → (nullable) {object}

Lists all subscription schedules, optionally for a specified customer.

Optional pagination parameters may be supplied.

Parameters:
Name Type Attributes Description
customerId string <optional>

The ID of the customer to retrieve the subscription schedules for. Defaults to all customers.

limit number <optional>

The number of results to fetch.

startingAfter number <optional>

The offset to begin fetching from.

See:
Returns:
object

Response object from the Stripe API.

subscriptionSchedule.makePhase(lineItems, statusopt) → (nullable) {object}

Returns an object defining a subscription phase. A subscription phase is a list of billable line items and, optionally, start and end timestamps or a number of cycles to bill.

Billing cycle length is determined by the specified price or via the line item's price_data.

A subscription can continue indefinitely if the final phase has no iterations and the subscription schedule has no end_date specified.

Subscription schedules must have one or more phases.

Parameters:
Name Type Attributes Description
lineItems Array.<object>  

Array of billable line items for this subscription phase.

status object <optional>

Additional parameters.

See:
Returns:
object

The phase for the subscription schedule. Returns null if no line items were specified.

Example:
// Set the parameters for a recurring monthly payment
var parameters = {
	recurring: {
	  interval: 'month',
	  interval_count: 1
	}
};

// Build the array of subscription line items
var items = [
	connectors.verjio.stripe.helpers.makeLineItem('Organic ice cream delivery (3x 450ml tub)', 14.99, 1, null, parameters)
];

// Create a 3-month free trial, starting now
var trialPhase = connectors.verjio.stripe.subscriptionSchedule.makePhase(items, { trial: true, iterations: 3 });

subscriptionSchedule.release(id) → (nullable) {object}

Releases a subscription schedule, specified by their ID. This will stop scheduling of its phases, but leave any existing subscription in place.

A schedule can only be released if its status is not_started or active.

This action cannot be undone.

Parameters:
Name Type Description
id string

The ID of the subscription schedule to cancel.

Returns:
object

Response object from the Stripe API. Returns null if the ID is omitted.

subscriptionSchedule.update(id, parametersopt) → (nullable) {object}

Updates an existing subscription schedule using its ID.

Parameters:
Name Type Attributes Description
id string  

The ID of the subscription schedule to update.

parameters object <optional>

Parameters to update.

Returns:
object

Response object from the Stripe API. Returns null if the ID is omitted.

webhook.create(url, eventsopt, parametersopt) → (nullable) {object}

Creates a new webhook endpoint at a specified URL. The endpoint is configured using an allowlist of events.

Parameters:
Name Type Attributes Default Description
url string    

The URL of your webhook endpoint

events Array.<string> <optional> ['payment_intent.payment_failed', 'payment_intent.succeeded']

Allowlist of enabled events. The default values are configured for checkout session callbacks.

parameters object <optional>  

Additional parameters that describe the endpoint.

See:
Returns:
object

Details of the new endpoint. Returns null if one or more required parameters are omitted or invalid.

Example:
// Set the webhook URL
fields.webhook_url.value = 'https://sandy.example.com/checkout/callback/success';

// Create a new webhook endpoint for checkout session callbacks
var webhook = stripe.webhook.create(fields.webhook_url.value);

// Store the webhook secret to validate incoming requests
fields.webhook_secret.value = webhook.secret;
resources.webhook.insert();

webhook.delete(id) → (nullable) {object}

Deletes a webhook endpoint, specified by its ID.

This action cannot be undone.

Parameters:
Name Type Description
id string

The ID of the webhook endpoint to delete.

Returns:
object

Response object from the Stripe API. Returns null if the ID is omitted.

webhook.get(id) → (nullable) {object}

Retrieves an existing webhook endpoint using its ID.

Parameters:
Name Type Description
id string

The ID of the webhook endpoint to retrieve.

Returns:
object

Details of the requested webhook endpoint. Returns null if the ID is omitted.

webhook.list(limitopt, startingAfteropt) → {object}

Lists all the webhook endpoints.

Optional pagination parameters may be supplied.

Parameters:
Name Type Attributes Description
limit number <optional>

The number of results to fetch.

startingAfter string <optional>

The object ID to use as a cursor to begin fetching from.

Returns:
object

Response object from the Stripe API.

webhook.update(id, parametersopt) → (nullable) {object}

Updates an existing webhook endpoint using its ID.

Parameters:
Name Type Attributes Description
id string  

The ID of the webhook endpoint to update.

parameters object <optional>

Parameters to update.

Returns:
object

Response object from the Stripe API. Returns null if the ID is omitted.

helpers.formatTimestamp(timestampopt) → {number|string}

Formats a timestamp into seconds from the unix epoch. Accepts Date objects, integers and strings.

If a timestamp appears to be milliseconds from the unix epoch it will be converted to seconds.

Note that now is a valid Stripe timestamp.

Parameters:
Name Type Attributes Description
timestamp Date | number | string <optional>

The timestamp to format.

See:
Returns:
number | string

The formatted timestamp as an integer (seconds from the unix epoch) or string (now). Returns null if the timestamp was not valid or null.

Example:
var timestamp = connectors.verjio.stripe.helpers.formatTimestamp(new Date());

helpers.makeLineItem(name, price, quantityopt, currencyopt, parametersopt) → {object}

Creates a line item for checkout or payment.

Parameters:
Name Type Attributes Default Description
name string    

The name of the product.

price float    

The product price (e.g. 0.99).

quantity number <optional> 1

The quantity of the product being sold.

currency string <optional> default currency

The currency to use. This will use the default currency if not provided.

parameters object <optional>  

Additional parameters to include.

See:
Returns:
object

The line item for the product.

Examples:
var lineItem = connectors.verjio.stripe.helpers.makeLineItem('Organic ice cream (450ml tub)', 4.99, 1);
var lineItemUSD = connectors.verjio.stripe.helpers.makeLineItem('Export quality ice-cream liquor', 38.99, 1, 'USD');

helpers.makePriceLineItem(priceId, quantityopt, parametersopt) → {object}

Creates a line item using an existing price.

Parameters:
Name Type Attributes Default Description
priceId string    

The price ID. Prices are linked to a single product.

quantity number <optional> 1

The quantity of the product being sold.

parameters object <optional>  

Additional parameters to include.

See:
Returns:
object

The line item for the product.

Example:
var product = connectors.verjio.stripe.product.create('Organic ice cream', {
  description: 'A 450ml tub of delicious, home made organic ice cream.',
  unit_label: 'tub'
});

var price = connectors.verjio.stripe.price.create(product.id, {
  unit_amount_decimal: 499
});

var lineItem = connectors.verjio.stripe.helpers.makePriceLineItem(price.id, 1);

helpers.makeProductLineItem(productId, price, quantityopt, currencyopt, parametersopt) → {object}

Creates a line item using an existing product but a custom price.

Parameters:
Name Type Attributes Default Description
productId string    

The product ID.

price float    

The product price (e.g. 0.99).

quantity number <optional> 1

The quantity of the product being sold.

currency string <optional> default currency

The currency to use. This will use the default currency if not provided.

parameters object <optional>  

Additional parameters to include.

See:
Returns:
object

The line item for the product.

Example:
var product = connectors.verjio.stripe.product.create('Organic ice cream', {
  description: 'A 450ml tub of delicious, home made organic ice cream.',
  unit_label: 'tub'
});

var lineItem = connectors.verjio.stripe.helpers.makeProductLineItem(product.id, 4.99, 1);

getDefaultCurrency() → {string}

Gets the default currency used by the Data Connector.

See:
Returns:
string

The default currency used by the Data Connector.

Example:
var defaultCurrency = connectors.verjio.stripe.getDefaultCurrency();

handleError(response)

Checks an API response for errors. If an error is encountered, the appropriate Error is thrown.

Parameters:
Name Type Description
response object

the response from a services.rest request

See:
Throws:
  • HttpAuthorisationError

    Thrown when a request is not authorised due to an invalid account or API key or insufficient permissions. Also thrown in response to rate-limiting.

  • HttpNotFoundError

    Thrown when a requested resource does not exist.

  • HttpServerError

    Thrown when the Stripe API experiences an error.

  • HttpRequestError

    Thrown when a request is malformed or does not contain required parameters. See the error message for more details. Also thrown during an idemopotency conflict.

Example:
try {
  connectors.verjio.stripe.product.create('Chocolate bar', {
    description: 'A 100g bar of milk chocolate.',
  });
}
catch (e) { 
  var message;
  if (e instanceof HttpRequestError) {
	  message = `There was a problem with your request: ${e.getMessage()}`;
  } else if (e instanceof HttpAuthorisationError) {
	  message = `There was a problem authorising with Stripe: ${e.getMessage()}`;
  } else if (e instanceof HttpServerError) {
	  fields.response.value = 'There was a problem with Stripe. Please try again later.';
  } else {
	  fields.response.value = `There was a problem communicating with Stripe: ${e.getMessage()}`;
  }
  
  event.owner.addErrorMessage(message);
}

setDefaultCurrency(defaultCurrencyopt)

Sets the default currency used by the Data Connector.

Parameters:
Name Type Attributes Default Description
defaultCurrency string <optional> GBP

The default currency to use for payments and other transactions. This is specified as the 3-digit ISO code.

See:
Example:
connectors.verjio.stripe.setDefaultCurrency('GBP');

Type definitions

StripePaymentMethods

Payment methods that can be accepted during Checkout.

Properties:
Name Type Description
CARD string

Card payments.

BACS string

BACS transfers.

SEPA string

SEPA transfers.

StripeSessionModes

Checkout session modes.

Properties:
Name Type Description
PAYMENT string

Accept one-time payments for cards, iDEAL, and more.

SETUP string

Save payment details to charge your customers later.

SUBSCRIPTION string

Use Stripe Billing to set up fixed-price subscriptions.

See:

StripeAccountType

Constants used to identify account types.

These can be accessed via account.types.

Properties:
Name Type Description
STANDARD string

Process charges manually.

EXPRESS string

Manage payment schedules, control funds and branding. Account management, identity verification and onboarding are handled by Stripe.

CUSTOM string

Custom accounts are managed entirely by you.

See:

StripeSubscriptionScheduleStatus

Constants used to identify subscription schedule statuses.

These can be accessed via subscriptionSchedule.statuses.

Properties:
Name Type Description
ACTIVE string

The subscription schedule is active and in use.

CANCELED string

The subscription schedule has been cancelled.

COMPLETED string

The final phase of the subscription schedule has finished. This will not happen if no end_date has been set.

NOT_STARTED string

The first phase of the subscription schedule is yet to start.

RELEASED string

The subscription schedule has finished and the subscription has been released to keep running.