PageSourceSearch

https://www.aeropostale.com/on/demandware.static/Sites-aeropostale…/v1791537152385/js/braintreeVenmo.js

js aeropostale.com collected 2026-10-09 21:32:09 UTC 5,793 bytes, 160 lines download raw bytes

1'use strict';
2
3/* global braintreeUtils braintree $ VenmoSession */
4
5braintreeUtils.venmo = (function () {
6    var bu = braintreeUtils;
7
8    function Constructor(initParams, $btn) {
9      var $errorContainer = $('<div class="venmo-error"></div>'); 
10      var $loaderContainter = $('<div class="braintree-loader"></div>');
11      this.$btn = $btn;
12      this.params = initParams;
13      
14      if (initParams.$errorContainer) {
15        $errorContainer = initParams.$errorContainer;
16        delete initParams.$errorContainer;
17      }
18
19      if (initParams.$loaderContainer) {
20          $loaderContainter = initParams.$loaderContainer;
21      }
22
23      $btn.after($errorContainer);
24      $btn.after($loaderContainter);
25      this.er = bu.createErrorInstance($errorContainer[0]);
26      this.loader = bu.createLoaderInstance($loaderContainter[0]);
27    }
28
29    Constructor.prototype.createVenmo = function () {
30        var that = this;
31        that.loader.show();
32
33        braintree.client.create({
34            authorization: bu.clientToken
35          }, function (clientErr, clientInstance) {
36            // Stop if there was a problem creating the client.
37            // This could happen if there is a network error or if the authorization
38            // is invalid.
39            if (clientErr) {
40              that.er.show(clientErr);
41              return;
42            }
43
44            braintree.dataCollector.create({
45                client: clientInstance,
46                paypal: true
47            }, function (dataCollectorErr, dataCollectorInstance) {
48                if (dataCollectorErr) {
49                    that.er.show(dataCollectorErr);
50                    return;
51                }
52                
53                $('#braintreeVenmoDeviceData').val(dataCollectorInstance.deviceData);
54                that.loader.hide();
55            });
56            
57            braintree.venmo.create({
58                client: clientInstance,
59                allowNewBrowserTab: false
60            }, function (venmoErr, venmoInstance) {
61                if (venmoErr) {
62                    that.er.show(venmoErr);
63                    return;
64                }
65                
66                //Verify browser support before proceeding.
67                if (!venmoInstance.isBrowserSupported()) {
68                    that.params.deviceNotSupportVenmo();
69                    that.loader.hide();
70                    return;
71                }
72
73                that.$btn.click(function(){     
74                    if (!that.params.onClick()) {
75                        return;
76                    }                  
77                    venmoInstance.tokenize(function (tokenizeErr, payload) {
78                        that.loader.show();
79
80                        if (tokenizeErr) {
81                            handleVenmoError(tokenizeErr);
82                        } 
83                        else {
84                            handleVenmoSuccess(payload);
85                        }
86                    });
87                    return;
88                });
89              });
90        });
91       
92        function handleVenmoError(err) {
93            that.er.show(err);
94            that.loader.hide();
95          }
96        function handleVenmoSuccess(payload) {
97            that.params.onTokenizePayment(payload);
98          }
99    };
100    
101    function initAccountListAndSaveFunctionality() {
102      var $accountsList = $('#braintreeVenmoAccountsList');
103      var $saveVenmoAccountCountainerEl = $('#braintreeSaveVenmoAccountContainer');
104      var $saveVenmoAccountEl = $('#braintreeSaveVenmoAccount');
105      var $venmoAccounMakeDefaultEl = $('#braintreeVenmoAccountMakeDefault');
106      var $venmoButton = $('.js_braintree_venmo_button');
107
108      function accountsListChange() { // eslint-disable-line require-jsdoc
109          if ($accountsList.val() === 'newaccount') {
110              if ($saveVenmoAccountCountainerEl.length) {
111                  $saveVenmoAccountCountainerEl.show();
112                  $saveVenmoAccountEl[0].checked = true;
113                  $saveVenmoAccountEl[0].disabled = false;
114              }
115              if ($venmoAccounMakeDefaultEl.length) {
116                  $venmoAccounMakeDefaultEl[0].disabled = false;
117              }
118          } else {
119              var selectedAccount = window.braintreeUtils.getSelectedData($accountsList[0]);
120              if (selectedAccount && $venmoAccounMakeDefaultEl.length) {
121                  if (selectedAccount['data-default'].value === 'true') {
122                      $venmoAccounMakeDefaultEl[0].disabled = true;
123                  } else {
124                      $venmoAccounMakeDefaultEl[0].disabled = false;
125                  }
126                  $venmoAccounMakeDefaultEl[0].checked = true;
127                  $venmoButton.hide();
128              }
129              if ($saveVenmoAccountCountainerEl.length) {
130                  $saveVenmoAccountEl[0].checked = false;
131                  $saveVenmoAccountCountainerEl.hide();
132              }
133          }
134      }
135
136      $saveVenmoAccountEl.change(function () {
137          if ($saveVenmoAccountEl[0].checked) {
138              $venmoAccounMakeDefaultEl[0].disabled = false;
139              $venmoAccounMakeDefaultEl[0].checked = true;
140          } else {
141              $venmoAccounMakeDefaultEl[0].disabled = true;
142              $venmoAccounMakeDefaultEl[0].checked = false;
143          }
144      });
145
146      if ($accountsList.length) {
147          $accountsList.change(accountsListChange);
148          accountsListChange();
149      }
150  }
151
152    return {
153        init: function (params, $btn) {
154            var ins = new Constructor(params, $btn);
155            bu.clientToken = params.clientToken;
156            return ins.createVenmo();
157        },
158        initAccountListAndSaveFunctionality: initAccountListAndSaveFunctionality
159    };
160}());

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.