1.0.1-alpha • Published 3 years ago

@dmn-arc-core-components/feature_subscriptions v1.0.1-alpha

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

Arc Subscriptions

This is an out of the box solution for Arc Subscriptions that offers three different levels of components to suit your needs plus convenience functions.

  1. SPAs - these requires only minimal style customization and configuration with the option to pass in custom localization. It includes all of the workflows pre-built into two different components for you to get up and running on Arc Subscriptions as soon as possible with minimal effort. One is designed for logging in and user profile/account management and the other allows the user to purchase products and follow the checkout and payment workflow.

    • Identity - login, lost password, verify email, profile, manage subscriptions, order history

    • Retail - offers/products, cart, payment processing, order confirmation

    • Custom SPA - shows an example of how to create your own custom SPA

  2. Forms - these are pre-built forms for the different areas of Arc Subscriptions that you can highly customize or use as they are to create your own workflows or to meet the specific needs of your project.

    • Identity Forms - forms related to account creation and management, email verification and password resets

    • Retail & Sales Forms - forms offers/products and shopping cart

    • Paywall - all variations of the paywall forms and an example component

    • Custom Form - an example of how to create your own custom form

  3. Elements - these are all of the form sub-components that make up Arc Subscriptions so that you can create and build your highly customizable forms and workflows to meet the specific needs of your project

  4. Functions & Analytics - these are functions and events you can use to help with your custom form creations or for customizing a specific form.

    • Analytics - call these or listen to these for your analytics reporting

    • Input Validation - validations to run on various types of form inputs

    • Utilities - various other functions

Installation

Run npm i @dmn-arc-core-components/feature_subscriptions@stable to add it to your project.

In your default output file, add a script that sets window.arcIdentityApiOrigin, window.arcSalesApiOrigin, and window.arcSignInUrl. The arcIdentityApiOrigin and arcSalesApiOrigin will usually point to the same location. The arcSignInUrl should point to a page or template where you have implemented your signin feature.

For example here is a partial snippet:

// File: components/output-types/default.jsx

//set cc client side variables
let subsConfig = `window.arcIdentityApiOrigin = "YOUR_API_ORIGIN_URL";`;
subsConfig += `window.arcSalesApiOrigin = "YOUR_API_ORIGIN_URL";`;
subsConfig += `window.arcSignInUrl = "YOUR_SUBSCRIPTIONS_LOGIN_URL";`;

