D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
diafdxji
/
shihty.com
/
wp-content
/
plugins
/
surecart
/
dist
/
components
/
surecart
/
Filename :
p-2b3a9210.entry.js
back
Copy
import{r as e,h as t,a}from"./p-e97fde0a.js";import{a as s}from"./p-dd3464cd.js";import{o as i}from"./p-b719a497.js";import{a as n}from"./p-401e165e.js";import"./p-d3366af3.js";const c=":host{display:block;position:relative}.payment-methods-list{display:grid;gap:0.5em}.payment-methods-list sc-heading a{text-decoration:none;font-weight:var(--sc-font-weight-semibold);display:inline-flex;align-items:center;gap:0.25em;color:var(--sc-color-primary-500)}.payment-id{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}";const d=c;const r=class{constructor(t){e(this,t);this.query=undefined;this.heading=undefined;this.isCustomer=undefined;this.canDetachDefaultPaymentMethod=false;this.paymentMethods=[];this.loading=undefined;this.busy=undefined;this.error=undefined;this.hasTitleSlot=undefined;this.editPaymentMethod=false;this.deletePaymentMethod=false;this.cascadeDefaultPaymentMethod=false}componentWillLoad(){i(this.el,(()=>this.getPaymentMethods()));this.handleSlotChange()}handleSlotChange(){this.hasTitleSlot=!!this.el.querySelector('[slot="title"]')}async deleteMethod(){var e;if(!this.deletePaymentMethod)return;try{this.busy=true;await s({path:`surecart/v1/payment_methods/${(e=this.deletePaymentMethod)===null||e===void 0?void 0:e.id}/detach`,method:"PATCH"});this.paymentMethods=this.paymentMethods.filter((e=>{var t;return e.id!==((t=this.deletePaymentMethod)===null||t===void 0?void 0:t.id)}));this.deletePaymentMethod=false}catch(e){alert((e===null||e===void 0?void 0:e.messsage)||wp.i18n.__("Something went wrong","surecart"))}finally{this.busy=false}}async setDefault(){var e,t,a;if(!this.editPaymentMethod)return;try{this.error="";this.busy=true;await s({path:`surecart/v1/customers/${(t=(e=this.editPaymentMethod)===null||e===void 0?void 0:e.customer)===null||t===void 0?void 0:t.id}`,method:"PATCH",data:{default_payment_method:(a=this.editPaymentMethod)===null||a===void 0?void 0:a.id,cascade_default_payment_method:this.cascadeDefaultPaymentMethod}});this.editPaymentMethod=false}catch(e){this.error=(e===null||e===void 0?void 0:e.message)||wp.i18n.__("Something went wrong","surecart")}finally{this.busy=false}try{this.busy=true;this.paymentMethods=await s({path:n(`surecart/v1/payment_methods/`,{expand:["card","customer","billing_agreement","paypal_account","payment_instrument","bank_account"],...this.query})})}catch(e){this.error=(e===null||e===void 0?void 0:e.message)||wp.i18n.__("Something went wrong","surecart")}finally{this.busy=false}}async getPaymentMethods(){if(!this.isCustomer){return}try{this.loading=true;this.paymentMethods=await s({path:n(`surecart/v1/payment_methods/`,{expand:["card","customer","billing_agreement","paypal_account","payment_instrument","bank_account"],...this.query,per_page:100})})}catch(e){console.error(this.error);this.error=(e===null||e===void 0?void 0:e.message)||wp.i18n.__("Something went wrong","surecart")}finally{this.loading=false}}renderLoading(){return t("sc-card",{noPadding:true},t("sc-stacked-list",null,t("sc-stacked-list-row",{style:{"--columns":"4"},"mobile-size":500},[...Array(4)].map((()=>t("sc-skeleton",{style:{width:"100px",display:"inline-block"}}))))))}renderEmpty(){return t("div",null,t("sc-divider",{style:{"--spacing":"0"}}),t("slot",{name:"empty"},t("sc-empty",{icon:"credit-card"},wp.i18n.__("You don't have any saved payment methods.","surecart"))))}renderPaymentMethodActions(e){const{id:a,customer:s}=e;if(typeof s==="string")return;if(s.default_payment_method===a&&!this.canDetachDefaultPaymentMethod)return;return t("sc-dropdown",{placement:"bottom-end",slot:"suffix"},t("sc-icon",{role:"button",tabIndex:0,name:"more-horizontal",slot:"trigger"}),t("sc-menu",null,s.default_payment_method!==a&&t("sc-menu-item",{onClick:()=>this.editPaymentMethod=e},wp.i18n.__("Make Default","surecart")),t("sc-menu-item",{onClick:()=>this.deletePaymentMethod=e},wp.i18n.__("Delete","surecart"))))}renderList(){return this.paymentMethods.map((e=>{const{id:a,card:s,customer:i,live_mode:n,billing_agreement:c,paypal_account:d}=e;return t("sc-stacked-list-row",{style:{"--columns":c?"2":"3"}},t("sc-payment-method",{paymentMethod:e}),t("div",{class:"payment-id"},!!(s===null||s===void 0?void 0:s.exp_month)&&t("span",null,wp.i18n.__("Exp.","surecart"),s===null||s===void 0?void 0:s.exp_month,"/",s===null||s===void 0?void 0:s.exp_year),!!d&&(d===null||d===void 0?void 0:d.email)),t("sc-flex",{"justify-content":"flex-start","align-items":"center",style:{"--spacing":"0.5em",marginLeft:"auto"}},typeof i!=="string"&&(i===null||i===void 0?void 0:i.default_payment_method)===a&&t("sc-tag",{type:"info"},wp.i18n.__("Default","surecart")),!n&&t("sc-tag",{type:"warning"},wp.i18n.__("Test","surecart"))),this.renderPaymentMethodActions(e))}))}renderContent(){var e;if(!this.isCustomer){return this.renderEmpty()}if(this.loading){return this.renderLoading()}if(((e=this.paymentMethods)===null||e===void 0?void 0:e.length)===0){return this.renderEmpty()}return t("sc-card",{"no-padding":true},t("sc-stacked-list",null,this.renderList()))}handleEditPaymentMethodChange(){this.cascadeDefaultPaymentMethod=false}render(){return t("sc-dashboard-module",{key:"cd8b3279018d01a3f619c92f49a9222e73aacc11",class:"payment-methods-list",error:this.error},t("span",{key:"9a2b8133a9b26e0472cd923d6d11ce74f5cdba7c",slot:"heading"},t("slot",{key:"bf215e895d9ed7cbf800da8aa6031d55a1e4c5f2",name:"heading"},this.heading||wp.i18n.__("Payment Methods","surecart"))),this.isCustomer&&t("sc-flex",{key:"7e04f6ea07470eac74fe6f9e83f8c9ca247e578e",slot:"end"},t("sc-button",{key:"eae8ccbb73275ce14e5f8e39510e9c37f14f7d89",type:"link",href:n(window.location.href,{action:"index",model:"charge"})},t("sc-icon",{key:"2865398ea0cf2a6440ee556f5ea68575d8f43517",name:"clock",slot:"prefix"}),wp.i18n.__("Payment History","surecart")),t("sc-button",{key:"ae935722ac3c2dfed9321af4f20cbf9f4ca76c02",type:"link",href:n(window.location.href,{action:"create",model:"payment_method"})},t("sc-icon",{key:"d6a610d6f2abd11a548909902bed9c57241fd2e0",name:"plus",slot:"prefix"}),wp.i18n.__("Add","surecart"))),this.renderContent(),t("sc-dialog",{key:"edf15fa53daa4e9fc1c5b164712ed3ef5100dbd0",open:!!this.editPaymentMethod,label:wp.i18n.__("Update Default Payment Method","surecart"),onScRequestClose:()=>this.editPaymentMethod=false},t("sc-alert",{key:"dbff7bc5e6e5f7801f738c420380af8dacf2229e",type:"danger",open:!!this.error},this.error),t("sc-flex",{key:"87c678aa0156c9b2c4aa602a4844691995b5950d",flexDirection:"column",style:{"--sc-flex-column-gap":"var(--sc-spacing-small)"}},t("sc-alert",{key:"0170c2f2cf02125b9fbacb69cce5c4f638189bf2",type:"info",open:true},wp.i18n.__("A default payment method will be used as a fallback in case other payment methods get removed from a subscription.","surecart")),t("sc-switch",{key:"ac65dd035baff8d7947d5ceae1bd47404d8b51cd",checked:this.cascadeDefaultPaymentMethod,onScChange:e=>this.cascadeDefaultPaymentMethod=e.target.checked},wp.i18n.__("Update All Subscriptions","surecart"),t("span",{key:"4740f486fc7f0b9091a8b450a400fb333bda623d",slot:"description"},wp.i18n.__("Update all existing subscriptions to use this payment method","surecart")))),t("div",{key:"0cd2d1c844c80ebac20f73c490ce1a90c34da70e",slot:"footer"},t("sc-button",{key:"a439cdf578c1a828a9403315bcc7186b9eece498",type:"text",onClick:()=>this.editPaymentMethod=false},wp.i18n.__("Cancel","surecart")),t("sc-button",{key:"ce249fe690f5a871dee222e8693dd23cf3f78db0",type:"primary",onClick:()=>this.setDefault()},wp.i18n.__("Make Default","surecart"))),this.busy&&t("sc-block-ui",{key:"7b242b13aeae5c675f47a1a88a9da0920939dd23",spinner:true})),t("sc-dialog",{key:"08fefd5c9a38aa8f69418910c6711cf8ed4c616d",open:!!this.deletePaymentMethod,label:wp.i18n.__("Delete Payment Method","surecart"),onScRequestClose:()=>this.deletePaymentMethod=false},t("sc-alert",{key:"2603a6ca5d9d9a25d5ab79dda54e7b6799c78813",type:"danger",open:!!this.error},this.error),t("sc-text",{key:"ef922dafb8c15d47a8ee84f962957064ab027bf6"},wp.i18n.__("Are you sure you want to remove this payment method?","surecart")),t("div",{key:"99e5bfdc1d1f3ccbc0c2fde5c0ef4414092021d0",slot:"footer"},t("sc-button",{key:"585d7601568485f59dfb46a0304cba3439c949ef",type:"text",onClick:()=>this.deletePaymentMethod=false},wp.i18n.__("Cancel","surecart")),t("sc-button",{key:"517bf0767e8218ee057f72dace55d055bafb7d33",type:"primary",onClick:()=>this.deleteMethod()},wp.i18n.__("Delete","surecart"))),this.busy&&t("sc-block-ui",{key:"b4de4df8fbb4dbfeba4ff800e45c91f9230ee851",spinner:true})),this.busy&&t("sc-block-ui",{key:"3ba74aa0620ef77e748089d8b5f6e43d0b8881db",spinner:true}))}get el(){return a(this)}static get watchers(){return{editPaymentMethod:["handleEditPaymentMethodChange"]}}};r.style=d;export{r as sc_payment_methods_list}; //# sourceMappingURL=p-2b3a9210.entry.js.map