Last updated
These docs are intended for a developer audience.Dismiss

Reference

RebillyInstruments.mount()

Use this method to mount the library UI components to the DOM of your website, and configure the experience for all your payment instrument methods. This method returns a Promise and accepts a single configuration object.

await RebillyInstruments.mount({ /* organizationId, publishableKey, websiteId, form, items */ });

Parameters

This table lists all available configuration options for the mount() method.

Required configuration properties

Option Type Default Requires Description
organizationIdstringThis is a required field.Your organization ID. To obtain your organization ID, see Obtain your organization ID and website ID.
publishableKeystringThis is a required field.Your publishable API key. To obtain your publishable API key, see Obtain a publishable API key.
websiteIdstringThis is a required field.Your website ID. To obtain your website ID, see Obtain your organization ID and website ID.

Add-ons configuration properties

Option Type Default Requires Description
addonsarray<object>items and addons.The list of add-ons items to be used for the transaction.
addons[]objectIndividual addon item configuration.
Properties: planId, quantity, thumbnail
addons[].planIdstringRebilly planId for the addon.
addons[].quantitynumberNumber of this addon being purchased.
addons[].thumbnailstringImage source for the addon. Recommend ~100px by 100px.

API configuration properties

Option Type Default Requires Description
apiModestringsandboxRebilly environment.
Allowed values: sandbox, live

Bump offer configuration properties

Option Type Default Requires Description
bumpOfferarray <object>items and bumpOffer.List of bump offer items to be used for the transaction instead of items.
bumpOffer[]objectIndividual bump offer item configuration.
Properties: planId, quantity, thumbnail
bumpOffer[].planIdstringRebilly planId for the bump offer.
bumpOffer[].quantitynumberNumber of this bump offer being purchased.
bumpOffer[].thumbnailstringImage source for the bump offer. Recommend ~100px by 100px.

Country configuration properties

Option Type Default Requires Description
countryCodestringUSCountry code for the transaction.
localestringautoLocale of the forms to be posted, uses browser locale by default.
Allowed values: en, es

CSS configuration properties

Option Type Default Requires Description
cssstringnullA stringified CSS that overrides default styling.

Deposit configuration properties

Option Type Default Requires Description
depositobjectjwt, and depositRequestId or currency.Deposit configurations. For an example, see Request deposits.
deposit.depositRequestIdstringID of the deposit request.
deposit.currencystringThree character ISO 4217 currency code.
deposit.amountnumberDefault deposit amount. For example, 9.99 or 5.
deposit.buttonsarray <number>nullDisplays buttons for the quick selection of deposit amounts.
deposit.editablebooleantrueSpecifies whether the customer can enter a deposit amount into a text input field. If this value is false, the customer may still change the deposit amount if deposit.buttons are provided.
deposit.customAmountobjectValidation of allowed deposit amount values.
deposit.customAmount.minimumnumber1Minimum allowed deposit amount.
deposit.customAmount.maximumnumber1000000000000Maximum allowed deposit amount.

Features display configuration

Option Type Default Requires Description
featuresobjectControls features related to the UI flow.
Properties: hideConfirmation, hideResult, showCoupons, enableTelemetry
features.hideConfirmationbooleanfalseDisplays the confirmation screen. Enable this to build your own confirmation screen.
features.hideResultbooleanfalseDisplays the result screen. Enable this to build your own result screen.
features.hideContinuebooleanfalseDisplays a continue button. Enable this option to stop customers from proceeding through the payment flow.
features.showCouponsarray <string>nullEnable and display coupons within summary details. Use array values to set coupon display locations.
features.enableTelemetrybooleantrueEnable this option to allow Rebilly to access data on Rebilly Instruments library usage. Disable this option to not provide any data on Rebilly Instruments library usage.
features.hideZeroAmountSummaryItemsbooleanfalseEnable this option to hide any invoice items with a price of 0.

