PageSourceSearch

https://anpin.ai/assets/StripePaymentView-Bdsy9wp8.js

js anpin.ai collected 2026-10-05 11:49:18 UTC 9,848 bytes, 1 lines download raw bytes

1import{y as Z,z as ee,_ as V}from"./index-C_k8olYN.js";import{d as te,c as j,X as se,r as u,o as ae,n as re,Z as ne,a as oe,D as ie,K as le,B as e,z as l,k as F,G as r,u as o,E,F as D,H as ce,A as L,J as ue,C as i}from"./vendor-vue-BVJWaRIf.js";import{u as de}from"./payment-3Adqzuui.js";import{p as me}from"./payment-CdCct12x.js";import{b as W}from"./apiError-zX02PgX9.js";import{n as $,f as pe}from"./currency-DpW1WrYL.js";import{r as ye,P as fe}from"./paymentFlow-cys_N5rS.js";import{_ as _e}from"./AppLayout.vue_vue_type_script_setup_true_lang-DHyBjO3R.js";import{u as ve}from"./vendor-i18n-pgwztqC8.js";import"./vendor-misc-g39fh_pU.js";import"./AppHeader.vue_vue_type_style_index_0_scoped_59fb3e77_lang-ychy3K7_.js";import"./useClipboard-B0ISP9ZB.js";import"./LocaleSwitcher-CQyfn4AX.js";/* empty css                                                                       */const ge={key:0,class:"flex items-center justify-center py-20"},he={key:1,class:"card p-8 text-center"},xe={class:"mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-red-100 dark:bg-red-900/30"},be={class:"text-lg font-semibold text-gray-900 dark:text-white"},we={class:"mt-2 text-sm text-gray-500 dark:text-gray-400"},ke={key:0,class:"card overflow-hidden"},Pe={class:"bg-gradient-to-br from-[#635bff] to-[#4f46e5] px-6 py-6 text-center"},Ce={class:"text-sm font-medium text-indigo-200"},Ee={class:"mt-1 text-3xl font-bold text-white"},Se={class:"card p-6"},qe={class:"flex flex-col items-center space-y-4"},Te={class:"text-lg font-semibold text-gray-900 dark:text-white"},Re={class:"relative rounded-lg border-2 border-[#2BB741] bg-green-50 p-4 dark:border-[#2BB741]/70 dark:bg-green-950/20"},ze=["src"],Ae={class:"text-center text-sm text-gray-500 dark:text-gray-400"},Be={class:"card p-4 text-center"},Ie={class:"text-sm text-gray-500 dark:text-gray-400"},Ne={key:2,class:"card p-6"},De={class:"flex flex-col items-center space-y-4 py-4"},Me={class:"text-sm text-gray-500 dark:text-gray-400"},Oe={key:3,class:"card p-6 text-center"},Ve={class:"flex flex-col items-center gap-3 py-4"},je={class:"flex h-16 w-16 items-center justify-center rounded-full bg-green-100 dark:bg-green-900/30"},Fe={class:"text-lg font-bold text-gray-900 dark:text-white"},Le={class:"text-sm text-gray-500 dark:text-gray-400"},We={class:"card p-6"},$e={key:0,class:"mt-4 text-sm text-red-600 dark:text-red-400"},Ge=["disabled"],Ye={key:0,class:"flex items-center justify-center gap-2"},He={key:1},Ke={class:"text-center"},Ue={key:5,class:"card p-4"},Qe={class:"text-sm text-red-600 dark:text-red-400"},mt=te({__name:"StripePaymentView",setup(Je){const M=ve(),{t:a}=M,m=se(),b=ne(),S=de(),q=j(()=>!!m.query.method),w=u(!0),f=u(""),d=u(""),g=u(!1),k=u(!1),O=u(!1),T=u(null),R=u("CNY"),P=u(""),z=u(!1),A=u(!1);let B=null,I=null,C=null;ae(async()=>{var c;const s=Number(m.query.order_id),t=String(m.query.client_secret||""),n=String(m.query.method||""),p=typeof m.query.resume_token=="string"?m.query.resume_token:void 0;if(!s||!t){w.value=!1,f.value=a("payment.stripeMissingParams");return}try{if(typeof window<"u"){const v=ye(window.localStorage.getItem(fe),{resumeToken:p});(v==null?void 0:v.orderId)===s&&(R.value=$(v.currency))}const y=await me.getOrder(s);T.value=y.data,y.data.currency&&(R.value=$(y.data.currency)),await S.fetchConfig();const h=(c=S.config)==null?void 0:c.stripe_publishable_key;if(!h){f.value=a("payment.stripeNotConfigured");return}const{loadStripe:X}=await Z(async()=>{const{loadStripe:v}=await import("./vendor-stripe-DSy-tJeT.js");return{loadStripe:v}},[]),x=await X(h);if(!x){f.value=a("payment.stripeLoadFailed");return}B=x,w.value=!1,n==="alipay"?await H(x,t,s):n==="wechat_pay"?await K(x,t):(A.value=!0,await re(),U(x,t))}catch(y){f.value=W(y,a,"payment.errors",a("payment.stripeLoadFailed"))}finally{w.value=!1}});const G=j(()=>{const s=M.locale;if(typeof s=="string")return s;if(s&&typeof s=="object"&&"value"in s)return String(s.value||"")});function Y(s){return pe(s,R.value,G.value)}async function H(s,t,n){z.value=!0;const p=window.location.origin+"/payment/result?order_id="+n+"&status=success",{error:c}=await s.confirmAlipayPayment(t,{return_url:p});c&&(z.value=!1,d.value=c.message||a("payment.result.failed"))}async function K(s,t){var y,h;const{paymentIntent:n,error:p}=await s.confirmWechatPayPayment(t,{payment_method_options:{wechat_pay:{client:ee()?"mobile_web":"web"}}});if(p){d.value=p.message||a("payment.result.failed");return}const c=(h=(y=n==null?void 0:n.next_action)==null?void 0:y.wechat_pay_display_qr_code)==null?void 0:h.image_data_url;c?(P.value=c,J()):(n==null?void 0:n.status)==="succeeded"?(k.value=!0,N()):d.value=a("payment.result.failed")}function U(s,t){const n=document.documentElement.classList.contains("dark"),p=s.elements({clientSecret:t,appearance:{theme:n?"night":"stripe",variables:{borderRadius:"8px"}}});I=p;const c=p.create("payment",{layout:"tabs",paymentMethodOrder:["alipay","wechat_pay","card","link"]});c.mount("#stripe-payment-element"),c.on("ready",()=>{O.value=!0})}async function Q(){if(!(!B||!I||g.value)){g.value=!0,d.value="";try{const{error:s}=await B.confirmPayment({elements:I,confirmParams:{return_url:window.location.origin+"/payment/result?order_id="+m.query.order_id+"&status=success"},redirect:"if_required"});s?d.value=s.message||a("payment.result.failed"):(k.value=!0,N())}catch(s){d.value=W(s,a,"payment.errors",a("payment.result.failed"))}finally{g.value=!1}}}let _=null;function J(){const s=Number(m.query.order_id);s&&(_=setInterval(async()=>{const t=await S.pollOrderStatus(s);t&&(t.status==="COMPLETED"||t.status==="PAID")&&(_&&(clearInterval(_),_=null),k.value=!0,P.value="",N())},3e3))}function N(){window.opener?C=setTimeout(()=>{window.close()},2e3):C=setTimeout(()=>{b.push({path:"/payment/result",query:{order_id:String(m.query.order_id||""),status:"success"}})},2e3)}return oe(()=>{C&&clearTimeout(C),_&&clearInterval(_)}),(s,t)=>
1(i(),ie(ue(q.value?"div":_e),{class:L(q.value?"min-h-screen bg-gray-50 dark:bg-dark-900":"")},{default:le(()=>[e("div",{class:L(["mx-auto max-w-lg space-y-6 py-8",q.value?"px-4":""])},[w.value?(i(),l("div",ge,[...t[3]||(t[3]=[e("div",{class:"h-8 w-8 animate-spin rounded-full border-4 border-primary-500 border-t-transparent"},null,-1)])])):f.value?(i(),l("div",he,[e("div",xe,[F(V,{name:"exclamationCircle",size:"xl",class:"text-red-500"})]),e("h3",be,r(o(a)("payment.stripeLoadFailed")),1),e("p",we,r(f.value),1),e("button",{class:"btn btn-primary mt-6",onClick:t[0]||(t[0]=n=>o(b).push("/purchase"))},r(o(a)("payment.result.backToRecharge")),1)])):(i(),l(D,{key:2},[T.value?(i(),l("div",ke,[e("div",Pe,[e("p",Ce,r(o(a)("payment.actualPay")),1),e("p",Ee,r(Y(T.value.pay_amount)),1)])])):E("",!0),P.value?(i(),l(D,{key:1},[e("div",Se,[e("div",qe,[e("p",Te,r(o(a)("payment.qr.scanWxpay")),1),e("div",Re,[e("img",{src:P.value,alt:"WeChat Pay QR",class:"h-56 w-56 rounded"},null,8,ze),t[4]||(t[4]=e("div",{class:"pointer-events-none absolute inset-0 flex items-center justify-center"},[e("span",{class:"rounded-full bg-[#2BB741] p-2 shadow ring-2 ring-white"},[e("svg",{class:"h-5 w-5 text-white",viewBox:"0 0 24 24",fill:"currentColor"},[e("path",{d:"M8.691 2.188C3.891 2.188 0 5.476 0 9.53c0 2.212 1.17 4.203 3.002 5.55a.59.59 0 0 1 .213.665l-.39 1.48c-.019.07-.048.141-.048.213 0 .163.13.295.29.295a.326.326 0 0 0 .167-.054l1.903-1.114a.864.864 0 0 1 .717-.098 10.16 10.16 0 0 0 2.837.403c.276 0 .543-.027.811-.05-.857-2.578.157-4.972 1.932-6.446 1.703-1.415 3.882-1.98 5.853-1.838-.576-3.583-4.196-6.348-8.596-6.348zM5.785 5.991c.642 0 1.162.529 1.162 1.18a1.17 1.17 0 0 1-1.162 1.178A1.17 1.17 0 0 1 4.623 7.17c0-.651.52-1.18 1.162-1.18zm5.813 0c.642 0 1.162.529 1.162 1.18a1.17 1.17 0 0 1-1.162 1.178 1.17 1.17 0 0 1-1.162-1.178c0-.651.52-1.18 1.162-1.18zm3.636 4.35c-2.084 0-3.993.672-5.363 1.844-1.188.982-2.004 2.308-2.004 3.862 0 1.207.546 2.355 1.483 3.285.114.113.238.213.358.321l-.105.42c-.021.084-.042.17-.042.253 0 .168.126.258.282.258.065 0 .126-.025.18-.058l1.27-.765a.69.69 0 0 1 .58-.086c.96.282 1.99.437 3.043.437 2.633 0 5.03-.972 6.4-2.5.782-.87 1.258-1.901 1.258-3.006 0-3.328-3.325-6.006-7.34-6.006zm-3.21 3.09c.52 0 .94.429.94.957a.949.949 0 0 1-.94.955.949.949 0 0 1-.94-.955c0-.528.42-.957.94-.957zm4.739 0c.52 0 .94.429.94.957a.949.949 0 0 1-.94.955.949.949 0 0 1-.94-.955c0-.528.42-.957.94-.957z"})])])],-1))]),e("p",Ae,r(o(a)("payment.qr.scanWxpayHint")),1)])]),e("div",Be,[e("p",Ie,r(o(a)("payment.qr.waitingPayment")),1)])],64)):z.value?(i(),l("div",Ne,[e("div",De,[t[5]||(t[5]=e("div",{class:"h-10 w-10 animate-spin rounded-full border-4 border-[#00AEEF] border-t-transparent"},null,-1)),e("p",Me,r(o(a)("payment.qr.payInNewWindowHint")),1)])])):k.value?(i(),l("div",Oe,[e("div",Ve,[e("div",je,[F(V,{name:"check",size:"lg",class:"text-green-500"})]),e("p",Fe,r(o(a)("payment.result.success")),1),e("p",Le,r(o(a)("payment.stripeSuccessProcessing")),1)])])):A.value?(i(),l(D,{key:4},[e("div",We,[t[7]||(t[7]=e("div",{id:"stripe-payment-element",class:"min-h-[200px]"},null,-1)),d.value?(i(),l("p",$e,r(d.value),1)):E("",!0),e("button",{class:"btn btn-stripe mt-6 w-full py-3 text-base",disabled:g.value||!O.value,onClick:Q},[g.value?(i(),l("span",Ye,[t[6]||(t[6]=e("span",{class:"h-4 w-4 animate-spin rounded-full border-2 border-white border-t-transparent"},null,-1)),ce(" "+r(o(a)("common.processing")),1)])):(i(),l("span",He,r(o(a)("payment.stripePay")),1))],8,Ge)]),e("div",Ke,[e("button",{class:"btn btn-secondary",onClick:t[1]||(t[1]=n=>o(b).push("/purchase"))},r(o(a)("payment.result.backToRecharge")),1)])],64)):E("",!0),d.value&&!A.value?(i(),l("div",Ue,[e("p",Qe,r(d.value),1),e("button",{class:"btn btn-secondary mt-3 w-full",onClick:t[2]||(t[2]=n=>o(b).push("/purchase"))},r(o(a)("payment.result.backToRecharge")),1)])):E("",!0)],64))],2)]),_:1},8,["class"]))}});export{mt 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.