0.0.2-beta.4 • Published 12 months ago

@livechat/text-payments v0.0.2-beta.4

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

Text Payments

Text Payments goal is to be a collection of tools, with which you can easily integrate payment flows for Text, and Text-related products (subscriptions, apps, in-app purchases). The package is currently in the prototype stage, so please be mindful of that.

Usage

Installation

NPM

npm install @livechat/text-payments

or to get the tarball:

npm pack @livechat/text-payments

CC Form usage

init(config)

Use the init method to create and embed form in a host element. Init takes a single argument, config object with properties:

  • token(required) - Auth bearer token, required for Billing API calls
  • product(required) - one of the supported products (currently: 'livechat' | 'alphabot')
  • rootId - id of the host element (default: 'root')
  • env - set this to 'test' | 'labs' for API labs env
  • onSuccess(data: eventParams) - callback invoked when CC is saved successfully
  • onError(data: eventParams) - callback invoked when error occurs during CC save
  • onCancel() - callback invoked when Cancel button is clicked
  • customStyles - Emotion-compatible object, applied on the root div container; target .cc-form-container class to access the direct form wrapper styles

Example usage in index.html, UMD:

<div id="embed-root">
<script src="/package/dist/text-payments.umd.cjs"></script>
<script defer>
  TextPayments.init({
    token: <auth_token>,
    product: <'livechat' | 'alphabot'>,
    rootId: 'embed-root',
    env: 'labs'
  })
</script>