Form configuration properties

Option Type Default Requires Description
formstring|HTMLElement.rebilly-instrumentsThis is a required field.CSS class or HTML element where the form mounts.
summarystring|HTMLElement.rebilly-instruments-summaryCSS class or HTML element where the summary mounts.

i18n/Localization configuration properties

Option Type Default Requires Description
i18nobjectnullConfigurable object to override translations and texts.
Properties: en (or any country ISO code like "en-CA")
i18n[countryISOCode]objectnullLanguage specific translations.
Properties: summary, form, confirmation, result, validations, paymentMethods
i18n[countryISOCode].summaryobjectnullSummary related fields.
Properties: subTotal, discounts, taxes, shipping, total
i18n[countryISOCode].formobjectnullForm related fields.
Properties: expressCheckout, or, continue, bumpOffer, billingAddressTitle, address, useSameAsBillingAddress, shippingAddressTitle, paymentCard, ach
i18n[countryISOCode].form.achobjectnullPayment card form related fields.
Properties: addNew, useExisting, accountingNumber, routingNumber, iban
i18n[countryISOCode].form.paymentCardobjectnullPayment card form related fields.
Properties: addNew, useExisting
i18n[countryISOCode].form.bumpOfferobjectnullBump offer related fields.
Properties: title, startingAt
i18n[countryISOCode].confirmationobjectnullConfirmation related fields.
Properties: billingAddressTitle, shippingAddressTitle, paymentMethodTitle, addons, edit, confirm, goBack, sameAsBillingAddress, addressFromPayPal, paymentMethodTitle, save, cancel
i18n[countryISOCode].confirmation.addonsobjectnullAdd-ons related fields.
Properties: title, startingAt
i18n[countryISOCode].resultobjectnullResult related fields.
Properties: success, failure, wrong
i18n[countryISOCode].validationsobjectnullValidation related fields.
Properties: form
i18n[countryISOCode].validations.addressobjectnullForm validation related fields.
Properties: firstName, lastName, fullName, email, address, address, city, country, region, state, province, postalCode, zipCode
i18n[countryISOCode].validations.confirmationobjectnullConfirmation validation related fields.
Properties: deliveryAddress
i18n[countryISOCode].paymentMethodsobjectnullChange the display name of different payment methods.
Properties: payment-card, ach

Items configuration properties

Option Type Default Requires Description
itemsarray <object>One of the following: items, money, invoiceId, or transactionId.The list of plan items to be used for the transaction.
items[]objectProperties: planId, quantity, thumbnail
items[].planIdstringRebilly planId for the item.
items[].quantitynumber|objectNumber of this item being purchased.
items[].quantity.defaultnumberNumber of this item being purchased. If minimum, maximum or multipleOf values are specified, the quantity field becomes editable.
items[].quantity.minimumnumber1Specifies the minimum number of this item that can be purchased.
items[].quantity.maximumnumberNumber.MAX_SAFE_INTEGERSpecifies the maximum number of this item that can be purchased.
items[].quantity.multipleOfnumber1The number by which the quantity of this item can be changed.
items[].thumbnailstringImage source for the item. Recommend ~100px by 100px.

JWT configuration properties

Option Type Default Requires Description
jwtstringRequired with: invoiceId, transactionIdAn exchanged token for customer authorization to the invoice or transaction resource.

Money configuration properties

Option Type Default Requires Description
moneyobjectOne of the following: items, money, invoiceId, or transactionId.Properties: amount, currency
money.amountnumberRequired with: money.The transaction amount. For example, "9.99" or 5.
money.currencystringRequired with: money.A three character ISO 4217 currency code.

Payout configuration properties

Option Type Default Requires Description
payoutobjectjwt and payoutRequestId.Payout configurations.
payout.payoutRequestIdstringID of the payout request.

Payment instruments additional fields configuration