return (<html lang="en">
  <head>
    <script type="text/javascript" dangerouslySetInnerHTML={{ __html: subsConfig }} />
  </head>
  <body>
    ...

Identity

This allows you to use pre-built solutions for managing login/logout, lost password, user profile, viewing order history and managing subscriptions.

SPA

This is a Single Page App that has all of the pre-configured workflow already setup and ready for you to customize and start using.

PropertyTypeDescription
config (required)ObjectConfigurations for the SPA
debugBooleanToggle debugging messages inside of the SPA
localizationObjectObject with mappings to all the text, error codes and country codes so you can customize all text within the SPA
stylesObjectObject with mappings to all styles so you can customize the look and feel of the SPA

SPA Configuration

These are passed to the config property and will affect how your SPA works.

PropertyTypeDescription
dateFormatStringAccepts EU or US
useCookiesBooleanWhether or not to allow cookies (if disabled uses localstorage instead)
autoLoginBooleanIf true will automatically login after creating a new account
secondLastNameBooleanIf true, displays a second last name field on the sign up and profile form
enableMagicLinkBooleanToggles showing the magic link button on the forgot password form
recaptchaObjectDeveloper configuration settings for ReCaptcha
debugBooleanWhen true will console log debugging messages
termsUrlStringUrl to your terms of service
privacyUrlStringUrl to your privacy policy
GDPRUrlStringUrl to GDPR policies
registerUrlStringUrl to create a new account
signInUrlStringUrl to sign in
signOutUrlStringUrl to sign out page
signOutPageHomeUrlStringUrl to return to the home page once you've signed out
signOutPageSignInUrlStringUrl on the sign out page to sign in again
signOutPageSignUpUrlStringUrl on the sign out page to create a new account
profileUrlStringUrl to the user's profile page
useTermsModalBooleanIf true, shows the terms of service in a modal window rather than a clickable URL
isTermsModalOpenBooleanFunctionif boolean does nothing, otherwise a function for checking if the terms of service modal is open or not
termsModalHideCloseIconBooleanWhether or not to hide the terms of service close modal icon
termsModalChildrenObjectContent to display in the terms of service modal
showSignOutLinkBooleanWhether or not to show the sign out link on the profile
hidePrivacyModalCloseIconBooleanWhether or not to display the close modal icon in the privacy modal
googleButtonWidthNumberThe width of the google social sign in button
googleButtonHeightNumberThe height of the google social sign in button
googleButtonLongTitleBooleanWhether or not to use the short title or the long title on the google social sign in button
googleButtonThemeStringThe theme for the google button, defaults to "dark"
fbButtonSizeStringThe size of the facebook button
fbButtonTypeStringThe type of facebook button
fbIncludePictureBooleanWhether or not to include a picture on the facebook button
dobRegistrationBooleanTurn on requirements to be a certain age before you can register
dobRequiredRegistrationBooleanForces the date of birth field to be required on the registration form
hideFacebookOnSignInBooleanHides the button to sign in with Facebook on the sign in page
hideGoogleOnSignInBooleanHides the Google sign in button on the sign in page
hideFacebookOnSignUpBooleanHides the register with Facebook button on the registration page
hideGoogleOnSignUpBooleanHides the register with Google button on the registration page
registrationAgeNumberSets the age a user must be in order to create an account, use 0 (default) if any age is allowed. For example, if this value is set to 14 then users that are 14 years and 1 day old will be permitted to register, anyone younger will not.
peekSignUpStateCallbackFunctionA function intended to return the current state values to be used in defining new logic/properties outside of the sign up form, for instance setting profile attributes from selections in the privacy modal

Hash Routes

These are the hash routes used in the Identity SPA:

#/ or #/sign-in – login to an existing account or optionally use social logins (FB or Google)

#/register – creates a new account by filling in the form or optionally using social sign up buttons (FB or Google)

#/sign-out – destroys the user’s session and gives them options on where to go next

#/profile – Includes the change password form, allows the user to edit their account information they entered when they signed up, includes the privacy modal (if enabled) and a link to sign out.

#/manage – allows a user to manage their current, update their credit card, change their billing address, cancel a subscription and view their order history.

#/forgot-password – for users who have forgotten their password.

#/verify-email?nonce={nonce} – if enabled in the subs admin, will force users to verify their email address before they can proceed to their profile page.

#/reset-password?nonce={nonce} - allows the user to reset their password if the nonce is valid.

#/magic-link?nonce={nonce} – allows the user to send themselves a one-time access link to login without having to remember their password if the nonce is valid.

SPA Sample Implementation

/* eslint-disable */
import React from 'react';
import Subscriptions from '@dmn-arc-core-components/feature_subscriptions';

/**
* @class IdentitySPA
* @desc Single page application for subscriptions Sign In, Sign Up, Profile,
* Reset Password, and Magic Link functionality
*
* @return {Object} IdentitySPA
*/
class Identity extends React.PureComponent {

  /**
  * Render the Identity SPA
  **/
  render() {
    return (<Subscriptions.IdentitySPA
      debug={false}
      styles={{
        wrapperClasses: 'col',
        profilePageContainerClasses: 'width_full',
        managePageContainerClasses: 'width_full',
        headerClasses: '',
        errorClasses: 'row color_red',
        errorHeadlineSize: 4,
      }}
      config={{
        useCookies: true,
        autoLogin: true,
        secondLastName: false,
        recaptcha: {
          enabled: true,
          token: "your_site_key_here",
          position: "above",
          size: "invisible",
        },
        termsUrl: "http://my.site.com/terms",
        privacyUrl: "http://my.site.com/privacy",
        GDPRUrl: "http://my.site.com/gdpr",
        signOutUrl: '/sign-out',
        signOutPageHomeUrl: '/homepage',
        signOutPageSignInUrl: '/sign-in',
        signOutPageSignUpUrl: '/register',
        profileUrl: '/profile',
        dobRegistration: true,
        dobRequiredRegistration: true,
        googleButtonWidth: 400,
        googleButtonHeight: 30,
        registrationAge: 14,
      }}
    />);
  }
}

export default Identity;

SPA Localization

All text within the SPA can be localized by passing a custom localization object with alternative/translated content. For a full list of all text that can be customized please see the localization section below.

SPA Styles

By default we provide bootstrap classes on all components for you. In order to match the look and feel of your project we expose certain classes within the SPA that you can set to your existing CSS classes. For a full list of all styles that can be customized please see the styles section below.

Identity Forms

  1. Sign Up - Create a new account
  2. Sign In - Login to your existing account
  3. Profile - View/edit user profile
  4. Manage - View order history and see/cancel current subscription
  5. Email Verification - Allow users to verify their email address
  6. Forgot Password - Request a link to change the user's password
  7. Reset Password - Allow a verified user to set a new password
  8. Order History - A table to display/sort orders
  9. Change Password - A form for changing the user's profile after they've logged in
  10. Magic Link - A form to get a one time login magic link code
  11. Sign Out - A form to destroy the user's session and let them sign in again or create a new account

Sign Up Form

Allows a user to create a new account on your site

PropertyTypeDescription
useCookies (required)BooleanWhether or not to use cookies
doLogin (required)BooleanIf true, signs the user in after a successful sign up
successUrl (required)StringWhere the user should be redirected to after a successful sign up
headerPropsObjectProps to pass to the Header form element at the top of the profile form
saveChangesPropsObjectProps to pass to the SaveChanges form submit button
firstNamePropsObjectProps to pass to the FirstNameInput form element
lastNamePropsObjectProps to pass to the LastNameInput form element
signInButtonPropsObjectProps to pass to the SignInButton form element
errorTextObjectLocalization of all SDK API error messages
<SignUpForm
  useCookies={false}
  doLogin={true}
  successUrl="http://my.site.com/profile"
/>

Sign In Form

Allows a user with an existing account to login to that account

PropertyTypeDescription
loginSuccessUrl (required)StringURL to redirect the user to upon successful login, defaults to /profile )
cookieBooleanUse cookies to store user authentication
recaptchaTokenStringThe ReCaptcha token
wrapperClassesStringClasses to apply around the sign in form
errorClassesStringClasses to apply to sign in form error messages
headerPropsObjectProps to pass to the Header form element at the top of the sign up form
emailInputPropsObjectProps to pass to the EmailInput form element
passwordInputPropsObjectProps to pass to the PasswordInput form element
forgottenPasswordLinkPropsObjectProps to pass to the ForgotPasswordLink form element
signInButtonPropsObjectProps to pass to the SignInButton form element
rememberMeCheckboxPropsObjectProps to pass to the RememberMeCheckbox form element
errorTextObjectLocalization of all text and error codes
<SignInForm
  loginSuccessUrl="http://my.site.com/profile"
