How to use the braintree-web/paypal.create function in braintree-web

To help you get started, we’ve selected a few braintree-web examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github braintree / braintree-web-drop-in / src / views / payment-method-views / paypal-view.js View on Github external
PayPalView.prototype._initialize = function () {
  var paypalButton;

  BasePaymentMethodView.prototype._initialize.apply(this, arguments);
  this._createPayPalButton();
  this.model.asyncDependencyStarting();

  PayPal.create({client: this.options.client}, function (err, paypalInstance) {
    if (err) {
      // TODO: handle errors in PayPal creation
      console.error(err);
      return;
    }

    this.paypalInstance = paypalInstance;

    paypalButton = this.getElementById('paypal-button');
    paypalButton.addEventListener('click', this._tokenize.bind(this));

    this.model.asyncDependencyReady();
  }.bind(this));
};