Option Type Default Requires Description
paymentInstruments.additionalFieldsobjectDisplay options for additional fields.
Properties: show, require
paymentInstruments.additionalFields.showarray <string>Controls whether any of the listed inputs are displayed.
Properties: poNumber
paymentInstruments.additionalFields.requirearray <string>Controls whether any of the listed inputs are required to be filled.
Properties: poNumber

Payment instruments address configuration

Option Type Default Requires Description
paymentInstruments.addressobjectConfigure how address forms look and behave across the library
paymentInstruments.address.namestringdefaultControls how the first name and last name inputs are displayed.
Properties: default, combined, stacked
paymentInstruments.address.regionstringdefaultControls how the country, region, and postalCode inputs are displayed.
Properties: default, split, stacked
paymentInstruments.address.showarray <string>Controls if of the listed inputs are displayed.
Properties: all, email, organization, phoneNumber, city, country, region, postalCode
paymentInstruments.address.hidearray <string>Controls if any of the listed inputs are not displayed.
Properties: all, address, address2
paymentInstruments.address.requirearray <string>firstName and lastName.
If there are shippable plans in the items, country is also required.
Controls if any of the listed inputs are required to be filled. Note:
Properties: organization, email, phoneNumber, address, address2, city, country, region, postalCode

Payment instruments base configuration

Option Type Default Requires Description
paymentInstrumentsobjectPayment instruments configuration options.
Properties: compactExpressInstruments, allowDeactivate, allowUpdate, allowMakeDefault, allowCreate, enableTelemetry
paymentInstruments.compactExpressInstrumentsbooleantrueControls if express payment methods are displayed in a compact view.

Payment instruments Google Pay configuration

Option Type Default Requires Description
paymentInstruments.googlePayobjectGoogle Pay configuration options.
Properties: displayOptions
paymentInstruments.googlePay.displayOptionsobjectGoogle Pay display options.
Properties: buttonColor, buttonHeight, buttonType

Payment instruments payment card configuration

Option Type Default Requires Description
paymentInstruments.paymentCardobjectPayment card configuration options.
Properties: input
paymentInstruments.paymentCard.inputstringdefaultControls if payment card inputs are split apart. Default is to combine the inputs.
Properties: default, split

Payment instruments permission properties

Option Type Default Requires Description
paymentInstruments.allowCreatebooleantrueDisplay button to allow the creation of a new payment instrument.
paymentInstruments.allowDeactivatebooleanfalseDisplay option on selected payment instruments to deactivate the payment instrument.
paymentInstruments.allowMakeDefaultbooleanfalseDisplay option on a selected payment instrument to mark it as the customer's default payment instrument.
paymentInstruments.allowUpdatebooleanfalseDisplay options on a selected payment instrument to update the details of the payment instrument.

Theme button properties

Option Type Default Requires Description
theme.buttonColorBackgroundstringMain button background color (CSS value).
theme.buttonColorTextstring#FFFFFFMain button text color (CSS value).
theme.buttonFontFamilystringButton text font family.
theme.buttonFontSizestringButton font size (in px).
theme.buttonFontLineHeightstringButton line-height (in px).
theme.buttonFontWeightstringButton font weight.
theme.buttonBorderstring1px solid transparentMain button border (CSS border shorthand).
theme.buttonBorderRadiusstringButton border radius (in px).
theme.buttonBoxShadowstringnoneButton box shadow (CSS box-shadow value).
theme.buttonSecondaryColorTextstring#0044D4Secondary button text color (CSS value).
theme.buttonSecondaryFontFamilystringSecondary button text font family.
theme.buttonSecondaryFontSizestringSecondary button font size (in px).
theme.buttonSecondaryFontLineHeightstringSecondary button line-height (in px).
theme.buttonSecondaryFontWeightstringSecondary button font weight.
theme.buttonSecondaryBorderstring1px solid #0044D4Secondary button border (CSS border shorthand).
theme.buttonSecondaryBorderRadiusstringSecondary button border radius (in px).
theme.buttonSecondaryBoxShadowstringnoneSecondary button box shadow (CSS box-shadow value).

