var __apiEndpoint='https://account.convoyofhope.org';var __stripekey='pk_live_pO6tpuus6tAbZ2DpiS0yhqhp';var __ipnUrl='https://account.convoyofhope.org/api/paypal/webhook';var __emailAddress='paypal2@convoyofhope.org';var __paypalDonationUrl='https://www.paypal.com/cgi-bin/webscr';/*! For license information please see api.js.LICENSE.txt */ !function(e){var t={};function r(n){if(t[n])return t[n].exports;var a=t[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,r),a.l=!0,a.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)r.d(n,a,function(t){return e[t]}.bind(null,a));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="/",r(r.s=1)}({1:function(e,t,r){e.exports=r("ck9e")},ck9e:function(e,t){function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function n(){"use strict";n=function(){return e};var e={},t=Object.prototype,a=t.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",s=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function l(e,t,r,n){var a=t&&t.prototype instanceof d?t:d,i=Object.create(a.prototype),o=new S(n||[]);return i._invoke=function(e,t,r){var n="suspendedStart";return function(a,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===a)throw i;return O()}for(r.method=a,r.arg=i;;){var o=r.delegate;if(o){var s=x(o,r);if(s){if(s===p)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=h(e,t,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===p)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(e,r,o),i}function h(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=l;var p={};function d(){}function m(){}function f(){}var y={};u(y,o,(function(){return this}));var v=Object.getPrototypeOf,_=v&&v(v(E([])));_&&_!==t&&a.call(_,o)&&(y=_);var g=f.prototype=d.prototype=Object.create(y);function b(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function w(e,t){var n;this._invoke=function(i,o){function s(){return new t((function(n,s){!function n(i,o,s,c){var u=h(e[i],e,o);if("throw"!==u.type){var l=u.arg,p=l.value;return p&&"object"==r(p)&&a.call(p,"__await")?t.resolve(p.__await).then((function(e){n("next",e,s,c)}),(function(e){n("throw",e,s,c)})):t.resolve(p).then((function(e){l.value=e,s(l)}),(function(e){return n("throw",e,s,c)}))}c(u.arg)}(i,o,n,s)}))}return n=n?n.then(s,s):s()}}function x(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,x(e,t),"throw"===t.method))return p;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return p}var n=h(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,p;var a=n.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,p):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,p)}function P(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function k(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function S(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(P,this),this.reset(!0)}function E(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,n=function t(){for(;++r=0;--n){var i=this.tryEntries[n],o=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var s=a.call(i,"catchLoc"),c=a.call(i,"finallyLoc");if(s&&c){if(this.prev=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&a.call(n,"finallyLoc")&&this.prev=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),k(r),p}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var a=n.arg;k(r)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:E(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),p}},e}function a(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function i(e){for(var t=1;t0&&void 0!==a[0]?a[0]:{},e.next=3,this._sendData("/api/stripe/intent",i({amount:this.meta.amount,currency:this.currency,metadata:this.meta},t));case 3:return r=e.sent,e.abrupt("return",r.clientSecret);case 5:case"end":return e.stop()}}),e,this)}))),function(){return g.apply(this,arguments)})},{key:"_donateMonthly",value:(_=c(n().mark((function e(t){var r;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r={payment_method_id:t.id,name:t.billing_details.name,email_address:t.billing_details.email,currency:this.currency,amount:parseInt(100*this.meta.amount),metadata:this.meta},e.abrupt("return",this._sendData("/api/stripe/monthly",r));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return _.apply(this,arguments)})},{key:"setupACHDonateMonthly",value:(v=c(n().mark((function e(){var t;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t={name:this.meta.first_name+" "+this.meta.last_name,email_address:this.meta.email_address,currency:this.currency,amount:parseInt(100*this.meta.amount),metadata:this.meta},e.abrupt("return",this._sendData("/api/stripe/ach-monthly",t));case 2:case"end":return e.stop()}}),e,this)}))),function(){return v.apply(this,arguments)})},{key:"_sendData",value:(y=c(n().mark((function e(t){var r,a,i,o,s=arguments;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=s.length>1&&void 0!==s[1]?s[1]:{},a={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)},e.next=4,fetch(__apiEndpoint+t,a);case 4:if((i=e.sent).ok){e.next=10;break}return e.next=8,i.json();case 8:throw o=e.sent,new Error(o.message||"An unexpected error has occurred. Please try your request again later.");case 10:return e.abrupt("return",i.json());case 11:case"end":return e.stop()}}),e)}))),function(e){return y.apply(this,arguments)})},{key:"setupStripe",value:function(e){var t=e.cardNumberElement,r=e.cardExpiryElement,n=e.cardCVCElement,a=e.onElementInputChange,i=e.styles,o=void 0===i?null:i,s=this._createStripeStyles(o);this._createStripeCardElements({elementStyles:s,elementClasses:{focus:"focused",empty:"empty",invalid:"invalid"},cardNumberElement:t,onElementInputChange:a,cardExpiryElement:r,cardCVCElement:n})}},{key:"setupStripeACH",value:function(e){var t=e.paymentFormElement,r=e.clientSecret;e.styles,this.elements=stripe.elements({locale:"auto",clientSecret:r,appearance:{theme:"flat",variables:{colorText:"#00344f",fontWeight:500,fontFamily:"Proxima Nova",fontSize:"16px",fontSmoothing:"antialiased",backgroundColor:"#f7fafe",borderRadius:"3px",colorDanger:"#C73126",fontSizeSm:"16px",fontWeightNormal:700,colorPrimary:"#0083ca"},rules:{".Input":{backgroundColor:"#f7fafe",border:"1px solid #c6d0dd",verticalAlign:"top"},".PickerItem":{border:"2px solid #001f2e",backgroundColor:"white",color:"#0083ca",fontWeight:700},".PickerItem:hover":{border:"2px solid #0083ca",backgroundColor:"#0083ca",color:"white",fontWeight:700}}}}),this.elements.create("payment",{fields:{billingDetails:"never"}}).mount(t)}},{key:"setupStripeCustomerData",value:function(e){var t=e.paymentId,r=e.customerId;this.stripeCustomerId=r,this.paymentId=t}},{key:"_createStripeCardElements",value:function(e){var t=e.elementStyles,r=e.elementClasses,n=e.cardNumberElement,a=e.onElementInputChange,i=e.cardExpiryElement,o=e.cardCVCElement;this.elements=stripe.elements({locale:"auto"});var s=this.elements.create("cardNumber",{showIcon:!0,style:t,classes:r});s.mount(n),a&&s.on("change",(function(e){return a(n,e)})),this.cardNumber=s;var c=this.elements.create("cardExpiry",{style:t,classes:r});c.mount(i),a&&c.on("change",(function(e){return a(c,e)}));var u=this.elements.create("cardCvc",{style:t,classes:r});u.mount(o),a&&u.on("change",(function(e){return a(o,e)}))}},{key:"_createStripeStyles",value:function(e){return e||{base:{color:"#32325D",fontWeight:500,fontFamily:"Proxima Nova",fontSize:"16px",fontSmoothing:"antialiased",backgroundColor:"#f7fafe",lineHeight:"46px","::placeholder":{color:"#CFD7DF"},":-webkit-autofill":{color:"#e39f48"}},invalid:{color:"#C73126","::placeholder":{color:"#FFCCA5"}}}}},{key:"_createHiddenField",value:function(e,t,r){var n=document.createElement("input");return n.type="hidden",n.name=t,n.value=r,e.appendChild(n),n}},{key:"_redirectToSingleDonationPaypal",value:function(e){var t=document.createElement("form");t.action=__paypalDonationUrl,t.method="post",e.appendChild(t),this._createHiddenField(t,"cmd","_donations"),this._createHiddenField(t,"business",__emailAddress),this._createHiddenField(t,"amount",Number(this.meta.amount).toFixed(2)),this._createHiddenField(t,"item_name","Donation: ".concat(this.meta.program)),this._createHiddenField(t,"custom",JSON.stringify(this.meta)),this._createHiddenField(t,"return",this._getRedirectUrl()),this._createHiddenField(t,"currency_code",this.currency.toUpperCase()),this._createHiddenField(t,"cancel_return",this.cancel_donation_page_url),this._createHiddenField(t,"notify_url",__ipnUrl);var r=document.createElement("img");r.style="display: none;",r.src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif",r.height="1",r.width="1",e.appendChild(r),t.submit()}},{key:"_redirectToRecurringDonationPaypal",value:function(e){var t=document.createElement("form");t.action=__paypalDonationUrl,t.method="post",e.appendChild(t),this._createHiddenField(t,"cmd","_xclick-subscriptions"),this._createHiddenField(t,"business",__emailAddress),this._createHiddenField(t,"item_name","Donation: ".concat(this.meta.program)),this._createHiddenField(t,"src","1"),this._createHiddenField(t,"p3","1"),this._createHiddenField(t,"currency_code",this.currency.toUpperCase()),this._createHiddenField(t,"t3","M"),this._createHiddenField(t,"custom",JSON.stringify(this.meta)),this._createHiddenField(t,"srt","0"),this._createHiddenField(t,"a3",Number(this.meta.amount).toFixed(2)),this._createHiddenField(t,"return",this._getRedirectUrl()),this._createHiddenField(t,"cancel_return",this.cancel_donation_page_url),this._createHiddenField(t,"notify_url",__ipnUrl);var r=document.createElement("img");r.style="display: none;",r.src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif",r.height="1",r.width="1",e.appendChild(r),t.submit()}},{key:"setupPayPal",value:function(e){var t=this;e.addEventListener("click",(function(r){if("undefined"!=typeof DonationForm){var n={is_organization_donation:DonationForm.isOrganizationDonation,referrer:window.location.href.replace(window.location.origin,"").substring(0,255)};DonationForm.organizationName&&(n.organization_name=DonationForm.organizationName),DonationForm.organizationType&&(n.organization_type=DonationForm.organizationType),t.updateMeta(n)}if(t.meta.is_recurring)return t._redirectToRecurringDonationPaypal(e);t._redirectToSingleDonationPaypal(e)}))}},{key:"setupApplePay",value:(f=c(n().mark((function e(t){var r,a,i;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.buttonElement,a=t.containerElement,i=this._createApplePayButton(),e.next=4,this.applePayPaymentRequest.canMakePayment();case 4:if(e.sent){e.next=7;break}return e.abrupt("return",document.querySelector(a).style.display="none");case 7:i.mount(r),this.applePayPaymentRequest.on("paymentmethod",this._payWithApplePay.bind(this));case 9:case"end":return e.stop()}}),e,this)}))),function(e){return f.apply(this,arguments)})},{key:"_createApplePayButton",value:function(){return this.applePayPaymentRequest=stripe.paymentRequest({country:"US",currency:this.currency.toLowerCase(),total:{label:"Donation",amount:0},requestPayerName:!0,requestPayerEmail:!0}),this.elements.create("paymentRequestButton",{paymentRequest:this.applePayPaymentRequest,style:{paymentRequestButton:{type:"donate"}}})}},{key:"updateMeta",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e.is_recurring&&(e.is_recurring=Boolean(e.is_recurring)),this.meta=i(i({referrer:window.location.href.substring(0,255)},this.meta),e),this.applePayPaymentRequest&&e.amount&&this.applePayPaymentRequest.update({total:{label:"Donation",amount:parseInt(100*e.amount)}})}},{key:"_redirectToThankYouPage",value:function(){return window.location=this._getRedirectUrl()}},{key:"_getRedirectUrl",value:function(){var e="".concat(this.thank_you_page_url,"?amount=").concat(this.meta.amount);return this.meta.program&&(e+="&program=".concat(this.meta.program)),e}},{key:"_confirmACHPaymentMethod",value:(m=c(n().mark((function e(){var t,r,a=arguments;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=a.length>0&&void 0!==a[0]?a[0]:{},e.next=3,stripe.confirmPayment(i({elements:this.elements,confirmParams:{return_url:this._getRedirectUrl(),payment_method_data:{billing_details:{name:this.meta.first_name+" "+this.meta.last_name,email:this.meta.email_address,phone:this.meta.phone_number,address:{city:this.meta.city,line1:this.meta.street_address,line2:null,postal_code:this.meta.zip_code,state:this.meta.state,country:"US"}}}}},t));case 3:if(!(r=e.sent).error){e.next=7;break}return alert("ERROR PROCESSING TRANSACTION"),e.abrupt("return",Promise.reject(r.error));case 7:this._redirectToThankYouPage();case 8:case"end":return e.stop()}}),e,this)}))),function(){return m.apply(this,arguments)})},{key:"_confirm",value:(d=c(n().mark((function e(t){var r,a,o=arguments;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=o.length>1&&void 0!==o[1]?o[1]:{},e.next=3,stripe.confirmCardPayment(t,i({},r));case 3:if(!(a=e.sent).error){e.next=7;break}return alert("ERROR PROCESSING TRANSACTION"),e.abrupt("return",Promise.reject(a.error));case 7:this._redirectToThankYouPage();case 8:case"end":return e.stop()}}),e,this)}))),function(e){return d.apply(this,arguments)})},{key:"payWithACH",value:(p=c(n().mark((function e(){return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._confirmACHPaymentMethod();case 2:case"end":return e.stop()}}),e,this)}))),function(){return p.apply(this,arguments)})},{key:"payWithCard",value:(h=c(n().mark((function e(){var t,r,a,i=this;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.meta.is_recurring){e.next=6;break}return e.next=3,this._createCardPaymentMethod();case 3:return t=e.sent,r=t.paymentMethod,e.abrupt("return",this._donateMonthly(r).then((function(e){return i._redirectToThankYouPage()})));case 6:return e.next=8,this.createPaymentIntent();case 8:return a=e.sent,e.abrupt("return",this._confirm(a,{payment_method:{card:this.cardNumber,billing_details:{name:this.meta.first_name+" "+this.meta.last_name,email:this.meta.email_address,phone:this.meta.phone_number,address:{city:this.meta.city,line1:this.meta.street_address,postal_code:this.meta.zip_code,state:this.meta.state}}}}));case 10:case"end":return e.stop()}}),e,this)}))),function(){return h.apply(this,arguments)})},{key:"payWithStripePaymentId",value:(l=c(n().mark((function e(t){var r=this;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.meta.is_recurring){e.next=2;break}return e.abrupt("return",this._donateMonthly({id:t,billing_details:{email:this.meta.email_address}}).then((function(){return r._redirectToThankYouPage()})));case 2:return e.prev=2,e.next=5,this._sendData("/api/stripe/charge",{amount:this.meta.amount,currency:this.currency,payment_method:t,customer:this.stripeCustomerId,metadata:this.meta});case 5:e.next=11;break;case 7:return e.prev=7,e.t0=e.catch(2),alert("ERROR PROCESSING TRANSACTION"),e.abrupt("return",Promise.reject(e.t0));case 11:return this._redirectToThankYouPage(),e.abrupt("return");case 15:return e.abrupt("return",e.sent);case 16:case"end":return e.stop()}}),e,this,[[2,7]])}))),function(e){return l.apply(this,arguments)})},{key:"_payWithApplePay",value:(s=c(n().mark((function e(t){var r,a=this;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.updateMeta({is_apple_pay:!0,email_address:t.paymentMethod.billing_details.email}),"undefined"!=typeof DonationForm&&this.updateMeta({should_receive_text_updates:DonationForm.shouldReceiveTextMessages,is_organization_donation:DonationForm.isOrganizationDonation,organization_name:DonationForm.organizationName,organization_type:DonationForm.organizationType}),!this.meta.is_recurring){e.next=4;break}return e.abrupt("return",this._donateMonthly(t.paymentMethod).then((function(e){return a._redirectToThankYouPage()})));case 4:return e.next=6,this.createPaymentIntent();case 6:return r=e.sent,e.abrupt("return",this._confirm(r,{payment_method:t.paymentMethod.id}));case 8:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"_createCardPaymentMethod",value:(o=c(n().mark((function e(){return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,stripe.createPaymentMethod({type:"card",card:this.cardNumber,billing_details:{name:this.meta.first_name+" "+this.meta.last_name,email:this.meta.email_address,phone:this.meta.phone_number,address:{city:this.meta.city,line1:this.meta.street_address,postal_code:this.meta.zip_code,state:this.meta.state}}});case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})}])&&u(t.prototype,r),a&&u(t,a),Object.defineProperty(t,"prototype",{writable:!1}),e}();window&&(window.Donator=l)}});