Sha256: 554cb06edecc660e3b6bd3ba78f897c5ce9820d95ebeabb6d57b78912699de48

Contents?: true

Size: 1.29 KB

Versions: 5

Compression:

Stored size: 1.29 KB

Contents

SolidusPaypalBraintree.HostedForm = function(paymentMethodId) {
  this.paymentMethodId = paymentMethodId;
  this.client = null;
};

SolidusPaypalBraintree.HostedForm.prototype.initialize = function() {
  this.client = SolidusPaypalBraintree.createClient({
    paymentMethodId: this.paymentMethodId,
    useThreeDSecure: (typeof(window.threeDSecureOptions) !== 'undefined'),
  });

  return this.client.initialize().
    then(this._createHostedFields.bind(this));
};

SolidusPaypalBraintree.HostedForm.prototype._createHostedFields = function () {
  if (!this.client) {
    throw new Error("Client not initialized, please call initialize first!");
  }

  var opts = {
    _solidusClient: this.client,
    client: this.client.getBraintreeInstance(),

    fields: {
      number: {
        selector: "#card_number" + this.paymentMethodId,
        placeholder: placeholder_text["number"]
      },

      cvv: {
        selector: "#card_code" + this.paymentMethodId,
        placeholder: placeholder_text["cvv"]
      },

      expirationDate: {
        selector: "#card_expiry" + this.paymentMethodId,
        placeholder: placeholder_text["expirationDate"]
      }
    },

    styles: credit_card_fields_style
  };

  return SolidusPaypalBraintree.PromiseShim.convertBraintreePromise(braintree.hostedFields.create, [opts]);
};

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
solidus_paypal_braintree-1.2.0 app/assets/javascripts/solidus_paypal_braintree/hosted_form.js
solidus_paypal_braintree-1.1.2 app/assets/javascripts/solidus_paypal_braintree/hosted_form.js
solidus_paypal_braintree-1.1.1 app/assets/javascripts/solidus_paypal_braintree/hosted_form.js
solidus_paypal_braintree-1.1.0 app/assets/javascripts/solidus_paypal_braintree/hosted_form.js
solidus_paypal_braintree-1.0.0 app/assets/javascripts/solidus_paypal_braintree/hosted_form.js