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

react-authorize-net

v0.5.7

Published

React integration for Authorize.Net

Downloads

1,105

Readme

Modern and idiomatic React interface to Authorize.Net.

Why

Integrating the Authorize.Net platform with a modern web application can be painful.

Their whole platform is very unfriendly to SPAs and even more so to the beautiful programming model offered by React.

The main goal of this library is to abstract some of this pain away.

Features

  • Modern idiomatic React interface to Authorize.Net
  • Small API surface
  • Fully typed interface (using TypeScript)
  • Quick and easy integration in any modern React stack
  • Elegant and beautiful form UX available by default
  • Simple authentication with Authorize.Net platform
  • Easy validation of user input

Installation

ES Module

npm install --save react-authorize-net

API

<FormContainer />

This component can be used to easily implement and integrate a payment form in a React application.

Props

clientKey

string

Your Authorize.Net Client Key.

apiLoginId

string

Your Authorize.Net API Login ID.

amount

number

The amount of money that is being charged by the payment form.

environment

"sandbox" | "production"

Which underlying Accept.js library to use.

The libaries are unique to both Authorize.Net environments (production and sandbox), so it is important to load the sandbox library if you are testing transactions, and to use the production library for live transaction processing, as shown below.

onSuccess

(response: Accept.Response) => void

Function called on successful reception of payment nonce.

onError

(errors: string[]) => void

Function called on failed form submission.

render

FormContainer expect a function returning some React elements (a component) passed in the render prop. This should allow for maximum flexibility during the implementation of your payment form UX.

This function will be called with an object containing the following properties:

values

{ cardCode: string, cardNumber: string, expDate: string }

values represents the values backing your underlying input elements.

handleChange

(keyof FormType, React.ChangeEvent<any>) => React.ChangeEvent<any>

handleChange is the callback used to notify FormContainer about changes to the raw values backing your form inputs.

validationErrors

{ cardCode: boolean, cardNumber: boolean, expDate: boolean }

validationErrors is an object used to represent any invalid state (invalid user input) present in your payment form.

The validation is made according to the shape of data that Authorize.Net API is expecting.

apiErrors

[]string

apiErrors represents any errors that Authorize.Net API might return while making the underlying API request.

<AcceptHosted />

This component allows you to create forms that are fully SAQ-A compliant, through an idiomatic and easy-to-use API.

It is essentially a wrapper around Accept Hosted.

Styling

Custom styles can be applied to the form by supplying an appropriate style or className prop.

Custom element

The button used to trigger the actual payment form can be customized by using the children prop.

<AcceptHosted formToken={'...'}>
  <button>Pay now</button>
</AcceptHosted>

Props

formToken

string

formToken is used to represent the transaction itself.

It is returned by Authorize.Net API.

mode

'sandbox' | 'production'

If you're using the sandbox environment or not.

type

'redirect' | 'iframe'

Renders the form either as an iframe or redirect link.

More information

onResize

(width: number, height: number) => void

Called for every resizeWindow messages from Accept Hosted.

onCancel

() => void

Called for every cancel messages from Accept Hosted.

onTransact

(response: TransactionResponse) => void

Called for every transactResponse messages from Accept Hosted.

onReceiveCommunication

(queryStr: string) => void

Low level handler for raw communication between Accept Hosted and client code.

onMessage

(message: Message) => void

Called for every valid messages coming from Accept Hosted.

How to use

Code sample

You can use this repo as a reference point on how to integrate the library in an existing React application.

Commercial support

Are you having trouble integrating Authorize.Net with the rest of your infrastructure? Do you need a feature that is not supported in react-authorize-net yet?

Reach out at [email protected]!