Theme button active properties

Option Type Default Requires Description
theme.buttonActiveColorBackgroundstringMain button background color on active state (CSS value).
theme.buttonActiveColorTextstringMain button text color on active state (CSS value).
theme.buttonActiveFontFamilystringButton text font family on active state.
theme.buttonActiveFontSizestringButton font size on active state (in px).
theme.buttonActiveFontLineHeightstringButton line-height on active state (in px).
theme.buttonActiveFontWeightstringButton font weight on active state.
theme.buttonActiveBorderstringMain button border on active state (CSS border shorthand).
theme.buttonActiveBorderRadiusstringButton border radius on active state (in px).
theme.buttonActiveBoxShadowstringnoneButton box shadow on active state (CSS box-shadow value).
theme.buttonSecondaryActiveColorBackgroundstringSecondary button background color on active state (CSS value).
theme.buttonSecondaryActiveColorTextstringSecondary button text color on active state (CSS value).
theme.buttonSecondaryActiveFontFamilystringSecondary button text font family on active state.
theme.buttonSecondaryActiveFontSizestringSecondary button font size on active state (in px).
theme.buttonSecondaryActiveFontLineHeightstringSecondary button line-height on active state (in px).
theme.buttonSecondaryActiveFontWeightstringSecondary button font weight on active state.
theme.buttonSecondaryActiveBorderstringSecondary button border on active state (CSS border shorthand).
theme.buttonSecondaryActiveBorderRadiusstringSecondary button border radius on active state (in px).
theme.buttonSecondaryActiveBoxShadowstringnoneSecondary button box shadow on active state (CSS box-shadow value).

Theme button hover properties

Option Type Default Requires Description
theme.buttonHoverColorBackgroundstringMain button background color on hover state (CSS value).
theme.buttonHoverColorTextstringMain button text color on hover state (CSS value).
theme.buttonHoverFontFamilystringButton text font family on hover state.
theme.buttonHoverFontSizestringButton font size on hover state (in px).
theme.buttonHoverFontLineHeightstringButton line-height on hover state (in px).
theme.buttonHoverFontWeightstringButton font weight on hover state.
theme.buttonHoverBorderstringMain button border on hover state (CSS border shorthand).
theme.buttonHoverBorderRadiusstringButton border radius on hover state (in px).
theme.buttonHoverBoxShadowstringnoneButton box shadow on hover state (CSS box-shadow value).
theme.buttonSecondaryHoverColorBackgroundstringSecondary button background color on hover state (CSS value).
theme.buttonSecondaryHoverColorTextstringSecondary button text color on hover state (CSS value).
theme.buttonSecondaryHoverFontFamilystringSecondary button text font family on hover state.
theme.buttonSecondaryHoverFontSizestringSecondary button font size on hover state (in px).
theme.buttonSecondaryHoverFontLineHeightstringSecondary button line-height on hover state (in px).
theme.buttonSecondaryHoverFontWeightstringSecondary button font weight on hover state.
theme.buttonSecondaryHoverBorderstringSecondary button border on hover state (CSS border shorthand).
theme.buttonSecondaryHoverBorderRadiusstringSecondary button border radius on hover state (in px).
theme.buttonSecondaryHoverBoxShadowstringnoneSecondary button box shadow on hover state (CSS box-shadow value).

Theme configuration properties

Option Type Default Requires Description
themeobjectTheme configuration options.
Properties: labels
theme.labelsstringstackedChanges the layout and behavior of the label inputs.
Allowed values: floating, stacked

Theme color properties

Option Type Default Requires Description
theme.colorPrimarystring#0044D4Primary theme color (CSS value).
theme.colorBackgroundstring#FFFFFFBackground color (CSS value).
theme.colorTextstring#0D2B3EMain font color (CSS value).
theme.colorDangerstring#CD5C5CError message text color (CSS value).
theme.borderRadiusstring4pxGeneral border radius (in px).

