Astra Web App SDK

Installation

Add the Astra initialize script to the <head> of your app's root HTML file

// Sandbox URL
<script src="https://web-sdk-sandbox.astra.finance/v1/initialize.js"></script>

// Production URL
<script src="https://web-sdk.astra.finance/v1/initialize.js"></script>

Getting Started

To initialize the Astra Web App in your application, Astra.create creates a handler that accepts the following parameters:

try {
  const handler = Astra.create({
    actionType,
    actionType,
    business,
    businessProfileId,
    bypassConnect,
    clientId,
    debitDirect,
    onAuth: (code, oAuthState) => {},
    onClose,
    onError: (errorMessage) => {},
    phone,
    phoneReadOnly,
    redirectUri,
    sessionToken,
    state,
    userId,
    userIntentId,
  });
} catch (e) {
  // handle error
}

Create

actionType string, required

The authorization action for the User. Must be one of the following values:

COLLECT_AUTHORIZATION

VERIFY_PROFILE

SUBMIT_DOCUMENT

LINK_ACCOUNT

LINK_CARD

Please refer to the official Astra documentation for more information: OAuth Links and Parameters

clientId string, required

Your Astra Client ID

redirectUri string, required

The redirect URI for your Client (this must match your Developer Account settings)

onAuth callback, required if using COLLECT_AUTHORIZATION action type

Callback function that accepts two parameters, code and state

code string

Temporary token used to generate an access_token for API request

state string

The optional state parameter passed to .create()

business boolean, optional

Use the business account verification flow

businessProfileId string, optional

The ID associated with a Business Profile. When provided, this pre-populates the business information fields in the form, based on the existing business profile.

bypassConnect boolean, optional

Skip the connect accounts screen

debitDirect boolean, optional

Only ask for one debit card. For debit enabled clients only.

onClose callback, optional

Callback function utilized after a close event.

onError callback, optional

Callback function that accepts one parameter, errorMessage

errorMessage string

A description of the Error encountered during auth flow

phone string, optional

The User's phone number, to prefill the phone number field (10 digit format 5557771234)

phoneReadOnly boolean, optional

Lock the phone number field

sessionToken string, optional

The short-lived token generated for trusted authenticatio

state string, optional

A custom query string. Could be used as a parameter to pass through to a redirect URI to better control the UX navigation.

userId string, optional

The ID of the User. We recommend including this parameter if the user (business or personal) has successfully onboarded.

userIntentId string, optional

The ID of the User Intent (when included the User can bypass manually entering profile details)

Handler

The handler returns two methods:

open

Opens the Astra Web App in an iframe and begins your authentication session

handler.open();

exit

Ends your authentication session and removes the iframe

handler.exit();