Skip to main content
With the $wsStripe module, you can retrieve payment information related to Stripe. It provides the configuration data for the Stripe.js integration as well as status information about the current payment process. In this section, you will learn how to initialize Stripe in the frontend and evaluate the payment status.

Module overview

Example / excerpt of $wsStripe
{{= $wsStripe | json }}
JSON output
{
  "configuration": {
    "publishableKey": "...",
    "targetAccount": "..."
  },
  "createCustomerSession": "ƒ()",
  "paymentCanceled": false,
  "paymentFailed": false,
  "paymentPending": false
}
Note: "ƒ()" denotes a function. Variables and methods overview
NameTypeDescription
configurationmapMap with Stripe configuration data.
publishableKeystringPublic Stripe key for the integration in the frontend.
targetAccountstringStripe Connected Account ID (for platform payments).
paymentCanceledbooltrue if the payment was canceled.
paymentFailedbooltrue if the payment failed.
paymentPendingbooltrue if the payment is still pending.
createCustomerSession()mapCreates a Stripe Customer Session for the currently logged-in customer.

Templates

The $wsStripe module is typically used in the checkout area,
in particular on the payment page. The configuration data is required to
initialize the Stripe.js object in the frontend.

Variables

$wsStripe.configuration

Returns the Stripe configuration data. Used to initialize the Stripe object in the frontend.
{{ var $myStripeConfig = $wsStripe.configuration }}

$wsStripe.configuration.publishableKey

Returns the public Stripe key. This key is required to initialize Stripe.js in the browser and is safe to use in the frontend.
Publishable Key: {{= $wsStripe.configuration.publishableKey }}

$wsStripe.configuration.targetAccount

Returns the Stripe Connected Account ID. Only required for platform or marketplace payments, when payments are forwarded to a connected account.
Target Account: {{= $wsStripe.configuration.targetAccount }}

$wsStripe.paymentCanceled

Returns true if the payment was canceled.
{{ if $wsStripe.paymentCanceled }}
  // The payment was canceled
{{ /if }}

$wsStripe.paymentFailed

Returns true if the payment failed.
{{ if $wsStripe.paymentFailed }}
  // The payment failed
{{ /if }}

$wsStripe.paymentPending

Returns true if the payment is still pending.
{{ if $wsStripe.paymentPending }}
  // The payment is being processed
{{ /if }}

Methods

$wsStripe.createCustomerSession()

Creates a Stripe Customer Session for the currently logged-in customer. The session enables secure access to stored payment methods and customer data directly in the frontend. Signature
$wsStripe.createCustomerSession()
Return value
map - Customer Session object with the following attributes:
AttributeTypeDescription
client_secretstringSecret key for secure access to the customer.
componentsobjectConfiguration for enabled Stripe components.
customerstringID of the customer for whom the session was created.
expires_attimestampTime at which the session expires.
Example that creates a Customer Session.
{{ var $myCustomerSession = $wsStripe.createCustomerSession() }}
const customerSessionClientSecret = "{{= $myCustomerSession.client_secret }}";

Actions

No actions are available for $wsStripe.

Examples

Check payment status

{{ if $wsStripe.paymentCanceled }}
  <div class="alert">The payment was canceled.</div>
{{ /if }}

{{ if $wsStripe.paymentFailed }}
  <div class="alert error">The payment failed.</div>
{{ /if }}

{{ if $wsStripe.paymentPending }}
  <div class="alert info">The payment is being processed.</div>
{{ /if }}