/>

Profile Form

Allows a user to view and edit their profile information

PropertyTypeDescription
wrapperClassesStringthe classes to use on around form elements
headerPropsObjectproperties to pass to the Header form element
firstNamePropsObjectproperties to customize the FirstNameInput element
lastNamePropsObjectproperties to customize the LastNameInput element
secondLastNamePropsObjectproperties to customize the SecondLastNameInput element
displayNamePropsObjectproperties to customize the DisplayName element
emailInputPropsObjectproperties to customize the EmailInput element
DOBInputPropsObjectproperties to customize the DOBInput element
genderRadioButtonsPropsObjectproperties to customize the GenderRadioButtons element
addressContainerPropsObjectproperties to customize the AddressContainer element
validateFullAddressCallbackFunctioncustom function that validates the address
saveChangesButtonPropsObjectproperties to customize the SaveChangesButton element
errorClassesStringthe classes applied to the error messages displayed in case of failure
successClassesStringthe classes applied to the success messages displayed in case of success
errorTextObjectLocalization of all SDK API error messages
successTextObjectLocalization of all SDK API success messages
getProfileFailureUrlStringthe url to redirect the user in case of failure to retrieve the user profile
requireEmailVerificationBooleanthe condition of requiring the user to verify their email address before accessing their profile information (defaults to false)
verifyEmailUrlStringthe url to redirect the user in the case that the email is not verified
<ProfilePageForm
  headerProps={{
    title: "Profile Page",
  }}
  DOBInputProps={{
    dateFormat: "US",
  }}
  getProfileFailureUrl="http://my.site.com/login"
  verifyEmailUrl="http://my.site.com/verify-email"
