Dwolla’s Drop-in Components are low-code solutions to abstract away the complexity of integrating with a payment API and act as a shortcut to completing a payment integration.
tokenUrl
or token
configuration.
tokenUrl
option when configuring dwolla-web.js requires creating a server-side endpoint that can be called by the library when an action needs to be performed within a flow component. Establishing an endpoint enables the ability for the component to fetch client-tokens on-demand in order to render the appropriate UI. The server-side endpoint should act as a pass-through by taking in the request body required in order to make the appropriate call to the ‘/client-tokens’ endpoint. Upon success, the ‘/client-tokens’ endpoint will return a response body including a “token” string value. The HTTP response that is returned to the client-side is expecting an object in the format of {token: 'Token string value'}
. More information on configuration of dwolla-web.js can be found in step 3 of this guide.
dwolla-web.js
when the component that’s being used needs to generate a client token that’s being performed in the flow.
tokenUrl
token
option when configuring the dwolla-web.js library allows you to create a function that calls your server-side tokenUrl
endpoint (as described above). The function you create takes in two arguments, 1) the request body that is required to make the ‘/client-tokens’ API request; and 2) a JSON object that includes key:value pairs for specifying custom headers. When an action needs to be performed within a flow component, the dwolla-web.js library will call your custom function and dynamically pass in a request body as the first argument. The server-side endpoint should act as a pass-through by taking in the request body required in order to make the appropriate call to the ‘/client-tokens’ endpoint. Upon success, the ‘/client-tokens’ endpoint will return a response body including a “token” string value. The HTTP response that is returned to the client-side is expecting an object in the format of {token: 'Token string value'}
.
tokenUrl
using Expresstoken
Parameter | Type | Description |
---|---|---|
environment | string | Acceptable values of: sandbox or production |
styles | string | Optional. A relative or absolute URL linking to a hosted stylesheet containing component styles. |
token | function | A function that gets called by the component for fetching client-tokens as needed throughout the flow. Example usage: token: (req) => Promise.resolve(dwollaAPIToken(req, {blah: "abcd"})) |
tokenUrl | function | A URL pointing to a server-side endpoint that can be used to generate client-token. Example usage: tokenUrl: "tokenUrl" |
success | function | A function that gets called upon a successful request from the Component. |
error | function | A function that gets called when an error occurs in the Component. |
tokenUrl
token
customerId
element in order to initialize the component. This Customer ID should come from your back-end server when generating a client-token for an end user/Customer and can optionally be stored in a session or cookie.
dwolla-success
and dwolla-success-message
dwolla-error
and dwolla-error-message
We have encountered an issue fetching a token.
resource
which denotes the resource in the API related to the action being performed, and a response
which contains any relevant information from the API response. If the component creates a new resource in the API, the response
will contain a location
key:value pair including a link to the created resource. Otherwise, it will contain the JSON response body from the API that corresponds to the action that occurred.
Here are some example responses you can expect in the success callback: