Initial commit: WordPress wp-content (themes, plugins, languages)

- Theme: momentry (custom theme with REST API routes)
- Plugins: code-snippets (contains all API proxies)
- Languages: zh_TW translations
- Excludes: cache, backups, uploads, logs
This commit is contained in:
OpenCode
2026-05-29 19:07:56 +08:00
commit 09ef1f000f
6521 changed files with 867163 additions and 0 deletions

View File

@@ -0,0 +1 @@
((r,a,e)=>{let n=[];class i extends WPFormsPaypalCommercePaymentHandler.PaymentHandler{constructor(){super(),this.session=null}async initPaymentButton(){var t=this.getPayPalSDK();if(void 0!==t&&void 0!==t.Applepay){var a=this.$form.find(".wpforms-paypal-commerce-applepay-button");if(a.length)try{let e=await this.isAvailable(t.Applepay());var o=r.createElement("apple-pay-button");o.setAttribute("buttonstyle",this.formOptions.applepay.buttonColor),o.setAttribute("type","plain"),o.setAttribute("locale",wpforms_paypal_commerce.locale||"en"),o.addEventListener("click",()=>{this.validateBeforePayment().then(()=>{this.startApplePaySession(e)}).catch(()=>{})}),a.removeClass("wpforms-hidden"),a[0].appendChild(o)}catch(e){console.error("Apple Pay availability check error:",e)}}}async isAvailable(e){if(!e)throw new Error("Empty Apple Pay instance provided");if(void 0===a.ApplePaySession)throw new Error("This device does not support Apple Pay");if(!a.ApplePaySession.canMakePayments())throw new Error("This device is not capable of making Apple Pay payments");e=await e.config();if(e.isEligible)return e;throw new Error("Merchant is not eligible for Apple Pay")}buildPaymentRequest(e,t){var a=wpforms.getCurrency();return{countryCode:e.countryCode,merchantCapabilities:e.merchantCapabilities,supportedNetworks:e.supportedNetworks,currencyCode:a.code,requiredBillingContactFields:["postalAddress"],total:{label:wpforms_paypal_commerce.total_price_label,type:"final",amount:t}}}startApplePaySession(e){var t=String(wpforms.amountTotalCalc(this.$form)),e=this.buildPaymentRequest(e,t);this.session=new a.ApplePaySession(4,e),this.session.onvalidatemerchant=e=>{this.onValidateMerchant(e)},this.session.onpaymentauthorized=e=>{this.onPaymentAuthorized(e)},this.session.oncancel=()=>{console.log("Apple Pay payment was canceled")},this.session.begin()}onValidateMerchant(e){var t=this.getPayPalSDK().Applepay(),a=this.getFormOptions();t.validateMerchant({validationUrl:e.validationURL,displayName:a.merchant_name||"My Store"}).then(e=>{this.session.completeMerchantValidation(e.merchantSession)}).catch(e=>{console.error("Merchant validation failed:",e),this.session.abort()})}onPaymentAuthorized(e){this.processPayment(e.payment).then(()=>{this.session.completePayment(ApplePaySession.STATUS_SUCCESS)}).catch(()=>{this.session.completePayment(ApplePaySession.STATUS_FAILURE)})}async processPayment(e){try{var t=await WPFormsPaypalCommerce.createSingleOrder(this.$form,"apple_pay");return await this.confirmPayment(t,e),WPFormsPaypalCommerce.submitPaymentForm(this.$form,t,this.type,"apple_pay"),Promise.resolve()}catch(e){throw console.error("Apple Pay payment processing error:",e),this.showError(wpforms_paypal_commerce.i18n.on_error),e}}async confirmPayment(e,t){if("APPROVED"!==(await this.getPayPalSDK().Applepay().confirmOrder({orderId:e,token:t.token,billingContact:t.billingContact,shippingContact:t.shippingContact}))?.approveApplePayPayment?.status)throw new Error("Payment not approved");return Promise.resolve()}static checkApplePayAPI(){return void 0!==a.ApplePaySession}}let t={init(){e(r).on("wpformsPayPalCommerceLoadedSDK",t.initFromQueue),e(r).on("wpformsPayPalCommerceInit",t.queueOrInit)},queueOrInit(e,t,a,o){var r;"single"===o&&((r=new i).init(t,wpforms_paypal_commerce.payment_options[a],o),i.checkApplePayAPI()?r.initPaymentButton():n.push(r))},initFromQueue(e,{handle:t}){"wpforms-paypal-commerce-apple-pay-sdk"===t&&(i.checkApplePayAPI()?WPFormsPaypalCommercePaymentHandler.processQueue(n):console.error("Apple Pay SDK not loaded"))}};t.init()})(document,window,jQuery);

View File

@@ -0,0 +1 @@
let WPFormsPaypalCommercePaymentHandler=window.WPFormsPaypalCommercePaymentHandler||(document,{processQueue(e){for(;0<e.length;)e.shift().initPaymentButton()},PaymentHandler:class{constructor(){this.$form=null,this.formOptions=null,this.type=null}init(e,t,r){this.$form=e,this.formOptions=t,this.type=r}validateBeforePayment(){return new Promise((e,t)=>{this.$form.find(".wpforms-paypal-commerce-error").remove(),(WPFormsUtils.triggerEvent(this.$form,"wpformsPayPalCommerceOnCheckoutClick",[this.$form]).isDefaultPrevented()?t:wpforms.amountTotalCalc(this.$form)?this.$form.validate().form()?e:t:(WPFormsPaypalCommerce.onError(this.$form,wpforms_paypal_commerce.i18n.empty_amount),t))()})}getFormOptions(){var e=this.$form.data("formid");return wpforms_paypal_commerce.payment_options[e]}getPayPalSDK(){return"single"===this.type?wpforms_paypal_single:wpforms_paypal_subscriptions}initPaymentButton(){throw new Error("initPaymentButton() must be implemented by subclass")}processPayment(e){throw new Error("processPayment() must be implemented by subclass")}}});