/>

Manage Form

Allows a user to view and/or cancel their subscription and see their latest order history

PropertyTypeDescription
localization (required)ObjectObject containing all localization values passed from the SPA
stylesObjectObject containing all style customization prop values
<ManageSubsPage
  localization={localizationObject}
  styles={stylesObject}
/>

Email Verification Form

Allows a user to verify they are using a valid email address.

PropertyTypeDescription
successUrlStringRedirect to this URL on successful verification
successTextStringMessage to display on successful verification
nonceStringA nonce to verify the email through the user's email provider
<EmailVerification
  successUrl="/#profile"
/>
How To Verify An Email Address

When you set the verify email address flag to true in the Subs admin the IdentitySPA and the Login Form will require a verified email addresses before the user can login and view their profile or manage their subscription. Upon account creation an email must be set to the user's unverified email address and include a link back to the following URL pattern in order to complete the full verification process: https://my.site.com/{subscriptions-url}?nonce={nonce}/#verify

Forgot Password Form

Allows a user to request a link to reset their password

PropertyTypeDescription
headerStringthe forgot password header text
instructionsStringinstructions on how to fill out the form to get a reset password link
emailInputPropsObjectproperties to pass to the EmailInput form element
resetLinkButtonPropsObjectproperties to pass to the ResetLinkButton form element
magicLinkButtonPropsObjectproperties to pass to the MagicLinkButton form element
wrapperClassesStringclasses wrapper around form
instructionClassesStringclasses that wrap around the instructions for this form
errorClassesStringclasses for error messages
successClassesStringclasses for success messages
defaultResponseTextObjectan object with all default text, error codes and response messages to override the default values
<ForgotPasswordForm
  header="Forgot Your Password?"
  instructions="Enter your email address and click the button to send a reset password link to your email"
/>

Reset Password Form

Allows a user to reset their password. Requires an email be sent to the user with a nonce in the format of https://my.site.com/{subscriptions-url}?nonce={nonce}/#reset-password

React PropTypeDescription
successUrl (required)StringWhere the user is redirected after they successfully change their password
nonceStringoptional nonce to use in place of the nonce coming from the window URL hash
headerStringthe forgot password header text
loadingStringmessage to display while the component is loading
wrapperClassesStringclasses wrapper around form
loadingClassesStringproperties to pass to the EmailInput form element
headerClassesStringclasses to pass to the header
passwordPropsObjectproperties to pass to the first password input
confirmPasswordPropsObjectproperties to pass to the second confirm password input
resetButtonPropsObjectproperties to pass to the reset password button at the bottom of the form
instructionClassesStringclasses that wrap around the instructions for this form
errorClassesStringclasses for error messages
successClassesStringclasses for success messages
defaultTextObjectan object with all default text, error codes and response messages to override the default values
<ResetPasswordForm
  successUrl="http://my.site.com/login"
/>

Manage Subscriptions Status Bar

