# react-recurly-modal

> [![forthebadge](https://forthebadge.com/images/badges/its-not-a-lie-if-you-believe-it.svg)](https://forthebadge.com) [![forthebadge](https://forthebadge.com/images/badges/built-with-love.svg)](https://forthebadge.com)

Latest version **1.0.2** (published 2020-04-15) · ISC license · 0 weekly downloads

## Install

```sh
npm install react-recurly-modal
pnpm add react-recurly-modal
yarn add react-recurly-modal
bun add react-recurly-modal
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2020-04-15 |
| First published | 2020-03-18 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 9 |
| Unpacked size | 145.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 11 |
| Maintainers | mrothery |

## Links

- npm: https://www.npmjs.com/package/react-recurly-modal
- Repository: https://github.com/matthewrothery/react-recurly-modal
- Issues: https://github.com/matthewrothery/react-recurly-modal/issues
- npm.io page: https://npm.io/package/react-recurly-modal

## Dependencies (9)

- [react](https://npm.io/package/react.md) ^16.8.6
- [moment](https://npm.io/package/moment.md) ^2.24.0
- [react-dom](https://npm.io/package/react-dom.md) ^16.8.6
- [class-autobind](https://npm.io/package/class-autobind.md) ^0.1.4
- [@recurly/react-recurly](https://npm.io/package/@recurly/react-recurly.md) ^1.1.1
- [@fortawesome/react-fontawesome](https://npm.io/package/@fortawesome/react-fontawesome.md) ^0.1.4
- [@fortawesome/fontawesome-svg-core](https://npm.io/package/@fortawesome/fontawesome-svg-core.md) ^1.2.19
- [@fortawesome/free-solid-svg-icons](https://npm.io/package/@fortawesome/free-solid-svg-icons.md) ^5.9.0
- [@fortawesome/free-brands-svg-icons](https://npm.io/package/@fortawesome/free-brands-svg-icons.md) ^5.9.0

## Recent versions

- 1.0.2 (latest) — 2020-04-15
- 1.0.1 — 2020-03-19
- 1.0.0 — 2020-03-18

## README

[![forthebadge](https://forthebadge.com/images/badges/its-not-a-lie-if-you-believe-it.svg)](https://forthebadge.com) [![forthebadge](https://forthebadge.com/images/badges/built-with-love.svg)](https://forthebadge.com)

# react-recurly-modal

<p align="center"><img src="./snapshot.jpg" width="450" /></p>

# How to use

Make sure to include the recurly api
```html
<script src="https://js.recurly.com/v4/recurly.js" async></script>
```

## Sample Usage

```javascript
import React from 'react';
import { render } from 'react-dom';
import ReactRecurlyModal from './index';

class MyComponent extends React.Component {

    constructor(props) {
        super(props);
        this.onSubmit = this.onSubmit.bind(this);
        this.openModal = this.openModal.bind(this);
        this.closeModal = this.closeModal.bind(this);

        this.state = {
            open: true,
            errorMessage: null,
        }
    }

    // Open the modal
    openModal() {
        this.setState({
            open: true,
        });
    }

    // Close the modal
    closeModal() {
        this.setState({
            open: false,
        });
    }

    // Handle the submission of the form
    onSubmit(token) {
        console.log(token);

        // Perform validation and any checks

        this.setState({
            errorMessage: "Failed to process request"
        });
    }

    render() {
        return (
            <div>
                <h2>Card Details</h2>

                <input type="button" onClick={this.openModal} value={"Update Card Details"} />

                <ReactRecurlyModal
                    open={this.state.open}
                    recurlyPublicKey={"your-recurly-public-key"}
                    headerBackgroundColor={"#098dd5"}
                    headerColor={"#fff"}
                    buttonStyle={{ backgroundColor: "#098dd5", borderColor: "#098dd5" }}
                    customerEmail={"demo@website.com"}
                    customerFirstname={"Firstname"}
                    customerLastname={"Lastname"}
                    onSubmit={this.onSubmit}
                    buttonLabel={"Upgrade Account"}
                    onCancel={this.closeModal}
                    errorMessage={this.state.errorMessage}
                />
            </div>
        )
    }
}

render(
    <MyComponent />,
    document.getElementById("root")
);
```

---
_Source: https://npm.io/package/react-recurly-modal · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
