Giter VIP home page Giter VIP logo

react-authorize-net's Introduction

react-authorize-net

Modern react integration layer for the Accept.js library.

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 Accept.js
  • 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.

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.

react-authorize-net's People

Contributors

j-em avatar jeremy-hunter avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.