PageSourceSearch

https://www.downstairscomedy.shop/assets/waterline/controllers/pay…a81cda8b84558b32d4e577b966c9b0b577c3cb81.js

js downstairscomedy.shop collected 2026-10-06 14:03:16 UTC 4,472 bytes, 1 lines download raw bytes

1import{Controller}from"@hotwired/stimulus";import{post,patch}from"@rails/request.js";import{loadPayPal,releasePayPal}from"waterline/helpers/payment_sdk_loader";import{computeBtnLgRadiusPx,computeBtnLgHeightPx,resolvePaypalStyle}from"waterline/helpers/bootstrap_tokens";export default class extends Controller{static values={fundingSource:String,style:Object,iqc:Boolean,approvedMessageId:String,checkoutButtonId:String,clientId:String,identityToken:String,partnerAttributionId:String,currency:String,components:String,enableFunding:String,disableFunding:String};connect(){this.mountId=`paypal-${Math.random().toString(36).slice(2)}`,this.connected=!0,this.zoidIframe&&(devlog("paypal reconnect, cleaning up stale iframe"),this.zoidIframe.remove()),devlog("paypal initializing...",{mountId:this.mountId,iqc:this.iqcValue,approvedMessageId:this.approvedMessageIdValue,checkoutButtonId:this.checkoutButtonIdValue}),this.iqcValue||this.toggleVisibility(!1),this.bootstrapSdk()}disconnect(){this.connected=!1,releasePayPal(this.mountId),clearTimeout(this.reenableTimer),this.reenableTimer=null,this.zoidIframe?.remove()}async bootstrapSdk(){try{await loadPayPal({mountId:this.mountId,commit:this.iqcValue,clientId:this.clientIdValue,identityToken:this.identityTokenValue,partnerAttributionId:this.partnerAttributionIdValue,currency:this.currencyValue,components:this.componentsValue,enableFunding:this.enableFundingValue,disableFunding:this.disableFundingValue})}catch(e){return void devlog("paypal SDK load failed:",e)}this.connected&&this.renderButtons()}renderButtons(){const e=resolvePaypalStyle(this.styleValue,computeBtnLgRadiusPx());this.element.style.height||(this.element.style.height=`${computeBtnLgHeightPx()}px`),devlog("paypal render buttons",{fundingSource:this.fundingSourceValue,style:e}),window.paypal.Buttons({fundingSource:this.fundingSourceValue,style:e,createOrder:this.payPalOrderCreate.bind(this),onApprove:this.payPalOrderApprove.bind(this),onCancel:this.payPalCancel.bind(this),onShippingAddressChange:this.payPalShippingAddressChange.bind(this),onShippingOptionsChange:this.payPalShippingOptionsChange.bind(this),onError:this.payPalError.bind(this)}).render(`#${this.element.id}`)}async payPalCancel(e){this.iqcValue&&(devlog("paypal express cancelled:",e),await post("/checkout/pay_pal_order/cancel?iqc=true",{responseKind:"turbo-stream"}))}async payPalOrderCreate(){devlog("paypal creating order...");const e=await post("/checkout/pay_pal_order?iqc="+(this.iqcValue?"true":"false"),{responseKind:"json"}),t=await e.json;if(t.goto)throw Turbo.visit(t.goto),new Error("cart total is zero, redirecting to checkout");return t.tracking_params&&window.parent.track_params(t.tracking_params),t.order_id}async payPalOrderApprove(e){if(devlog("paypal order approved:",e),await post("/checkout/pay_pal_order/background_update?iqc="+(this.iqcValue?"true":"false"),{responseKind:"json"}),this.iqcValue){const e=await post("/checkout/pay_pal_order/capture?iqc=true",{responseKind:"json"});if(!e.ok){devlog("paypal capture error:",e.statusCode);const t=await e.json.catch((()=>null));return void Turbo.visit(t?.goto||"/checkout")}const t=await e.json;t.tracking_params&&window.parent.track_params(t.tracking_params),t.goto&&Turbo.visit(t.goto)}else this.toggleVisibility(!0),this.checkoutButton&&(this.checkoutButton.disabled=!0,this.reenableTimer=setTimeout((()=>{this.reenableTimer=null,this.checkoutButton&&(this.checkoutButton.disabled=!1)}),5e3))}async payPalShippingAddressChange(e,t){if(devlog("paypal shipping address change:",e),!this.iqcValue)return;return(await patch("/checkout/pay_pal_order/shipping_address_change?iqc="+(this.iqcValue?"true":"false"),{body:e,responseKind:"json"})).ok?void 0:t.reject()}async payPalShippingOptionsChange(e,t){if(devlog("paypal shipping options change:",e),!this.iqcValue)return;return(await patch("/checkout/pay_pal_order/shipping_options_change?iqc="+(this.iqcValue?"true":"false"),{body:e,responseKind:"json"})).ok?void 0:t.reject()}payPalError(e){devlog("paypal error:",e)}toggleVisibility(e=!1){this.element.classList.toggle("d-none",e),this.checkoutButton&&this.checkoutButton.classList.toggle("d-none",!e),this.approvedMessage&&this.approvedMessage.classList.toggle("d-none",!e)}get zoidIframe(){return this.element.querySelector("[id^='zoid-']")}get checkoutButton(){return document.getElementById(this.checkoutButtonIdValue)}get approvedMessage(){return document.getElementById(this.approvedMessageIdValue)}}

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.