PropertyTypeDescription
statusLabelString, JSX ElementStatus Label
statusInputPlaceholderStringStatus Input Placeholder
statusRenderInputContentFunctionStatus Render Input Content
actionLabelString, JSX ElementAction Label
actionInputPlaceholderStringAction Input Placeholder
actionCancelReasonsArrayAction Cancel Reason Options List
actionBarCancelSubscriptionButtonContentString, JSX ElementAction Bar Cancel Subscription Button Content
actionBarSubmitButtonContentString, JSX ElementAction Bar Submit Button Content
actionBarCancelButtonContentString, JSX ElementAction Bar Cancel Button Content
actionBarRenewSubscriptionButtonContentString, JSX ElementAction Bar Renew Subscription Button Content
actionBarRenewSubscriptionRenderLabelContentFunctionAction Bar Renew Subscription Render Label Content
actionBarShowSubscriptionsButtonContentString, JSX ElementAction Bar Show Subscriptions Button Content
actionBarShowSubscriptionsLabelContentString, JSX ElementAction Bar Show Subscriptions Label Content
actionAlertSuccessContentString, JSX ElementAction Alert Success Content
actionAlertErrorContentString, JSX ElementAction Alert Error Content
actionAlertDurationNumberAction Alert Duration
loadingIndicatorString, JSX ElementLoading Indicator
renewSubscriptionCampaignIDString, Number"Renew Subscription" CampaignID
showSubscriptionsCampaignIDString, Number"Show Subscription" CampaignID
renewSubscriptionURLStringRenew Subscription URL
showSubscriptionOptionsURLStringShow Subscription Options URL
stylesObjectObject containing all custom class and styling props
<ManageSubStatusBar
  statusLabel="Current Subscription"
  statusInputPlaceholder=""
  statusRenderInputContent={subObj => `${subObj.productName} - ${subObj.subscriptionID}`}
  actionLabel="Reason for Cancellation"
  actionInputPlaceholder="Select reason..."
  actionCancelReasons={[
    "Price is too expensive"
    "Didn't utilize my subscription enough"
    "Found a service I like better"
    "I just don't want it anymore"
  ]}
  actionBarCancelSubscriptionButtonContent="Cancel Subscription"
  actionBarSubmitButtonContent="Submit & Cancel"
  actionBarCancelButtonContent="Nevermind"
  actionBarRenewSubscriptionButtonContent="Renew subscription"
  actionBarRenewSubscriptionRenderLabelContent={(subObj) => {
    return (<><i className="mr-2">{subObj.productName}</i>subscription has expired</>);
  }}
  actionBarShowSubscriptionsButtonContent="Show subscription options"
  actionBarShowSubscriptionsLabelContent={(<i className="mr-2">No current subscriptions</i>)}
  actionAlertSuccessContent="Subscription Cancellation Successful!"
  actionAlertErrorContent="Subscription Cancellation Failed"
  actionAlertDuration={4000}
  loadingIndicator={(<div className="alert alert-warning">Loading data...</div>)}
  renewSubscriptionCampaignID={12345}
  showSubscriptionsCampaignID={67890}
  renewSubscriptionURL="/packages-feature-subscriptions-src-children-retail-spa-spa#/campaign"
  showSubscriptionOptionsURL="/packages-feature-subscriptions-src-children-retail-spa-spa#/campaign"
  styles={stylesObject}
/>

Order History Table

Creates a responsive, sortable table of the user's order history with expandable rows for overflowing fields (dynamic/responsive)

PropertyTypeDescription
titleStringTitle to use on the table
displayConfigFunctionFunction that returns a configuration object used for providing table display parameters to child Table component
stylesObjectObject containing all custom class and styling props
<OrderHistoryTable
  title="Table Title"
  styles={stylesObject}
  displayConfig={displayType => ({
    mobile: {
      numColumns: 2,
      displayClasses: `d-${displayType} d-sm-${displayType}`,
      hiddenClasses: "d-none d-sm-none",
    },
    tablet: {
      numColumns: 3,
      displayClasses: `d-md-${displayType}`,
      hiddenClasses: "d-md-none",
    },
    desktop: {
      numColumns: 5,
      displayClasses: `d-lg-${displayType} d-xl-${displayType}`,
      hiddenClasses: "d-lg-none .d-xl-none",
    },
  })}
/>

Change Password Form

This allows a user to change their password to their account. They must already be signed into their account in order to use this form.

PropertyTypeDescription
headerStringTitle shown above the form
headerClassesStringClasses to apply to the header text
loadingStringText to display for the loading message
loadingClassesStringClasses to apply to the loading text
wrapperClassesStringClasses to apply to the div around the form
errorClassesStringClasses to apply to the error messages return from the form
successClassesStringClasses to apply to the success messages return from the form
oldPasswordPropsObjectValues passed to the passwordInput component used for the old password input field
newPasswordPropsObjectValues passed to the passwordInput component used for the new password input field
confirmPasswordPropsObjectValues passed to the passwordInput component used for the confirm password input field
saveChangesButtonPropsObjectValues passed to the button component used to save changes
defaultTextObjectLocalzation of text and error codes
<ChangePassword
  loading="Loading, please wait..."
  successClasses: "text-success mb-2",
  newPasswordProps: {{
    label: "Enter Your New Password",
  }}
/>

Magic Link Form

This allows a user to request a one time access code to login to their account if they've forgotten their password. It requires a nonce be sent to them with a link to their email address in the format of https://my.site.com/{subscriptions-url}?nonce={nonce}/#magic-link

