Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-braintree-fields

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-braintree-fields

React component for braintree hosted fields

  • 0.4.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

React components to integrate Braintree hosted fields

A few small React components to make integrating Braintree's Hosted Fields easier.

Build Status

Introduction

import { Braintree, HostedField } from 'react-braintree-fields';

let getToken;
function onSubmit() {
   getToken().then((payload) => {
     console.log("nonce=" , payload.nonce)
   })
}
function onFocus(event) {
    console.log("number is focused", event);
}
<Braintree
    authorization='sandbox_g42y39zw_348pk9cgf3bgyw2b'
    onError={this.handleError}
    onCardTypeChange={this.onCardTypeChange}
    getTokenRef={ref => (getToken = ref)}
    styles={{
        'input': {
            'font-size': '14px',
            'font-family': 'helvetica, tahoma, calibri, sans-serif',
            'color': '#3a3a3a'
        },
        ':focus': {
            'color': 'black'
        }
    }}
>
    <div className="fields">
        <HostedField type="number" onFocus={onFocus} />
        <HostedField type="expirationDate" />
        <HostedField type="cvv" />
    </div>
    <button onClick={onSubmit}>Submit</button>
</Braintree>


See demo site for a working example. It renders demo.jsx

Braintree Component

Props:

  • authorization: Required, either a tokenization key or a client token
  • styles: Object containing valid field styles
  • onError: Function that will be called if an Braintree error is encountered.
  • getTokenRef: A function that will be called once Braintree the API is initialized. It will be called with a function that can be used to initiate tokenization.
    • The tokenization function will return a Promise which will be either resolved or rejected. If resolved, the promise payload will contain an object with the nonce and other data from Braintree.

HostedField Component

Props:

  • type: Required, one of:
    • 'number', 'expirationDate', 'expirationMonth', 'expirationYear', 'cvv', 'postalCode'
  • onBlur
  • onFocus
  • onEmpty
  • onNotEmpty
  • onValidityChange
  • onCardTypeChange - accepted on any field, but will only be called by type="number"
  • placeholder - A string to that will be displayed in the input while it's empty

Keywords

FAQs

Package last updated on 13 Jun 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc