0.1.10 • Published 11 days ago

@strivve/strivve-cx v0.1.10

Weekly downloads
-
License
ISC
Repository
github
Last release
11 days ago

Strivve CX

Varying levels of customizable Javascript Components which easily drop into desktop and mobile web applications as well as native applications as reqired.

Documentation

https://swch.github.io/Strivve-UX-Components/

Install via CDN

<script src="https://cdn.jsdelivr.net/npm/@strivve/strivve-cx"></script>

Usage

<body>
  <div id="account-link"></div>
</body>
<script src="https://cdn.jsdelivr.net/npm/@strivve/strivve-cx"></script>
<script>
  Strivve.mountLinkingJourney({
    element_id: 'account-link',
    api_instance: 'customer-dev',
    card: {
      pan: '4111111111111111',
      cvv: '321',
      expiration_month: '2',
      expiration_year: '24',
      name_on_card: 'Jane',
    },
  });
</script>

Install as package

npm install @strivve/strivve-cx

Usage

import Strivve from '@strivve/strivve-cx';

Strivve.mountLinkingJourney({
  element_id: 'account-link',
  api_instance: 'customer-dev',
  card: {
    pan: '4111111111111111',
    cvv: '321',
    expiration_month: '2',
    expiration_year: '24',
    name_on_card: 'Jane',
    address: {
      city: 'Seattle',
      postal_code: '98177',
      country: 'USA',
      first_name: 'Jane',
      last_name: 'Smith',
      email: 'jane@test.com',
      phone_number: '2065555555',
      address1: 'test',
      state: 'test',
      subnational: 'WA',
      is_primary: true,
    },
  },
});

Config

nameparamsdescription
element_idstringrequired
api_instancestringrequired
cardCardConfigoptional
card_idstringoptional
appearanceAppearanceoptional
localizationLocalizationoptional
grantstringoptional
select_sitemountSelectSiteViewOptionsoptional
account_linkmountAccountLinkViewOptionsoptional

Card

nameparamsdescription
panstringUnique Personal Account Reference number for this card, to be used for card lookup. Generated automatically from PAN, expiration date, and username if using the SDK.
cvvstring-
expiration_monthstring-
expiration_yearstring-
name_on_cardstring-
addressAddressrequired

Address

nameparamsdescription
citystringrequired
postal_codestringrequired
first_namestringrequired
last_namestringrequired
emailstringrequired
phone_numberstringrequired
address1stringrequired
address2stringoptional
statestringrequired
subnationalstringrequired
is_primarybooleanrequired
countrystringoptional
postal_otherstringoptional

Service, Core and Component

We can use parts of the functions and components.

const service = Strivve.createService({ api_instance: 'customer-dev' });

const core = Strivve.createCore({
  service,
  card: {
    pan: '4111111111111111',
    cvv: '321',
    expiration_month: '2',
    expiration_year: '24',
    name_on_card: 'Jane',
  },
});

const component = Strivve.createComponent({ core });

component.mountAccountLinkView('account-link', {
  site_id: '1',
});

component.mountSelectSiteView('select-sites', {
  submit: (selected) => {
    alert(selected.map((item) => item.name).join(', '));
  },
});