React PropTypeDescription
wrapperClassStringClasses applied to the wrapper div
successUrlStringThe url to redirect to when a successful nonce is verified
successTextStringThe text to show when a nonce is successfully verified
nonceStringThe nonce to verify (will check from the URL by default but can also be passed as a prop)

<MagicLinkForm />

Sign Out Form

When a user is logged in and this form is rendered this form will automatically clear their session and display options to allow them to log back in, create a new account, or go back to the homepage.

React PropTypeDescription
pageTextStringText to show above the links on the page
wrapperClassesStringClasses to apply to the wrapper div
textClassesStringClasses to apply to the text at the top of the sign out form
homeTextStringThe text for the home url link
homeUrlStringThe url for redirecting the user back to the homepage
redirectLinkHomeClassesStringClasses to apply to the homepage redirect link
signInTextStringThe text for the sign in url link
signInUrlStringThe url for redirecting the user to the sign in page
redirectLinkSignInClassesStringClasses to apply to the sign in url
signUpTextStringThe text for the sign up url link
signUpUrlStringThe url for redirecting the user to the sign up page
redirectLinkSignUpClassesStringClasses to apply to the sign up url
<SignOutForm
  pageText="You have successfully logged out!"
/>

Google Sign On

Creates an out-of-the-box Sign On with Google feature.

Required Setup
  1. The correct google ID must be setup in the Subs Admin for the particular tenant (apiOrigin).
  2. The component must be placed on a valid https page. (For local development ngrok was used).
React PropTypeDescription
configObjectthe object containing all the configurations for the GoogleSignOn feature.
stylesObjectthe object containing all the styling classes for the GoogleSignOn feature.
textObjectthe object containing all the error messages for the Google Sign On Feature
redirectLinkStringthe url to which the user gets redirected after a successful Google sign on.
googleButtonWidthNumberwidth in pixels accepted by the Google Sdk (Defaults to 120).
googleButtonHeightNumberheight in pixels accepted by the Google Sdk (Defaults to 36).
googleButtonLongTitleBooleanboolean value that sets whether to display long labels such as "Sign in with Google" rather than "Sign in" (Defaults to false).
googleButtonThemeStringThe color theme of the button: either light or dark (defaults to "light").
wrapperClassesStringclasses to style the button wrapper
sdkErrorClassesStringclasses to style the error message in case the google sdk fails to load.
signOnErrorClassesStringclasses to style the error message in case the google Sign in fails.
successCallbackFunctionfunction that is invoked after a succesful sign on
failureCallbackFunctionfunction that is invoked after a failed sign on
attemptCallbackFunctionfunction that is invoked after the button click
sdkErrorMessageStringerror message to be displayed in case the Google sdk fails to load
signOnErrorMessageStringerror message to be displayed in case the Google sign on fails for any reason
Additional Customizations

More Google button customization options are available on https://developers.google.com/identity/sign-in/web/reference#ui_elements

  <GoogleSignOn
  config= {{
    redirectLink: "/profile",
    googleButtonWidth: 400,
    googleButtonHeight: 40,
    googleButtonLongTitle: true,
    googleButtonTheme: "dark",
  }}
  styles={{
    wrapperClasses: "d-flex flex-column align-items-center justify-content-center mt-3",
    sdkErrorClasses: "text-danger",
    signOnErrorClasses: "text-danger",
  }}
  />

Facebook Sign On

Creates an out-of-the-box Sign On with Facebook feature.

Required Setup
  1. The correct facebook APP ID and App Secret must be setup in the Subs Admin for the particular tenant (apiOrigin).
  2. The component must be placed on a valid https page. (For local development ngrok was used).
