PageSourceSearch

https://translayte.com/build/assets/StripeElementComponent-C_YjQF-A.js

js translayte.com collected 2026-09-28 09:30:32 UTC 16,662 bytes, 1 lines download raw bytes

1import{n as m}from"./_plugin-vue2_normalizer-p4i_2SC9.js";const l="https://translayte.com/build/img/powered_by_stripe.webp",c={props:{storeOrder:{type:Function,required:!0},resolveOrderId:{type:Function,required:!0},stripeKey:{type:String,required:!0},currencySymbol:{type:String,required:!0},returnUrl:{type:String,required:!0},orderForm:{type:Object,required:!0},amount:{type:Number,required:!0},step:{type:String,required:!0},countryCode:{type:String,required:!0},checkoutEmail:{type:String},accountId:{type:Number,default:null},isAccountAdmin:{type:Boolean,default:!1},termsUrl:{type:String,default:""},quoteOnly:{type:Boolean,default:!1}},data(){return{cardError:!1,cardErrorMessage:"",appearance:{theme:"stripe",variables:{colorText:"#636b6f",fontFamily:'"Open Sans", Helvetica, Arial, sans-serif'}},options:{layout:{type:"tabs",defaultCollapsed:!1},fields:{billingDetails:{name:"never",email:"never"}}},stripe:"",paymentElement:"",intent:"",elements:"",elementReady:!1,preferred:["GB","US","FR","DE","CA","AU","IT","IE"],inputOptions:{placeholder:$("#phoneNumber").html()},intentProcessing:!1,savedPaymentMethods:[],paymentMethodType:"new",selectedPaymentMethod:null,savePaymentMethod:!1,showSelectPaymentMethod:!1,showSelectPaymentMethodError:!1}},mounted(){this.quoteOnly||(this.loadSavedPaymentMethods(),this.loadStripeScript(()=>{this.processIntent(this.step)}))},methods:{querySeparator(a){return a.includes("?")?"&":"?"},loadSavedPaymentMethods(){this.accountId&&axios.get("/api/account-payment-methods").then(a=>{this.savedPaymentMethods=a.data||[],this.savedPaymentMethods.length>0&&(this.paymentMethodType="saved"),this.setDefaultPaymentMethod()}).catch(a=>{console.error("Error loading saved payment methods:",a)})},setDefaultPaymentMethod(){this.defaultPaymentMethod&&(this.selectedPaymentMethod=this.defaultPaymentMethod.id)},loadStripeScript(a){const e=document.createElement("script");e.src="https://js.stripe.com/v3/",e.async=!0,e.rel="preconnect",e.onload=a,document.body.appendChild(e)},processIntent(a){return this.intent.id&&this.intent.status!="succeeded"?this.updateIntent(a):this.createIntent(a)},createIntent(a){const e=this;if(e.orderForm.charge_amount===null&&e.amount===null||e.intentProcessing)return;e.orderForm.charge_amount=e.amount||e.orderForm.charge_amount;const t={...e.orderForm,save_payment_method:e.savePaymentMethod};e.intentProcessing=!0,axios.post("/stripe/intent",t).then(r=>(e.intent=r.data,a=="payment"&&e.paymentMethodType==="new"?e.setUpStripe():"")).catch(r=>{var n,o;const s=((o=(n=r==null?void 0:r.response)==null?void 0:n.data)==null?void 0:o.message)||this.trans("An error occured. Please try again or contact us.");e.handleError(s)}).finally(()=>{e.intentProcessing=!1})},updateIntent(a){const e=this;if(e.intentProcessing)return;if(!e.intent.id)return e.createIntent(a);const t={...e.orderForm,save_payment_method:e.savePaymentMethod};e.intentProcessing=!0,axios.patch("/stripe/intent/"+e.intent.id,t).then(r=>{e.intent=r.data}).catch(r=>{var n,o;const s=((o=(n=r==null?void 0:r.response)==null?void 0:n.data)==null?void 0:o.message)||this.trans("An error occured. Please try again or contact us.");e.handleError(s)}).finally(()=>{e.intentProcessing=!1})},async updateIntentMetadata(a){await axios.patch("/stripe/intent/"+this.intent.id+"/metadata",{order_id:a})},setUpStripe(){const a=this;this.elementReady=!1;let e=Stripe(this.stripeKey,{locale:this.locale}),t={clientSecret:this.intent.client_secret,appearance:this.appearance},r=e.elements(t);this.stripe=e,this.elements=r,this.paymentElement=this.elements.create("payment",this.options),this.paymentElement.mount(this.$refs.payment_element),this.paymentElement.on("ready",function(s){a.elementReady=!0})},collectPaymentDetails(){return this.paymentMethodType!=="new"||!this.elements?Promise.resolve(null):this.elements.submit().then(({error:a})=>a||null)},async confirmStripePayment(){this.cardError=!1,this.showSelectPaymentMethodError=!1;const a=await this.collectPaymentDetails();if(a){this.handleError(a.message||this.trans("Payment_Error"));return}
1if(await this.validateClientInformation()){if(this.paymentMethodType==="saved"&&!this.selectedPaymentMethod){this.showSelectPaymentMethodError=!0,this.handleError("Please select a saved payment method");return}this.orderForm.startProcessing();try{const t=await this.resolveOrderId();if(!t){this.handleError(this.trans("An error occured while trying to submit your order. We have logged this error and will investigate. Please contact us by email ([email protected]) to complete your order."));return}await this.updateIntentMetadata(t),this.paymentMethodType==="saved"?await this.chargeWithSavedPaymentMethod(t):await this.chargeWithNewPaymentMethod(t)}catch(t){console.error(t),this.handleError(this.trans("An error occured while trying to submit your order. We have logged this error and will investigate. Please contact us by email ([email protected]) to complete your order."))}}},async chargeWithNewPaymentMethod(a){const e=this.elements;let t=`${this.returnUrl}${this.querySeparator(this.returnUrl)}order_id=${a}`;this.savePaymentMethod&&this.isAccountAdmin&&this.accountId&&(t+=`&save_payment_method=${parseInt(this.selectedPaymentMethod)}`);const r=await this.stripe.confirmPayment({elements:e,confirmParams:{return_url:t,payment_method_data:{billing_details:{name:this.orderForm.name,email:this.orderForm.email}}}});r.error&&(["card_error","validation_error","invalid_request_error"].includes(r.error.type)?this.handleError(r.error.message):this.handleError(this.trans("An error occured. Please try again or contact us.")))},async chargeWithSavedPaymentMethod(a){var e,t;try{const r=await axios.post("/api/stripe/charge-payment-method",{payment_method_id:this.selectedPaymentMethod,amount:this.amount,currency:this.orderForm.charge_currency_code,description:this.orderForm.description,order_id:a});if(r.data.success){const s=r.data.payment_intent,n=`${this.returnUrl}${this.querySeparator(this.returnUrl)}order_id=${a}&payment_intent=${s.id}&redirect_status=${s.status}`;window.location.href=n}else this.handleError(r.data.message||this.trans("An error occured. Please try again or contact us."))}catch(r){console.error("Error charging saved payment method:",r),this.handleError(((t=(e=r.response)==null?void 0:e.data)==null?void 0:t.message)||this.trans("An error occured. Please try again or contact us."))}},handleError(a){this.orderForm.finishProcessing(),this.cardError=!0,this.cardErrorMessage=a,this.$forceUpdate()},validateClientInformation(){const a=this;return a.orderForm.startProcessing(),axios.post("/orders/validate-client-information",{name:a.orderForm.name,email:a.orderForm.email,phone:a.orderForm.phone,terms:a.orderForm.terms}).then(e=>!0).catch(e=>{var t,r,s,n,o;return(r=(t=e==null?void 0:e.response)==null?void 0:t.data)!=null&&r.errors?a.orderForm.setErrors(e.response.data.errors):swal("Whoops!",((n=(s=e==null?void 0:e.response)==null?void 0:s.data)==null?void 0:n.message)||((o=e==null?void 0:e.response)==null?void 0:o.statusText)||"","error"),!1}).finally(()=>{a.orderForm.finishProcessing()})}},computed:{termsAndConditionsLinkHtml(){return this.termsUrl?`<a href="${this.termsUrl}" target="_blank">Terms and Conditions</a>`:this.trans('<a href="/terms-conditions" target="_blank">Terms and Conditions</a>')},termsCheckboxHtml(){return this.trans("I accept the Translayte :terms_and_conditions_link",{terms_and_conditions_link:this.termsAndConditionsLinkHtml})},defaultPaymentMethod(){return this.savedPaymentMethods.find(a=>a.default)},paymentElementPending(){return this.paymentMethodType==="new"&&!this.elementReady}},watch:{paymentMethodType(a){a==="new"&&this.intent&&this.intent.client_secret&&!this.paymentElement&&this.$nextTick(()=>{this.setUpStripe()})}}};var h=function(){var e=this,t=e._self._c;return t("div",[t("div",{directives:[{name:"show",rawName:"v-show",value:e.cardError,expression:"cardError"}],staticClass:"alert alert-danger",attrs:{role:"alert"}},[e._v(" "+e._s(e.cardErrorMessage)+" ")]),t("div",{staticClass:"form-row"},[t("div",{staticClass:"form-group col-md-12"},[t("label",{attrs:{for:"contactName"}},[e._v(e._s(e.trans("Your Name"))+" "),t("span",{staticClass:"text-danger"},[e._v("*")])]),t("input",{directives:[{name:"model",rawName:"v-model",value:e.orderForm.name,expression:"orderForm.name"}
1],staticClass:"form-control",class:{"is-invalid":e.orderForm.errors.has("name")},attrs:{type:"name",name:"name",id:"contactName",placeholder:"John Smith",autocomplete:"name"},domProps:{value:e.orderForm.name},on:{input:function(r){r.target.composing||e.$set(e.orderForm,"name",r.target.value)}}}),t("span",{directives:[{name:"show",rawName:"v-show",value:e.orderForm.errors.has("name"),expression:"orderForm.errors.has('name')"}],staticClass:"help-block text-danger"},[t("small",[e._v(e._s(e.orderForm.errors.get("name")))])])]),t("div",{staticClass:"form-group col-md-6"},[t("label",{attrs:{for:"email"}},[e._v(e._s(e.trans("Your Email Address"))+" "),t("span",{staticClass:"text-danger"},[e._v("*")])]),t("input",{directives:[{name:"model",rawName:"v-model",value:e.orderForm.email,expression:"orderForm.email"}],staticClass:"form-control",class:{"is-invalid":e.orderForm.errors.has("email")},attrs:{type:"email",name:"email",id:"email",placeholder:"[email protected]",autocomplete:"email",disabled:e.checkoutEmail!==""},domProps:{value:e.orderForm.email},on:{input:function(r){r.target.composing||e.$set(e.orderForm,"email",r.target.value)}}}),t("span",{directives:[{name:"show",rawName:"v-show",value:e.orderForm.errors.has("email"),expression:"orderForm.errors.has('email')"}],staticClass:"help-block text-danger"},[t("small",[e._v(e._s(e.orderForm.errors.get("email")))])])]),t("div",{staticClass:"form-group col-md-6"},[t("label",{attrs:{for:"phone"}},[e._v(e._s(e.trans("Your Phone Number"))+" "),t("span",{staticClass:"text-danger"},[e._v("*")])]),t("vue-tel-input",{class:{"border-danger":e.orderForm.errors.has("phone")},staticStyle:{height:"38px"},attrs:{id:"phone","preferred-countries":e.preferred,"valid-characters-only":!0,mode:"international","input-options":e.inputOptions,"default-country":e.countryCode},model:{value:e.orderForm.phone,callback:function(r){e.$set(e.orderForm,"phone",r)},expression:"orderForm.phone"}}),t("span",{directives:[{name:"show",rawName:"v-show",value:e.orderForm.errors.has("phone"),expression:"orderForm.errors.has('phone')"}],staticClass:"help-block text-danger"},[t("small",[e._v(e._s(e.orderForm.errors.get("phone")))])])],1)]),e.amount>0?[t("div",{staticClass:"mb-4"},[e._m(0),e.defaultPaymentMethod&&!e.showSelectPaymentMethod?[t("div",{staticClass:"d-flex justify-content-between align-items-center"},[t("strong",[e._v(" "+e._s(e.defaultPaymentMethod.payment_method_name)+" "),e.defaultPaymentMethod.payment_method_card?t("span",[e._v("("+e._s(e._f("paymentMethodCard")(e.defaultPaymentMethod.payment_method_card))+")")]):e._e()]),t("button",{staticClass:"btn btn-sm btn-link",on:{click:function(r){e.showSelectPaymentMethod=!0}}},[e._v("Change")])])]:[e.savedPaymentMethods.length>0?t("div",[t("div",{staticClass:"custom-control custom-radio mb-2"},[t("input",{directives:[{name:"model",rawName:"v-model",value:e.paymentMethodType,expression:"paymentMethodType"}],staticClass:"custom-control-input",attrs:{type:"radio",name:"paymentMethodType",id:"useSavedCard",value:"saved"},domProps:{checked:e._q(e.paymentMethodType,"saved")},on:{change:function(r){e.paymentMethodType="saved"}}}),t("label",{staticClass:"custom-control-label",attrs:{for:"useSavedCard"}},[e._v(" Use a saved payment method ")])]),t("div",{staticClass:"custom-control custom-radio mb-3"},[t("input",{directives:[{name:"model",rawName:"v-model",value:e.paymentMethodType,expression:"paymentMethodType"}],staticClass:"custom-control-input",attrs:{type:"radio",name:"paymentMethodType",id:"useNewCard",value:"new"},domProps:{checked:e._q(e.paymentMethodType,"new")},on:{change:function(r){e.paymentMethodType="new"}}}),t("label",{staticClass:"custom-control-label",attrs:{for:"useNewCard"}},[e._v(" Use a new payment method ")])]),t("div",{directives:[{name:"show",rawName:"v-show",value:e.paymentMethodType==="saved",expression:"paymentMethodType === 'saved'"}],staticClass:"mb-3"},[t("label",{staticClass:"font-weight-bold mb-2",attrs:{for:"savedPaymentSelect"}},[e._v("Select Payment Method")]),t("select",{directives:[{name:"model",rawName:"v-model",value:e.selectedPaymentMethod,expression:"selectedPaymentMethod"}
1],staticClass:"form-control",class:{"is-invalid":e.showSelectPaymentMethodError&&e.paymentMethodType==="saved"},attrs:{id:"savedPaymentSelect"},on:{change:function(r){var s=Array.prototype.filter.call(r.target.options,function(n){return n.selected}).map(function(n){var o="_value"in n?n._value:n.value;return o});e.selectedPaymentMethod=r.target.multiple?s:s[0]}}},[t("option",{attrs:{disabled:""},domProps:{value:null}},[e._v("-- Select a payment method --")]),e._l(e.savedPaymentMethods,function(r){return t("option",{key:r.id,domProps:{value:r.id}},[e._v(" "+e._s(r.payment_method_name)+" "),r.payment_method_card?t("span",[e._v("("+e._s(e._f("paymentMethodCard")(r.payment_method_card))+")")]):e._e()])})],2),t("small",{staticClass:"form-text text-muted"},[e._v(" Select from your saved payment methods ")])])]):e._e(),t("div",{directives:[{name:"show",rawName:"v-show",value:e.paymentMethodType==="new",expression:"paymentMethodType === 'new'"}]},[t("div",{directives:[{name:"show",rawName:"v-show",value:!e.elementReady,expression:"!elementReady"}]},[t("p",{staticClass:"lead"},[t("i",{staticClass:"fa fa-circle-o-notch fa-spin fa-fw mr-1"}),e._v(" "+e._s(e.trans("Loading"))+"...")])]),t("div",{directives:[{name:"show",rawName:"v-show",value:e.elementReady,expression:"elementReady"}]},[t("div",{ref:"payment_element",staticClass:"mb-1",staticStyle:{height:"auto"}})]),e.isAccountAdmin?t("div",{staticClass:"mb-2 form-check"},[t("input",{directives:[{name:"model",rawName:"v-model",value:e.savePaymentMethod,expression:"savePaymentMethod"}],staticClass:"form-check-input",attrs:{type:"checkbox",id:"savePaymentMethod",disabled:e.intentProcessing||!e.elementReady},domProps:{checked:Array.isArray(e.savePaymentMethod)?e._i(e.savePaymentMethod,null)>-1:e.savePaymentMethod},on:{change:[function(r){var s=e.savePaymentMethod,n=r.target,o=!!n.checked;if(Array.isArray(s)){var d=null,i=e._i(s,d);n.checked?i<0&&(e.savePaymentMethod=s.concat([d])):i>-1&&(e.savePaymentMethod=s.slice(0,i).concat(s.slice(i+1)))}else e.savePaymentMethod=o},function(r){return e.updateIntent(e.step)}]}}),t("label",{staticClass:"form-check-label",attrs:{for:"savePaymentMethod"}},[e._v(" Save this payment method for future use ")])]):e._e()])]],2)]:e._e(),e._t("before-terms"),t("div",{staticClass:"form-group"},[t("div",{staticClass:"form-check"},[t("input",{directives:[{name:"model",rawName:"v-model",value:e.orderForm.terms,expression:"orderForm.terms"}],staticClass:"form-check-input",class:{"is-invalid":e.orderForm.errors.has("terms")},attrs:{"true-value":1,"false-value":0,type:"checkbox",id:"gridCheck"},domProps:{value:0,checked:Array.isArray(e.orderForm.terms)?e._i(e.orderForm.terms,0)>-1:e._q(e.orderForm.terms,1)},on:{change:function(r){var s=e.orderForm.terms,n=r.target,o=n.checked?1:0;if(Array.isArray(s)){var d=0,i=e._i(s,d);n.checked?i<0&&e.$set(e.orderForm,"terms",s.concat([d])):i>-1&&e.$set(e.orderForm,"terms",s.slice(0,i).concat(s.slice(i+1)))}else e.$set(e.orderForm,"terms",o)}}}),t("label",{staticClass:"form-check-label",attrs:{for:"gridCheck"}},[t("span",{domProps:{innerHTML:e._s(e.termsCheckboxHtml)}}),t("span",{staticClass:"text-danger"},[e._v("*")])]),t("span",{directives:[{name:"show",rawName:"v-show",value:e.orderForm.errors.has("terms"),expression:"orderForm.errors.has('terms')"}],staticClass:"invalid-feedback"},[e._v(" "+e._s(e.orderForm.errors.get("terms"))+" ")])])]),e.amount>0?t("div",{staticClass:"float-right"},[t("img",{staticClass:"img-fluid mr-3 mt-2",attrs:{src:l}}),t("button",{staticClass:"btn btn-success",attrs:{type:"button",disabled:e.orderForm.busy||!e.orderForm.terms||e.intentProcessing||e.paymentElementPending},on:{click:function(r){return e.confirmStripePayment()}}},[t("i",{directives:[{name:"show",rawName:"v-show",value:e.orderForm.busy,expression:"orderForm.busy"}],staticClass:"fa fa-circle-o-notch fa-spin"}),e._v(" "+e._s(e.trans("Pay"))+" "+e._s(e._f("currency")(e.amount,e.currencySymbol)))])]):e._e()],2)},p=[function(){var a=this,e=a._self._c;return e("div",{staticClass:"mb-2"},[a._v("Payment Method "),e("span",{staticClass:"text-danger"},[a._v("*")])])}],u=m(c,h,p,!1,null,null);const v=u.exports;export{v as default};

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.