1"use strict"; 2paypal.Buttons.driver("angular", window.angular); 3 4angular 5.module("sfmStore") 6.controller("sfmPaymentController", function(VALIDATORS, $order, $scope, $state) { 7 var vm = this; 8 vm.abaPattern = VALIDATORS.aba; 9 vm.bankAccountPattern = VALIDATORS.bankAccount 10 vm.order = $order; 11 vm.extended = vm.order.getOrder().details.extended || false; 12 vm.tmpProfile = angular.copy(vm.order.getProfile()); 13 14 vm.checkActions = [ 15 { name: "Send invoice to Group", address: vm.school, type: "schl" } 16 ]; 17 18 $scope.$watch( 19 "vm.tmpProfile", 20 function(newVal, oldVal) { 21 if (newVal) { 22 if (oldVal.send_to === "schl" && newVal.send_to === "home") { 23 vm.tmpProfile.send_to = "home"; 24 vm.tmpProfile.send_order_to = "home"; 25 vm.tmpProfile.address_1 = ""; 26 vm.tmpProfile.address_2 = ""; 27 vm.tmpProfile.city = ""; 28 vm.tmpProfile.state_location = ""; 29 vm.tmpProfile.zip = ""; 30 vm.tmpProfile.editable = true; 31 } else if ( 32 newVal.send_to === "home" || 33 vm.tmpProfile.send_to === "home" 34 ) { 35 _.merge(vm.tmpProfile, newVal); 36 } 37 vm.order.updateProfile(vm.tmpProfile); 38 } 39 }, 40 true 41 ); 42 43 $scope.$watch("vm.profile", function(newVal) { 44 if (newVal) { 45 newVal.editable = true; 46 vm.checkActions[0].address = angular.copy(newVal); 47 } 48 }); 49 50 $scope.$watch("vm.payment.payment_method", function(newVal) { 51 if (newVal) { 52 vm.payment.payment_method = newVal; 53 if (newVal === "check") { 54 vm.payment.pay_by_check = true; 55 } else { 56 vm.payment.pay_by_check = false; 57 } 58 } 59 }); 60 61 $scope.$watch("vm.school", function(newVal) { 62 if (newVal) { 63 vm.checkActions[0].address = { 64 send_order_to: "school", 65 first_name: vm.tmpProfile.first_name || "", 66 last_name: vm.tmpProfile.last_name || "", 67 email: vm.tmpProfile.email || "", 68 address_1: newVal.School_Name || "", 69 address_2: newVal.Address || "", 70 city: newVal.City || "", 71 state_location: newVal.State || "", 72 zip: newVal.Zip || "", 73 editable: false 74 }; 75 } 76 }); 77 78 $scope.opts = { 79 createOrder: function (data, actions) { 80 return actions.order.create({ 81 purchase_units: [ 82 { 83 amount: { 84 value: vm.order.order.details.total.toFixed(2), 85 currency: "USD" 86 }, 87 }, 88 ], 89 }); 90 }, 91 92 onApprove: function (data, actions) { 93 return $order.processOrder(data).then(function(res) { 94 if (res.data.success === true) { 95 $state.go("confirmation", { data: res.data.data }); 96 } else { 97 console.log('failure onApprove: ', res.data.message) 98 alert('Sorry, something went wrong processing your order. Please call 1-800-644-3561 to speak with our customer service team.'); 99 } 100 }).catch(function(err) { 101 console.log('err onApprove: ', err) 102 alert('Sorry, something went wrong processing your order. Please call 1-800-644-3561 to speak with our customer service team.') 103 }) 104 }, 105 106 style: { 107 shape: 'pill', 108 layout: 'horizontal', 109 label: 'checkout', 110 tagline: false 111 } 112 }; 113 });
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.