React PropTypeDescription
configObjectthe object containing all the configurations for the FacebookSignOn feature.
stylesObjectthe object containing all the styling classes for the FacebookSignOn feature.
textObjectthe object containing all the error messages for the FacebookSignOn Feature
redirectStringthe url to which the user gets redirected after a successful facebook sign on.
fbButtonSizeStringthe size of the button configured by the facebook sdk, can be "large", "medium" or "small". Defaults to "large".
fbButtonTypeStringthe button text accepted by the facebook sdk, must be either "login_with" or "continue_with". Defaults to "login_with".
fbIncludePictureBooleana boolean value accepted by the facebook sdk that allows the component to either include the name and profile picture when the user is signed into Facebook or not.
wrapperClassesStringclasses to style the button wrapper
sdkErrorClassesStringclasses to style the error message in case the Facebook sdk fails to load.
signOnErrorClassesStringclasses to style the error message in case the Facebook Sign On fails.
successCallbackFunctionfunction that is invoked after a succesful sign on
failureCallbackFunctionfunction that is invoked after a failed sign on
attemptCallbackFunctionfunction that is invoked after the button click
sdkErrorMessageStringerror message to be displayed in case the Facebook sdk fails to load
signOnErrorMessageStringerror message to be displayed in case the Facebook Sign On fails for any reason
  <FacebookSignOn
  config={{
    fbButtonSize: "medium",
    fbButtonType: "continue_with",
    }}
  styles={{
    wrapperClasses: "border border-success d-flex justify-content-center"
  }}
  />

Retail & Sales

This allows you to use pre-built solutions for managing campaigns, displaying products, adding/removing items to your cart, payment processing and confirmation of your purchases.

SPA Configuration

This is a Single Page App that has all of the pre-configured workflow already setup and ready for you to customize and start using.

PropertyTypeDescription
useCookies (required)BooleanWhether or not to use cookies
autoLoginBooleanAutomatically login via a cookie or local storage
checkoutUrlStringHash fragment used when user selects an offer
loginUrlStringHash fragment used when user needs to login
addItemToCartFailureUrlStringHash fragment used when we encounter an error adding an item to the cart
confirmationPageRedirectLinkURLStringHash fragment used when user clicks the "Start Reading" button on the confirmation page
errorUrlStringHash fragment used when an error is encountered
confirmUrlStringHash fragment used when user has paid
offersUrlStringHash fragment used when the user is looking at offers
recaptcha (required)ObjectConfig for recaptcha
registerUrlStringHash fragment used when user wants to create a new account

Hash Routes

These are the hash routes used in the retail SPA:

#/ and #/campaign – This pulls up the campaign to display the products and subscriptions available for purchase. This uses data from a content source.

#/checkout – This displays the items currently in the user’s shopping cart.

#/confirmation – This displays a confirmation message after the payment has been successfully processed by the payment processor.

#/error – This is the default error message if something has gone wrong at any point during this process.

SPA Sample Usage

This will create the retail spa with debugging messages.

import Subscriptions from '@dmn-arc-core-components/feature_subscriptions';

<Subscriptions.RetailSPA
  debug={true}
  styles={this.props.styles}
  config={this.props.configuration}
  localization={this.props.translatedMessages}
  offersData={this.props.offers}
/>

SPA Localization

All text within the SPA can be localized by passing a custom localization object with alternative/translated content. For a full list of all text that can be customized please see the localization section below.

SPA Styles

By default we provide bootstrap classes on all components for you. In order to match the look and feel of your project we expose certain classes within the SPA that you can set to your existing CSS classes. For a full list of all styles that can be customized please see the styles section below.

Retail Forms

  1. Campaign - displays a list of the current products in a campaign
  2. Cart - displays a list of items in the user's shopping cart along with

Campaign Form

Allows a user to view the information related to a campaign in form of a headline image, headline text and one or several products. If a product contains several rates, the user has the option to select one, the product then being added to the user cart.