Theme font properties

Option Type Default Requires Description
theme.fontFamilystring-apple-system, system-ui, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serifMain font family.
theme.fontSizeBasestring16pxMain font size (in px).
theme.fontWeightBasestring400Main font weight.
theme.fontLineHeightBasestring24pxLine height (in px), used as the main line-height.
theme.fontSmoothstringautoGeneral text anti-aliasing setting.
Allowed values: auto, never, always

Theme heading properties

Option Type Default Requires Description
theme.headingFontFamilystringHeading font family.
theme.headingFontWeightstring500Heading font weight.
theme.headingColorTextstringHeading text color (CSS value).

Theme input properties

Option Type Default Requires Description
theme.inputColorBackgroundstringInput element background color (CSS value).
theme.inputColorTextstringInput element text color (CSS value).
theme.inputFontFamilystringInput element font family.
theme.inputFontSizestringInput element font size (in px).
theme.inputFontLineHeightstringInput element line-height (in px).
theme.inputFontWeightstringInput element font weight.
theme.inputBorderstringInput element border (CSS border shorthand).
theme.inputBorderRadiusstringInput element border radius (in px).
theme.inputBoxShadowstringInput element box shadow (CSS box-shadow value).

Theme input focus state properties

Option Type Default Requires Description
theme.inputFocusColorBackgroundstringInput element background color on focus state (CSS value).
theme.inputFocusColorTextstringInput element text color on focus state (CSS value).
theme.inputFocusFontFamilystringInput element font family on focus state.
theme.inputFocusFontSizestringInput element font size on focus state (in px).
theme.inputFocusFontLineHeightstringInput element line-height on focus state (in px).
theme.inputFocusFontWeightstringInput element font weight on focus state.
theme.inputFocusBorderstringInput element border on focus state (CSS border shorthand).
theme.inputFocusBorderRadiusstringInput element border radius on focus state (in px).
theme.inputFocusBoxShadowstringInput element box shadow on focus state (CSS box-shadow value).

Theme input hover state properties

Option Type Default Requires Description
theme.inputHoverColorBackgroundstringInput element background color on hover state (CSS value).
theme.inputHoverColorTextstringInput element text color on hover state (CSS value).
theme.inputHoverFontFamilystringInput element font family on hover state.
theme.inputHoverFontSizestringInput element font size on hover state (in px).
theme.inputHoverFontLineHeightstringInput element line-height on hover state (in px).
theme.inputHoverFontWeightstringInput element font weight on hover state.
theme.inputHoverBorderstringInput element border on hover state (CSS border shorthand).
theme.inputHoverBorderRadiusstringInput element border radius on hover state (in px).
theme.inputHoverBoxShadowstringInput element box shadow on hover state (CSS box-shadow value).

Theme input placeholder properties

Option Type Default Requires Description
theme.inputPlaceholderColorTextstringInput placeholder text color (CSS value).
theme.inputPlaceholderFontFamilystringInput placeholder font family.
theme.inputPlaceholderFontSizestringInput placeholder font size (in px).
theme.inputPlaceholderFontLineHeightstringInput placeholder line-height (in px).
theme.inputPlaceholderFontWeightstringInput placeholder font weight.

Theme input selected text properties

Option Type Default Requires Description
theme.inputSelectionColorTextstringInput selected text color (CSS value).
theme.inputSelectionColorBackgroundstringInput selected background color (CSS value).

Theme invalid input properties

