All Projects → braintree → Braintree Web

braintree / Braintree Web

Licence: mit
A suite of tools for integrating Braintree in the browser

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Braintree Web

Braintree php
Braintree PHP library
Stars: ✭ 491 (+37.54%)
Mutual labels:  payments, braintree
Braintree android
Braintree SDK for Android
Stars: ✭ 343 (-3.92%)
Mutual labels:  payments, braintree
Braintree node
Braintree Node.js library
Stars: ✭ 271 (-24.09%)
Mutual labels:  payments, braintree
Braintree java
Braintree Java library
Stars: ✭ 129 (-63.87%)
Mutual labels:  payments, braintree
Braintree Android Drop In
Braintree Drop-In SDK for Android
Stars: ✭ 78 (-78.15%)
Mutual labels:  payments, braintree
Django Payments
Universal payment handling for Django.
Stars: ✭ 575 (+61.06%)
Mutual labels:  payments, braintree
Braintree ruby
Braintree Ruby library
Stars: ✭ 407 (+14.01%)
Mutual labels:  payments, braintree
Nestjs Braintree
A module for braintree reoccurring payments and transactions 💳
Stars: ✭ 62 (-82.63%)
Mutual labels:  payments, braintree
Braintree dotnet
Braintree .NET library
Stars: ✭ 109 (-69.47%)
Mutual labels:  payments, braintree
Braintree python
Braintree Python library
Stars: ✭ 217 (-39.22%)
Mutual labels:  payments, braintree
awesome-pix
Awesome PIX
Stars: ✭ 127 (-64.43%)
Mutual labels:  payments
cybersource-android-sdk
The CyberSource InApp SDK enables developers to simply and securely incorporate mobile payments into their Android applications.
Stars: ✭ 25 (-93%)
Mutual labels:  payments
Mojaloop
Starting point for on-boarding and contribution documentation for mojaloop
Stars: ✭ 267 (-25.21%)
Mutual labels:  payments
mobimoney
Cross-platform mobile payments project for React Native
Stars: ✭ 14 (-96.08%)
Mutual labels:  payments
saasform
Add signup & payments to your SaaS in minutes.
Stars: ✭ 247 (-30.81%)
Mutual labels:  payments
Android Card Form
A ready-made card form layout that can be included in your Android app, making it easy to accept credit and debit cards.
Stars: ✭ 310 (-13.17%)
Mutual labels:  payments
react-recurly
React components for Recurly.js
Stars: ✭ 38 (-89.36%)
Mutual labels:  payments
paymentgateway
Dokumentace ČSOB platební brány a jejího eAPI pro platby platebními kartami, Apple Pay, mallpay a platebními tlačítky ČSOB.
Stars: ✭ 104 (-70.87%)
Mutual labels:  payments
Laravel Stripe Webhooks
Handle Stripe webhooks in a Laravel application
Stars: ✭ 300 (-15.97%)
Mutual labels:  payments
In App Payments Flutter Plugin
Flutter Plugin for Square In-App Payments SDK
Stars: ✭ 256 (-28.29%)
Mutual labels:  payments

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].