PropertyTypeDescription
offersObject (required)ObjectThe object that contains all the offer related information that has been set up in the Subscriptions Admin
productCardsContainerPropsObjectProperties (text and styles) applied to the productCardsContainer element
headlineImagePropsObjectProperties (text and styles) applied to the HeadlineImage element
disclaimerMessagePropsObjectProperties (text and styles) applied to the Header (Disclaimer Message) component
checkoutUrlStringThe url of the checkout page where the user is able to interact with the current contents of their cart
loginUrlStringThe url of the login page where the user can either login or register and then proceed to checkout without losing the contents of their cart
addItemToCartFailureUrlStringThe url of the page on which the user lands in case the add to cart process fails
  <Subscriptions.Campaign
    checkoutUrl= "/checkout"
    loginUrl= "/login"
    addItemToCartFailureUrl= "/404"
    headlineImageProps={{
      wrapperClasses: String
      wrapperStyles: Object,
      smBrkPnt: String,
      mdBrkPnt: String,
      pageTitleSize: Number,
      titleClasses: String,
      pageSubTitleSize: Number,
      subTitleClasses: String,
    }}
    productCardsContainerProps= {{
      cardsWrapper: String,
      productCardsProps: {
        wrapperClasses: String,
        headerProps: {
          className: String,
        },
        unorderedListProps: {
          wrapperClasses: String,
          itemClasses: String,
        },
        getOfferButtonProps: {
          className: String,
        },
        lazyLoadingImageProps: {
          wrapperClasses: String,
          imageSrc: String,
          imageAlt: String,
          imageClasses: String,
          loaderSrc: String,
          loaderAlt: String,
          loaderClasses: String,
        },
        productPriceRadioButtonsProps: {
          wrapperClasses: String,
          label: String,
          labelClasses: String,
          radioContainerClasses: String,
        },
        singleProductPriceFieldProps: {
        size: Number,
        className: String,
        },
      },
    }}
    disclaimerMessageProps= {{
      size: Number,
      children: String,
      className: String,
    }}
    offersObject= {OFFERS_OBJECT}
  />

Notes on the OFFERS_OBJECT

In the current implementation with Fusion, the offers object is returned by making an api call that uses the campaign-name as a URI parameter, which is editable via a custom field.

A resolver needs to be setup in the sources folder, that would handle the API assembly logic.

const resolve = (params) => {
  const website = params['my-site'];
  const { 'campaign-name' } = params;
  return `https://api-${org}-${website}.cdn.arcpublishing.com/retail/public/v1/offer/live/${campaign-name}`;
};

export default {
  resolve,
  params,
};

The resolver can then be called inside the feature, passing the returned offers object to the Campaign component as a property.

    ...
    const { cached, fetched } = this.getContent('offers', { campaignName: props.customFields.defaultCampaign });
    this.state = { offers: cached };
    fetched.then((offers) => {
      this.setState({ offers });
    });
    ...
    ...
    ...
    render(){
      return(
        <Subscriptions.Campaign
          ...
          ...
          offersObject= {this.state.offers}
        />
      )
    }
    ...

Cart Form

This will quickly create a cart that displays a user's items they are trying to purchase, allows them to remove items, and provides a summary for the cost of those items.

PropertyTypeDescription
config (required)ObjectAn object containing the cart's configuration
localizationObjectAn object that includes the default text and error messages for the cart
stylesObjectAn object with style classes
import Subscriptions from '@dmn-arc-core-components/feature_subscriptions';

<Subscriptions.Cart />

Paywall

The paywall is comprised of two parts:

  1. A portal component that loads the paywall script (p.js) and runs it to check the user's registration status.

  2. A modal with contents, buttons, links etc wrapped by the portal.

If you want the prebuilt modal contents you can pass a PaywallModal component into the PaywallPortal. Otherwise pass in your own children if you need something more flexible. It's pretty barebones so this will most likely happen.

Paywall Domains

  1. apiOrigin and paywallScriptSrc should look like the following:
  1. If you add https:// to the paywallApiOrigin ArcP which is the paywall script adds https twice, it will break.

  2. The domain of paywallScriptSrc and paywallApiOrigin have to be the same, if they're not you get a CORS error and you'll get an error that the entitlement check failed (this is an under the hood request ArcP makes to the sales api to determine user registration).

  3. You will need versions of these url's for both sandbox and production. It's best to keep them in site properties for each of your sites.

Paywall p.js Script (ArcP)

  1. This will be located at https://my.site.cdn.arcpublishing.com/arc/subs/p.js

  2. If it's not available you will need to have it provisioned by the Arc Delivery team (DEL - minimum 1 week lead time).

  3. The p.js script is generated when you activate a paywall in the subs admin. Only one paywall can be active at a time. When you activate a new paywall you will get a new p.js. If you don't and the rules aren't updating when you run ArcP on the frontend, contact arc subscriptions support.

  4. You can type ArcP into the browser console to make sure the p.js script loaded (loaded by PaywallPortal via the paywallScriptSrc) properly.

  5. You can furthermore type ArcP._facts or ArcP._rules to see what facts were collected about the user and which paywall ruleset is being loaded from the admin. The _facts a