npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@dwolla/react-drop-ins

v1.1.0

Published

React bindings for Dwolla's drop-in components

Downloads

7,057

Readme

react-drop-ins npm version

React bindings for Dwolla's drop-in components. This library provides a React hook for importing the dwolla-web.js library and a set of React components for using the drop-in components.

Table of Contents

Installation

# using npm
$ npm i @dwolla/react-drop-ins

# using yarn
$ yarn add @dwolla/react-drop-ins

# using pnpm
$ pnpm add @dwolla/react-drop-ins

Examples

An example React component demonstrating how to use the library and the DwollaCustomerCreate component can be found in the examples directory.

Storybook

View a live demo of all components. Switch to the Docs tab and click on Show code to see the implementation code for each component.

Usage

In order to use this package, you will first need to set up your application to be able to make calls to the Dwolla API. You can use one of our SDKs in your preferred language to get up and running quickly.

Then you will need to set up a server-side endpoint for generating client tokens. You can do this by following the steps in the Generate a Client Token guide.

You're now ready to start using the package!

Create a configuration object for the useDwollaWeb hook as shown in the code example below. This hook will import the dwolla-web.js library and handle any errors that may occur during import.

The full list of configuration options for the hook can be found in the table below.

// Import the useDwollaWeb hook and the DwollaCustomerCreate component
import { DwollaCustomerCreate, useDwollaWeb } from '@dwolla/react-drop-ins';
import type { DwollaWebOptions } from '@dwolla/react-drop-ins';

// Create configuration for the useDwollaWeb hook
const config: DwollaWebOptions = {
environment: 'sandbox',
onError: function error() {
    console.log('Error');
},
onSuccess: function success() {
    console.log('Success');
},
tokenUrl: '/yourTokenUrl'
};

const App = () => {
  // Initialize the useDwollaWeb hook
  const { ready, error } = useDwollaWeb(config);

  // Wait for the hook to be ready
  if (!ready) return <div>Loading...</div>;

  // Handle errors
  if (error) return <div>Error</div>;

  // Render the DwollaCustomerCreate component when ready
  return (
    <>
      <DwollaCustomerCreate />
    </>
  );
};

export default App;

Configuration options for useDwollaWeb

| Parameter | Type | Required? | Description | | ----------- | -------- | ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | environment | string | yes | Acceptable values of: sandbox or production | | styles | string | no | Optional. A relative or absolute URL linking to a hosted stylesheet containing component styles. | | token | function | conditional | 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"})) Not required if tokenUrl is used. | | tokenUrl | function | conditional | A URL pointing to a server-side endpoint that can be used to generate client-token. Example usage: tokenUrl: "tokenUrl". Not required if token is used. | | success | function | no | A function that gets called upon a successful request from the Component. | | error | function | no | A function that gets called when an error occurs in the Component. |

Note: You can use either token or tokenUrl in the config options for generating a client token, but not both. Check out the tokenUrl vs token configuration section in the docs for more information on the differences between the two.

Changelog

  • 1.1.0 Updated Dwolla Web to v2.2.0, and added new component implementations. See GitHub Releases for more information.
  • 1.0.1 Initial release of React bindings for Dwolla's drop-in components.

Community

Additional Resources

To learn more about Dwolla and how to integrate our product with your application, please consider visiting some of the following resources and becoming a member of our community!