View File

@@ -0,0 +1 @@
((e,t,o)=>{let r=[],a={apiVersion:2,apiVersionMinor:0};class i extends WPFormsPaypalCommercePaymentHandler.PaymentHandler{constructor(){super(),this.paymentsClient=null,this.config=null}getButtonContainer(){var e=this.$form.find(".wpforms-paypal-commerce-googlepay-button");return e.length?e:null}buildPaymentDataRequest(){return{...a,transactionInfo:this.getTransactionInfo(),allowedPaymentMethods:this.config.allowedPaymentMethods,merchantInfo:this.config.merchantInfo,callbackIntents:["PAYMENT_AUTHORIZATION"]}}createGooglePayButton(e){e={buttonColor:this.formOptions.googlepay.buttonColor,buttonRadius:this.formOptions.googlepay.buttonRadius,buttonType:this.formOptions.googlepay.buttonType,buttonBorderType:this.formOptions.googlepay.borderType,buttonLocale:this.formOptions.googlepay.locale||"en",buttonSizeMode:this.formOptions.googlepay.sizeMode,buttonRootNode:e,onClick:()=>this.validateBeforePayment().then(()=>this.paymentsClient.loadPaymentData(this.buildPaymentDataRequest())).catch(()=>{})},e=this.paymentsClient.createButton(e);return this.applyFillSizeModeStylesToInnerButton(e),"sandbox"===wpforms_paypal_commerce.mode&&o("iframe.gpay-card-info-iframe",e).attr("sandbox","allow-scripts"),e}applyFillSizeModeStylesToInnerButton(t){if(t&&"fill"===this.formOptions.googlepay.sizeMode){let e=null;try{e=t.querySelector("button")}catch(e){}e&&e.style&&(e.style.setProperty("min-width","0","important"),e.style.setProperty("width","100%","important"),e.style.setProperty("max-width","100%","important"))}}async initPaymentButton(){var e=this.getPayPalSDK();if(void 0!==e&&void 0!==e.Googlepay){var t,o,a=this.getButtonContainer();if(a)try{await this.isAvailable(e.Googlepay())&&(t=a[0].attachShadow({mode:"open"}),o=this.createGooglePayButton(t),a.removeClass("wpforms-hidden"),t.appendChild(o))}catch(e){console.error("Google Pay availability check error:",e)}}}createPaymentsClient(){return new t.google.payments.api.PaymentsClient({environment:"sandbox"===wpforms_paypal_commerce.mode?"TEST":"PRODUCTION",paymentDataCallbacks:{onPaymentAuthorized:e=>this.onPaymentAuthorized(e)}})}async checkDeviceReadiness(){var e=Object.assign({},a,{allowedPaymentMethods:this.config.allowedPaymentMethods});return!0===(await this.paymentsClient.isReadyToPay(e)).result}async isAvailable(e){return!!e&&(this.config=await e.config(),this.paymentsClient=this.createPaymentsClient(),this.checkDeviceReadiness())}onPaymentAuthorized(t){return new Promise(e=>{this.processPayment(t).then(()=>{e({transactionState:"SUCCESS"})}).catch(()=>{e({transactionState:"ERROR",error:{intent:"PAYMENT_AUTHORIZATION",message:"Payment processing failed",reason:"PAYMENT_DATA_INVALID"}})})})}async processPayment(e){try{var t=this.getPayPalSDK(),o=await WPFormsPaypalCommerce.createSingleOrder(this.$form,"google_pay"),a=(await t.Googlepay().confirmOrder({orderId:o,paymentMethodData:e.paymentMethodData})).status;if("APPROVED"===a)return WPFormsPaypalCommerce.submitPaymentForm(this.$form,o,this.type,"google_pay"),{transactionState:"SUCCESS"};throw new Error("Payment not approved")}catch(e){throw console.error("Google Pay payment processing error:",e),this.showError(wpforms_paypal_commerce.i18n.on_error),e}}getTransactionInfo(){var e=String(wpforms.amountTotalCalc(this.$form)),t=wpforms.getCurrency();return{countryCode:this.config.countryCode,currencyCode:t.code,totalPriceStatus:"FINAL",checkoutOption:"COMPLETE_IMMEDIATE_PURCHASE",totalPrice:e,totalPriceLabel:wpforms_paypal_commerce.total_price_label}}static checkGooglePaymentsAPI(){return void 0!==t.google&&void 0!==t.google.payments}}let n={init(){o(e).on("wpformsPayPalCommerceLoadedSDK",n.initFromQueue),o(e).on("wpformsPayPalCommerceInit",n.queueOrInit)},queueOrInit(e,t,o,a){var n;"single"===a&&((n=new i).init(t,wpforms_paypal_commerce.payment_options[o],a),i.checkGooglePaymentsAPI()?n.initPaymentButton():r.push(n))},initFromQueue(e,{handle:t}){"wpforms-paypal-commerce-google-pay-sdk"===t&&(i.checkGooglePaymentsAPI()?WPFormsPaypalCommercePaymentHandler.processQueue(r):console.error("Google Pay SDK not loaded"))}};n.init()})(document,window,jQuery);