braintree-web

WebJar for braintree-web

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

braintree-web
Last Version

Last Version

3.55.0
Release Date

Release Date

Type

Type

jar
Description

Description

braintree-web
WebJar for braintree-web
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/braintree/braintree-web

Download braintree-web

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/braintree-web/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>braintree-web</artifactId>
    <version>3.55.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/braintree-web/
implementation 'org.webjars.npm:braintree-web:3.55.0'
// https://jarcasting.com/artifacts/org.webjars.npm/braintree-web/
implementation ("org.webjars.npm:braintree-web:3.55.0")
'org.webjars.npm:braintree-web:jar:3.55.0'
<dependency org="org.webjars.npm" name="braintree-web" rev="3.55.0">
  <artifact name="braintree-web" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='braintree-web', version='3.55.0')
)
libraryDependencies += "org.webjars.npm" % "braintree-web" % "3.55.0"
[org.webjars.npm/braintree-web "3.55.0"]

Dependencies

compile (13)

Group / Artifact Type Version
org.webjars.npm : credit-card-type jar [8.3.0]
org.webjars.npm : braintree__browser-detection jar [1.9.0]
org.webjars.npm : card-validator jar [6.2.0]
org.webjars.npm : promise-polyfill jar [8.1.3]
org.webjars.npm : braintree__asset-loader jar [0.3.1]
org.webjars.npm : restricted-input jar [2.1.0]
org.webjars.npm : braintree__iframer jar [1.0.3]
org.webjars.npm : inject-stylesheet jar [2.0.0]
org.webjars.npm : braintree__class-list jar [0.1.0]
org.webjars.npm : framebus jar [3.0.2]
org.webjars.npm : braintree__sanitize-url jar [4.0.0]
org.webjars.npm : braintree__event-emitter jar [0.3.0]
org.webjars.npm : braintree__wrap-promise jar [2.0.0]

Project Modules

There are no modules declared in this project.

braintree-web

A suite of tools for integrating Braintree in the browser.

This is the repo to submit issues if you have any problems or questions about a Braintree JavaScript integration.

For a ready-made payment UI, see Braintree Web Drop-in.

Install

npm install braintree-web
bower install braintree-web

Usage

For more thorough documentation, visit the JavaScript client SDK docs.

If you are upgrading from version 2.x, take a look at our migration guide.

Hosted Fields integration

<form action="/" id="my-sample-form">
  <input type="hidden" name="payment_method_nonce">
  <label for="card-number">Card Number</label>
  <div id="card-number"></div>

  <label for="cvv">CVV</label>
  <div id="cvv"></div>

  <label for="expiration-date">Expiration Date</label>
  <div id="expiration-date"></div>

  <input id="my-submit" type="submit" value="Pay" disabled/>
</form>
var submitBtn = document.getElementById('my-submit');
var form = document.getElementById('my-sample-form');

braintree.client.create({
  authorization: CLIENT_AUTHORIZATION
}, clientDidCreate);

function clientDidCreate(err, client) {
  braintree.hostedFields.create({
    client: client,
    styles: {
      'input': {
        'font-size': '16pt',
        'color': '#3A3A3A'
      },

      '.number': {
        'font-family': 'monospace'
      },

      '.valid': {
        'color': 'green'
      }
    },
    fields: {
      number: {
        selector: '#card-number'
      },
      cvv: {
        selector: '#cvv'
      },
      expirationDate: {
        selector: '#expiration-date'
      }
    }
  }, hostedFieldsDidCreate);
}

function hostedFieldsDidCreate(err, hostedFields) {
  submitBtn.addEventListener('click', submitHandler.bind(null, hostedFields));
  submitBtn.removeAttribute('disabled');
}

function submitHandler(hostedFields, event) {
  event.preventDefault();
  submitBtn.setAttribute('disabled', 'disabled');

  hostedFields.tokenize(function (err, payload) {
    if (err) {
      submitBtn.removeAttribute('disabled');
      console.error(err);
    } else {
      form['payment_method_nonce'].value = payload.nonce;
      form.submit();
    }
  });
}

Advanced integration

To be eligible for the easiest level of PCI compliance (SAQ A), payment fields cannot be hosted on your checkout page. For an alternative to the following, use Hosted Fields.

braintree.client.create({
  authorization: CLIENT_AUTHORIZATION
}, function (err, client) {
  client.request({
    endpoint: 'payment_methods/credit_cards',
    method: 'post',
    data: {
      creditCard: {
        number: '4111111111111111',
        expirationDate: '10/20',
        cvv: '123',
        billingAddress: {
          postalCode: '12345'
        }
      }
    }
  }, function (err, response) {
    // Send response.creditCards[0].nonce to your server
  });
});

For more examples, see the reference.

Promises

All the asynchronous methods will return a Promise if no callback is provided.

var submitBtn = document.getElementById('my-submit');
var yourStylesConfig = { /* your Hosted Fields `styles` config */ };
var yourFieldsConfig = { /* your Hosted Hields `fields` config */ };

braintree.client.create({authorization: CLIENT_AUTHORIZATION}).then(function (client) {
  return braintree.hostedFields.create({
    client: client,
    styles: yourStylesConfig,
    fields: yourFieldsConfig
  });
}).then(function (hostedFields) {
  submitBtn.addEventListener('click', function (event) {
    event.preventDefault();
    submitBtn.setAttribute('disabled', 'disabled');

    hostedFields.tokenize().then(function (payload) {
      // send payload.nonce to your server
    }).catch(function (err) {
      submitBtn.removeAttribute('disabled');
      console.error(err);
    });
  });
});

Releases

Subscribe to this repo to be notified when SDK releases go out.

License

The Braintree JavaScript SDK is open source and available under the MIT license. See the LICENSE file for more info.

org.webjars.npm

Braintree

Versions

Version
3.55.0
3.46.0
3.42.0
2.18.0
2.17.4