Option Type Default Requires Description
theme.inputErrorColorBackgroundstringInvalid input element background color (CSS value).
theme.inputErrorColorTextstringInvalid input element text color (CSS value).
theme.inputErrorFontFamilystringInvalid input element font family.
theme.inputErrorFontSizestringInvalid input element font size (in px).
theme.inputErrorFontLineHeightstringInvalid input element line-height (in px).
theme.inputErrorFontWeightstringInvalid input element font weight.
theme.inputErrorBorderstringInvalid input element border (CSS border shorthand).
theme.inputErrorBorderRadiusstringInvalid input element border radius (in px).
theme.inputErrorBoxShadowstringInvalid input element box shadow (CSS box-shadow value).

Theme invalid input hover state properties

Option Type Default Requires Description
theme.inputErrorHoverColorBackgroundstringInvalid input element background color on hover (CSS value).
theme.inputErrorHoverColorTextstringInvalid input element text color on hover (CSS value).
theme.inputErrorHoverFontFamilystringInvalid input element font family on hover.
theme.inputErrorHoverFontSizestringInvalid input element font size on hover (in px).
theme.inputErrorHoverFontLineHeightstringInvalid input element line-height on hover (in px).
theme.inputErrorHoverFontWeightstringInvalid input element font weight on hover.
theme.inputErrorHoverBorderstringInvalid input element border on hover (CSS border shorthand).
theme.inputErrorHoverBorderRadiusstringInvalid input element border radius on hover (in px).
theme.inputErrorHoverBoxShadowstringInvalid input element box shadow on hover (CSS box-shadow value).

Theme invalid input focus state properties

Option Type Default Requires Description
theme.inputErrorFocusColorBackgroundstringInvalid input element background color on focus (CSS value).
theme.inputErrorFocusColorTextstringInvalid input element text color on focus (CSS value).
theme.inputErrorFocusFontFamilystringInvalid input element font family on focus.
theme.inputErrorFocusFontSizestringInvalid input element font size on focus (in px).
theme.inputErrorFocusFontLineHeightstringInvalid input element line-height on focus (in px).
theme.inputErrorFocusFontWeightstringInvalid input element font weight on focus.
theme.inputErrorFocusBorderstringInvalid input element border on focus (CSS border shorthand).
theme.inputErrorFocusBorderRadiusstringInvalid input element border radius on focus (in px).
theme.inputErrorFocusBoxShadowstringInvalid input element box shadow on focus (CSS box-shadow value).

Theme invalid input placeholder properties

Option Type Default Requires Description
theme.inputErrorPlaceholderColorTextstringInvalid input placeholder text color (CSS value).
theme.inputErrorPlaceholderFontFamilystringInvalid input placeholder font family.
theme.inputErrorPlaceholderFontSizestringInvalid input placeholder font size (in px).
theme.inputErrorPlaceholderFontLineHeightstringInvalid input placeholder line-height (in px).
theme.inputErrorPlaceholderFontWeightstringInvalid input placeholder font weight.

Theme invalid input selected text properties

Option Type Default Requires Description
theme.inputErrorSelectionColorTextstringInvalid input selected text color (CSS value).
theme.inputErrorSelectionColorBackgroundstringInvalid input selected background color (CSS value).

Transaction configuration properties

Option Type Default Requires Description
transactionIdstringjwt and one of the following: items, money, invoiceId, or transactionId.ID of a Rebilly transaction.
transactionTypestringpurchaseWhen set to setup, the payment instrument will be available for future transactions.
Allowed values: purchase, setup
invoiceIdstringjwt and one of the following: items, money, invoiceId, or transactionId.ID of a Rebilly invoice.

Example

This example describes the configuration of mount parameters for the Rebilly Instruments JavaScript library.

Payment methods that are displayed in payment forms are based on the gateway configuration. For more information, see Set up a payment gateway.

RebillyInstruments.mount({
  organizationId: "abc-123-xyz",
  publishableKey: "pk_sandbox_1234567890",
  websiteId: "ghi-789-qst",
  form: ".rebilly-instruments",
  summary: ".rebilly-instruments-summary",
  items: [
    {
      planId: "abc-123-def",
      quantity: 1,
      thumbnail: "https://www.example.com/picture-1.png"
    }, {
      planId: "xyz-987-uvw",
      quantity: 2,
      thumbnail: "https://www.example.com/picture-2.png"
    }, {
        planId: "abc-567-xyz",
        quantity: {
            default: 1,
            multipleOf: 1,
            minimum: 1,
            maximum: 20
        }
    }
  ],
  addons: [
    {
      planId: "fgh-123-uio",
      quantity: 1,
      thumbnail: "https://www.example.com/picture-3.png"
    }, {
      planId: "vbn-987-jkl",
      quantity: 2,
      thumbnail: "https://www.example.com/picture-4.png"
    }
  ],
  bumpOffer: [
    {
      planId: "kjh-123-edw",
      quantity: 1,
      thumbnail: "https://www.example.com/picture-5.png"
    }, {
      planId: "hyu-543-klo",
      quantity: 1,
      thumbnail: "https://www.example.com/picture-6.png"
    }
  ],
  apiMode: "sandbox",
  css: `
    .rebilly-instruments-summary-line-item-figure {
      border: 2px solid #0044d4;
    }
  `,
  theme: {
    colorPrimary: "#0044d4",
    colorDanger: "#cd5c5c",
    colorText: "#0d2b3e",
    colorBackground: "#ffffff",
    buttonColorText: "#ffffff",
    fontFamily: "Comic Sans MS",
    labels: "floating"
  },
  i18n: {
    en: {
      summary: {
        subTotal: "Sub Total",
        discounts: "Discounts",
        taxes: "Taxes",
        shipping: "Shipping",
        total: "Total"
      },
      form: {
        expressCheckout: "Express checkout",
        or: "Or",
        popupOverlayText: "Press here to show popup window",
        "continue": "Continue",
        bumpOffer: {
          title: "Yes, I want to upgrade!",
          startingAt: "Starting at {basePrice}"
        },
        billingAddressTitle: "Billing address",
        useSameAsBillingAddress: "Use same billing address for shipping",
        shippingAddressTitle: "Shipping address",
        address: {
          organizationLabel: "Organization",
          organizationPlaceholder: "My Organization Name",
          firstNameLabel: "First Name",
          firstNamePlaceholder: "John",
          lastNameLabel: "Last Name",
          lastNamePlaceholder: "Doe",
          fullNameLabel: "Full Name",
          fullNamePlaceholder: "John Doe",
          emailLabel: "Email",
          emailPlaceholder: "person@example.com",
          phoneNumberLabel: "Phone number",
          phoneNumberPlaceholder: "",
          addressLabel: "Address",
          addressPlaceholder: "",
          address2Label: "Address 2",
          address2Placeholder: "",
          cityLabel: "City",
          cityPlaceholder: "",
          countryLabel: "Country",
          countryPlaceholder: "",
          regionLabel: "Region",
          regionPlaceholder: "",
          stateLabel: "State",
          statePlaceholder: "",
          provinceLabel: "Province",
          provincePlaceholder: "",
          postalCodeLabel: "Postal code",
          postalCodePlaceholder: "",
          zipCodeLabel: "Zip code",
          zipCodePlaceholder: ""
        }
      },
      confirmation: {
        billingAddressTitle: "Billing address",
        shippingAddressTitle: "Shipping address",
        paymentMethodTitle: "Payment method",
        edit: "Edit",
        confirm: "Confirm",
        goBack: "Choose another payment method",
        addons: {
          title: "Other customers also selected",
          startingAt: "Starting at {basePrice}"
        }
      },
      result: {
        success: "Thank you for your purchase!",
        failure: "Transaction {result}",
        wrong: "Something went wrong"
      },
      validations: {
        address: {
          firstName: {
            required: "First name is required."
          },
          lastName: {
            required: "Last name is required."
          },
          fullName: {
            required: "Full name is required.",
            lastNameMissing: "Must include first name and last name."
          },
          email: {
            required: "Email is required.",
            validEmail: "Email must be a valid email address."
          },
          address: {
            required: "Address is required."
          },
          address2: {
            required: "Address 2 is required."
          },
          city: {
            required: "City is required.",
            noSpecialCharacters: "City cannot have any special characters."
          },
          country: {
            required: "Country is required."
          },
          region: {
            required: "Region is required."
          },
          state: {
            required: "State is required."
          },
          province: {
            required: "Province is required."
          },
          postalCode: {
            required: "Postal code is required.",
            maxLength: "Postal code cannot have more than 10 characters."
          },
          zipCode: {
            required: "Zip code is required.",
            maxLength: "Zip code cannot have more than 10 characters."
          }
        }
      }
    }
  },
  countryCode: "US",
  locale: "auto",
  paymentInstruments: {
    compactExpressInstruments: true,
    allowDeactivate: false,
    allowUpdate: false,
    allowMakeDefault: false,
    allowCreate: true,
    enableTelemetry: true,
    address: {
      name: "default",
      region: "default",
      show: ["organization", "phoneNumber"],
      hide: [],
      require: ["address"]
    },
    googlePay: {
      displayOptions: {
        buttonColor: "black",
        buttonHeight: "48px",
        buttonType: "plain"
      }
    }
  },
  features: {
    hideConfirmation: false,
    hideResult: false,
    hideContinue: false,
    showCoupons: ["summary", "confirmation"],
    hideZeroAmountSummaryItems: false
  }
});

RebillyInstruments.on()

Rebilly Instruments supports 3 events:

  • instrument-ready
  • purchase-completed
  • setup-completed

RebillyInstruments.on("instrument-ready")

The instrument-ready event will be called once the payment instrument token is generated.

RebillyInstruments.on("instrument-ready", (instrument) => {
  console.info("instrument-ready", instrument);
});

RebillyInstruments.on("purchase-completed")

The purchase-completed event will be called once the transaction is processed.

RebillyInstruments.on("purchase-completed", (transaction) => {
  console.info("purchase-completed", transaction);
});

RebillyInstruments.on("setup-completed")

The setup-completed event is called once the payment instrument is processed.

RebillyInstruments.on("setup-completed", (setup) => {
  console.info("setup-completed", setup);
});

RebillyInstruments.show()

This method will display the following UI elements:

  • Confirmation
  • Result

By default, the library will display these screens, use the options.features.hideConfirmation and options.features.hideResult parameters to disable them. Use this function in conjunction with RebillyInstruments.on to display screens that provide the right argument.

RebillyInstruments.show("confirmation")

Displays the confirmation screen after the instrument-ready event is triggered. If this value is set to false, you must trigger the purchase manually .

RebillyInstruments.show("confirmation", instrument);

RebillyInstruments.show("result")

Displays the result of a transaction after the purchase-completed event is triggered. If this value is set to false, you must trigger purchase the manually.

RebillyInstruments.show("result", transaction);

RebillyInstruments.purchase()

Initializes the purchase by passing the instrument data from the instrument-ready event. If the mount options.features.hideConfirmation option is set to true, this method must be triggered by a user click event in the browser.

RebillyInstruments.purchase(instrument);

RebillyInstruments.setup()

Initializes the process to make a payment instrument available for future use. Requires that instrument data is passed from the instrument-ready event. If mount the options.features.hideConfirmation option is set to true, this instrument must be triggered by a user click event in the browser.

RebillyInstruments.setup(instrument);

RebillyInstruments.update()

Updates the library information or styles. All mount options are updatable.

RebillyInstruments.update(options);

RebillyInstruments.destroy()

Destroys the library instance.

RebillyInstruments.destroy();

RebillyInstruments.version

Returns the version of the library.

console.log(RebillyInstruments.version); // RebillyInstruments Ver.X