@foxy.io/elements 1.36.0-beta.2 → 1.36.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cdn/foxy-admin-subscription-form.js +1 -1
- package/dist/cdn/foxy-payments-api.js +1 -1
- package/dist/elements/public/AdminSubscriptionForm/AdminSubscriptionForm.js +3 -7
- package/dist/elements/public/AdminSubscriptionForm/AdminSubscriptionForm.js.map +1 -1
- package/dist/elements/public/PaymentsApi/api/composers/available_fraud_protections.js +7 -7
- package/dist/elements/public/PaymentsApi/api/composers/available_fraud_protections.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./shared-7ce74b42.js";import"./shared-43e551f2.js";import"./shared-528b3bdb.js";import"./shared-22dd6cbe.js";import{b as r,I as o}from"./shared-d784b79a.js";import"./foxy-transaction-card.js";import"./foxy-attribute-card.js";import"./foxy-attribute-form.js";import"./foxy-transaction.js";import"./shared-4e8a5b95.js";import{_ as t,B as e}from"./shared-d1195c27.js";import{i as s}from"./shared-53e42a77.js";import{h as a,s as i}from"./shared-ba5c42c7.js";import{a as n}from"./shared-f72d82a9.js";import"./shared-1482d5dd.js";import"./shared-c52295d5.js";import"./shared-01bb183b.js";import"./shared-c1ade7a9.js";import"./shared-0b00883f.js";import"./shared-0b1b1c14.js";import"./shared-2879b67f.js";import"./shared-d2340faa.js";import"./shared-6a45a781.js";import"./foxy-collection-page.js";import"./foxy-spinner.js";import"./shared-5f43aa36.js";import"./shared-17a61265.js";import"./shared-343d1fd7.js";import"./shared-eeb2bd18.js";import"./shared-d1dfac4d.js";import"./shared-7e9fdf64.js";import"./shared-cd96ff03.js";import"./shared-9cf15285.js";import"./shared-019348d7.js";import"./shared-1aff7995.js";import"./shared-fcdb896f.js";import"./shared-5fd5805c.js";import"./shared-53e476fd.js";import"./foxy-swipe-actions.js";import"./foxy-form-dialog.js";import"./shared-4c90701b.js";import"./shared-1a49f70b.js";import"./shared-4e709717.js";import"./foxy-pagination.js";import"./shared-d279baa5.js";import"./shared-fea2714e.js";import"./shared-cd652fd0.js";import"./shared-2e8361e1.js";import"./shared-6b76afc2.js";import"./shared-e0d1856d.js";import"./shared-4cf87721.js";import"./shared-10b54c49.js";import"./shared-6d11190a.js";import"./shared-651c44fa.js";import"./shared-3aaf64e6.js";import"./shared-76dcc864.js";import"./shared-e622d8cf.js";import"./shared-60150977.js";import"./shared-79d0699c.js";import"./shared-43e2c3f6.js";import"./shared-5212ef4f.js";import"./foxy-copy-to-clipboard.js";import"./shared-2503aefc.js";import"./shared-89d09114.js";import"./shared-bab2ea2c.js";import"./shared-1c07cd7f.js";import"./shared-93774efe.js";import"./shared-c5cf889e.js";import"./shared-8676e5c0.js";import"./foxy-billing-address-card.js";import"./foxy-custom-field-form.js";import"./shared-0053cf93.js";import"./foxy-custom-field-card.js";import"./shared-25893d83.js";import"./foxy-nucleon-element.js";import"./foxy-shipment-card.js";import"./shared-641786b2.js";import"./foxy-payment-card.js";import"./shared-cf613436.js";import"./foxy-webhook-card.js";import"./foxy-webhook-form.js";import"./shared-901b41cf.js";import"./shared-f20eefdd.js";import"./shared-42bb9e8e.js";import"./shared-cf28d2c8.js";import"./shared-133fc37b.js";import"./shared-d0aed1c1.js";import"./foxy-webhook-status-card.js";import"./foxy-webhook-log-card.js";import"./foxy-address-form.js";import"./foxy-item-card.js";import"./shared-9d7ae4aa.js";import"./foxy-item-form.js";import"./shared-2d11750b.js";import"./foxy-discount-detail-card.js";import"./foxy-coupon-detail-card.js";import"./foxy-item-category-card.js";import"./foxy-discount-builder.js";import"./shared-63c32024.js";import"./foxy-item-option-card.js";import"./foxy-item-option-form.js";import"./shared-8521017c.js";import"./foxy-customer-card.js";let d,m=r=>r;customElements.define("foxy-internal-admin-subscription-form-load-in-cart-action",class extends r{constructor(){super(...arguments),this.action=null}static get properties(){return t(t({},super.properties),{},{action:{}})}renderControl(){var r,o;const t=this.nucleon;let e;try{const s=new URL(null!==(o=null===(r=null==t?void 0:t.data)||void 0===r?void 0:r._links["fx:sub_token_url"].href)&&void 0!==o?o:"");"cancel"===this.action&&s.searchParams.set("sub_cancel","true"),e=s.toString()}catch(r){e=void 0}return a(d||(d=m` <a target="_blank" class="rounded font-medium text-primary group focus-outline-none focus-ring-2 focus-ring-primary-50" href="${0}"> <foxy-i18n class="transition-opacity group-hover-opacity-80" infer="" key="caption"> </foxy-i18n> </a> `),s(e))}});let c,f,l=r=>r;customElements.define("foxy-internal-admin-subscription-form-error",class extends r{renderControl(){var r,o;return a(c||(c=l` <p class="flex items-start gap-ds p-ds rounded border border-error-50" style="padding:calc(.625em + (var(--lumo-border-radius)/ 4) - 1px);gap:calc(.625em + (var(--lumo-border-radius)/ 4) - 1px)"> ${0} <span>${0}</span> </p> `),i(f||(f=l`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true" class="flex-shrink-0 text-error" style="width: 1.25em"><path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z" clip-rule="evenodd"></path></svg>`)),null===(o=null===(r=this.nucleon)||void 0===r?void 0:r.data)||void 0===o?void 0:o.error_message)}});let p,h,u=r=>r;const j=n(o,"admin-subscription-form");class y extends j{get hiddenSelector(){var r,o;const t=["delete",super.hiddenSelector.toString()];return(null===(r=this.data)||void 0===r?void 0:r.error_message)||t.unshift("error-message"),(null===(o=this.data)||void 0===o?void 0:o.is_active)||t.unshift("view-action","cancel-action"),new e(t.join(" ").trim())}get headerSubtitleOptions(){var r;return{context:(null===(r=this.data)||void 0===r?void 0:r.is_active)?"active":"inactive"}}renderHeaderActions(r){return a(p||(p=u` <foxy-internal-admin-subscription-form-load-in-cart-action infer="view-action"> </foxy-internal-admin-subscription-form-load-in-cart-action> <foxy-internal-admin-subscription-form-load-in-cart-action action="cancel" infer="cancel-action"> </foxy-internal-admin-subscription-form-load-in-cart-action> `))}renderBody(){var r,o,t,e,i;let n;try{const t=new URL(null!==(o=null===(r=this.data)||void 0===r?void 0:r._links["fx:transactions"].href)&&void 0!==o?o:"");t.searchParams.set("zoom","items"),n=t.toString()}catch(r){n=void 0}return a(h||(h=u` ${0} <foxy-internal-admin-subscription-form-error infer="error-message"> </foxy-internal-admin-subscription-form-error> <foxy-internal-summary-control infer="general"> <foxy-internal-date-control layout="summary-item"
|
|
1
|
+
import"./shared-7ce74b42.js";import"./shared-43e551f2.js";import"./shared-528b3bdb.js";import"./shared-22dd6cbe.js";import{b as r,I as o}from"./shared-d784b79a.js";import"./foxy-transaction-card.js";import"./foxy-attribute-card.js";import"./foxy-attribute-form.js";import"./foxy-transaction.js";import"./shared-4e8a5b95.js";import{_ as t,B as e}from"./shared-d1195c27.js";import{i as s}from"./shared-53e42a77.js";import{h as a,s as i}from"./shared-ba5c42c7.js";import{a as n}from"./shared-f72d82a9.js";import"./shared-1482d5dd.js";import"./shared-c52295d5.js";import"./shared-01bb183b.js";import"./shared-c1ade7a9.js";import"./shared-0b00883f.js";import"./shared-0b1b1c14.js";import"./shared-2879b67f.js";import"./shared-d2340faa.js";import"./shared-6a45a781.js";import"./foxy-collection-page.js";import"./foxy-spinner.js";import"./shared-5f43aa36.js";import"./shared-17a61265.js";import"./shared-343d1fd7.js";import"./shared-eeb2bd18.js";import"./shared-d1dfac4d.js";import"./shared-7e9fdf64.js";import"./shared-cd96ff03.js";import"./shared-9cf15285.js";import"./shared-019348d7.js";import"./shared-1aff7995.js";import"./shared-fcdb896f.js";import"./shared-5fd5805c.js";import"./shared-53e476fd.js";import"./foxy-swipe-actions.js";import"./foxy-form-dialog.js";import"./shared-4c90701b.js";import"./shared-1a49f70b.js";import"./shared-4e709717.js";import"./foxy-pagination.js";import"./shared-d279baa5.js";import"./shared-fea2714e.js";import"./shared-cd652fd0.js";import"./shared-2e8361e1.js";import"./shared-6b76afc2.js";import"./shared-e0d1856d.js";import"./shared-4cf87721.js";import"./shared-10b54c49.js";import"./shared-6d11190a.js";import"./shared-651c44fa.js";import"./shared-3aaf64e6.js";import"./shared-76dcc864.js";import"./shared-e622d8cf.js";import"./shared-60150977.js";import"./shared-79d0699c.js";import"./shared-43e2c3f6.js";import"./shared-5212ef4f.js";import"./foxy-copy-to-clipboard.js";import"./shared-2503aefc.js";import"./shared-89d09114.js";import"./shared-bab2ea2c.js";import"./shared-1c07cd7f.js";import"./shared-93774efe.js";import"./shared-c5cf889e.js";import"./shared-8676e5c0.js";import"./foxy-billing-address-card.js";import"./foxy-custom-field-form.js";import"./shared-0053cf93.js";import"./foxy-custom-field-card.js";import"./shared-25893d83.js";import"./foxy-nucleon-element.js";import"./foxy-shipment-card.js";import"./shared-641786b2.js";import"./foxy-payment-card.js";import"./shared-cf613436.js";import"./foxy-webhook-card.js";import"./foxy-webhook-form.js";import"./shared-901b41cf.js";import"./shared-f20eefdd.js";import"./shared-42bb9e8e.js";import"./shared-cf28d2c8.js";import"./shared-133fc37b.js";import"./shared-d0aed1c1.js";import"./foxy-webhook-status-card.js";import"./foxy-webhook-log-card.js";import"./foxy-address-form.js";import"./foxy-item-card.js";import"./shared-9d7ae4aa.js";import"./foxy-item-form.js";import"./shared-2d11750b.js";import"./foxy-discount-detail-card.js";import"./foxy-coupon-detail-card.js";import"./foxy-item-category-card.js";import"./foxy-discount-builder.js";import"./shared-63c32024.js";import"./foxy-item-option-card.js";import"./foxy-item-option-form.js";import"./shared-8521017c.js";import"./foxy-customer-card.js";let d,m=r=>r;customElements.define("foxy-internal-admin-subscription-form-load-in-cart-action",class extends r{constructor(){super(...arguments),this.action=null}static get properties(){return t(t({},super.properties),{},{action:{}})}renderControl(){var r,o;const t=this.nucleon;let e;try{const s=new URL(null!==(o=null===(r=null==t?void 0:t.data)||void 0===r?void 0:r._links["fx:sub_token_url"].href)&&void 0!==o?o:"");"cancel"===this.action&&s.searchParams.set("sub_cancel","true"),e=s.toString()}catch(r){e=void 0}return a(d||(d=m` <a target="_blank" class="rounded font-medium text-primary group focus-outline-none focus-ring-2 focus-ring-primary-50" href="${0}"> <foxy-i18n class="transition-opacity group-hover-opacity-80" infer="" key="caption"> </foxy-i18n> </a> `),s(e))}});let c,f,l=r=>r;customElements.define("foxy-internal-admin-subscription-form-error",class extends r{renderControl(){var r,o;return a(c||(c=l` <p class="flex items-start gap-ds p-ds rounded border border-error-50" style="padding:calc(.625em + (var(--lumo-border-radius)/ 4) - 1px);gap:calc(.625em + (var(--lumo-border-radius)/ 4) - 1px)"> ${0} <span>${0}</span> </p> `),i(f||(f=l`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true" class="flex-shrink-0 text-error" style="width: 1.25em"><path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z" clip-rule="evenodd"></path></svg>`)),null===(o=null===(r=this.nucleon)||void 0===r?void 0:r.data)||void 0===o?void 0:o.error_message)}});let p,h,u=r=>r;const j=n(o,"admin-subscription-form");class y extends j{get hiddenSelector(){var r,o;const t=["delete",super.hiddenSelector.toString()];return(null===(r=this.data)||void 0===r?void 0:r.error_message)||t.unshift("error-message"),(null===(o=this.data)||void 0===o?void 0:o.is_active)||t.unshift("view-action","cancel-action"),new e(t.join(" ").trim())}get headerSubtitleOptions(){var r;return{context:(null===(r=this.data)||void 0===r?void 0:r.is_active)?"active":"inactive"}}renderHeaderActions(r){return a(p||(p=u` <foxy-internal-admin-subscription-form-load-in-cart-action infer="view-action"> </foxy-internal-admin-subscription-form-load-in-cart-action> <foxy-internal-admin-subscription-form-load-in-cart-action action="cancel" infer="cancel-action"> </foxy-internal-admin-subscription-form-load-in-cart-action> `))}renderBody(){var r,o,t,e,i;let n;try{const t=new URL(null!==(o=null===(r=this.data)||void 0===r?void 0:r._links["fx:transactions"].href)&&void 0!==o?o:"");t.searchParams.set("zoom","items"),n=t.toString()}catch(r){n=void 0}return a(h||(h=u` ${0} <foxy-internal-admin-subscription-form-error infer="error-message"> </foxy-internal-admin-subscription-form-error> <foxy-internal-summary-control infer="general"> <foxy-internal-date-control layout="summary-item" infer="start-date"> </foxy-internal-date-control> <foxy-internal-frequency-control layout="summary-item" infer="frequency" allow-twice-a-month> </foxy-internal-frequency-control> <foxy-internal-date-control layout="summary-item" infer="next-transaction-date"> </foxy-internal-date-control> <foxy-internal-date-control layout="summary-item" infer="end-date"> </foxy-internal-date-control> </foxy-internal-summary-control> <foxy-internal-summary-control infer="overdue"> <foxy-internal-number-control layout="summary-item" suffix="${0}" infer="past-due-amount" min="0"> </foxy-internal-number-control> </foxy-internal-summary-control> ${0} <foxy-internal-async-list-control infer="attributes" class="min-w-0" first="${0}" item="foxy-attribute-card" form="foxy-attribute-form" alert> </foxy-internal-async-list-control> <foxy-internal-async-list-control infer="transactions" class="min-w-0" first="${0}" item="foxy-transaction-card" form="foxy-transaction" hide-create-button hide-delete-button alert wide> </foxy-internal-async-list-control> ${0} `),this.renderHeader(),s(null===(t=this.data)||void 0===t?void 0:t._embedded["fx:transaction_template"].currency_code),this.renderTemplateOrSlot(),s(null===(i=null===(e=this.data)||void 0===e?void 0:e._links)||void 0===i?void 0:i["fx:attributes"].href),s(n),super.renderBody())}}customElements.define("foxy-admin-subscription-form",y);export{y as AdminSubscriptionForm};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{L as e}from"./shared-ba5c42c7.js";import{F as t}from"./shared-343d1fd7.js";import{aM as a,aH as s,_ as n}from"./shared-d1195c27.js";import{A as r}from"./shared-7e9fdf64.js";async function o(e){const t=await e;if(!t.ok)throw new Error(await t.text());return t.json()}async function i(e){var t;let s,n;try{const{hostedPaymentGatewaysHelperUrl:r,paymentGatewaysHelperUrl:i,getPaymentMethodSetUrl:l,request:d,fetch:m}=e;if("GET"!==d.method)throw s=405,new Error("Method not allowed. Allowed methods: GET.");const p=a(/\/payment_presets\/(.+)\/available_payment_methods/,{presetId:1}).exec(new URL(d.url).pathname).groups.presetId,h=o(m(r)),y=o(m(i)),f=await o(m(l(p))),c=(async()=>{const e=[];for(;;){const t=new URL(d.url).origin,a=new URL(`${t}/payment_presets/${p}/payment_methods`);a.searchParams.set("offset",e.length.toString()),a.searchParams.set("limit","200");const s=await o(m(a.toString()));if(e.push(...s._embedded["fx:payment_methods"]),s._embedded["fx:payment_methods"].length<200)break}return e})(),u=null===(t=f._links["fx:payment_gateway"])||void 0===t?void 0:t.href,w=u?await o(m(u)):void 0,_=function(e){const{hostedPaymentGatewaysHelper:t,paymentGatewaysHelper:a,paymentPresetId:s,paymentMethods:n,paymentGateway:r,base:o}=e,i=new URL(`./payment_presets/${s}/available_payment_methods`,o),l={};return Object.entries(t.values).forEach((([e,t])=>{l[e]=t;const a=n.find((t=>t.type===e));a&&(l[e].conflict={type:a.type,name:a.description})})),Object.entries(a.values).forEach((([e,t])=>{l[e]=t,r&&(l[e].conflict={type:r.type,name:r.description})})),{_links:{self:{href:i.toString()}},values:l}}({hostedPaymentGatewaysHelper:await h,paymentGatewaysHelper:await y,paymentPresetId:p,paymentGateway:w,paymentMethods:await c,base:new URL(d.url).origin});n=JSON.stringify(_),s=200}catch(e){n=e instanceof Error?e.message:String(e),s=null!=s?s:500}return new Response(n,{status:s})}function l(e){const{paymentPresetId:t,fraudProtections:a,base:s}=e,n=new URL(`./payment_presets/${t}/available_fraud_protections`,s),r={minfraud:{name:"MaxMind minFraud",uses_rejection_threshold:!0,json:null},google_recaptcha:{name:"Google reCAPTCHA",uses_rejection_threshold:!1,json:{blocks:[{id:"",parent_id:"",fields:[{id:"config",name:"Configuration",type:"select",description:"Determines how reCAPTCHA is configured to operate.",default_value:"disabled",options:[{name:"Disabled",value:"disabled"},{name:"Always enabled",value:"enabled_always"},{name:"Enabled by errors",value:"enabled_by_errors"}]},{id:"private_key",name:"Private Key",type:"text",optional:!0,description:"If using a custom subdomain, enter your Private Key here.",default_value:""},{id:"site_key",name:"Site Key",type:"text",optional:!0,description:"If using a custom subdomain, enter your Site Key here.",default_value:""}]}]}},custom_precheckout_hook:{name:"Pre-Checkout Webhook",uses_rejection_threshold:!1,json:{blocks:[{id:"",parent_id:"",fields:[{id:"enabled",name:"Enabled",type:"checkbox",default_value:!1},{id:"url",name:"URL",type:"text",description:"Url of your Pre-Checkout Hook",default_value:""},{id:"failure_handling",name:"Failure handling",type:"select",description:"Determines what happens to the checkout submission if your webhook fails to respond correctly.",default_value:"",options:[{name:"Reject",value:"reject"},{name:"Approve",value:"approve"}]}]}]}}};for(const e in r){const t=null==a?void 0:a.find((t=>t.type===e));t&&(r[e].conflict={type:t.type,name:t.description})}return{_links:{self:{href:n.toString()}},values:r}}async function d(e){let t,s;try{const{request:n,fetch:r}=e;if("GET"!==n.method)throw t=405,new Error("Method not allowed. Allowed methods: GET.");const i=a(/\/payment_presets\/(.+)\/available_fraud_protections/,{presetId:1}).exec(new URL(n.url).pathname).groups.presetId,d=(async()=>{const e=[];for(;;){const t=new URL(n.url).origin,a=new URL(`${t}/payment_presets/${i}/fraud_protections`);a.searchParams.set("offset",e.length.toString()),a.searchParams.set("limit","200");const s=await o(r(a.toString()));if(e.push(...s._embedded["fx:fraud_protections"]),s._embedded["fx:fraud_protections"].length<200)break}return e})(),m=l({fraudProtections:await d,paymentPresetId:i,base:new URL(n.url).origin});s=JSON.stringify(m),t=200}catch(e){s=e instanceof Error?e.message:String(e),t=null!=t?t:500}return new Response(s,{status:t})}const m=["_links"];function p(e){const{paymentMethodSetFraudProtectionId:t,paymentPresetId:a,fraudProtection:r,base:o}=e,{_links:i}=r,d=s(r,m),p=l({paymentPresetId:a,base:o}),h=`${new URL(i.self.href).pathname.split("/").pop()}C${t}`,y=new URL(`./payment_presets/${a}`,o),f=new URL(`./payment_presets/${a}/fraud_protections/${h}`,o);return n(n({_links:{self:{href:f.toString()},"fx:store":i["fx:store"],"fx:payment_preset":{href:y.toString()}}},d),{},{helper:p.values[r.type]})}async function h(e){var t,s;let n,r;try{const{fraudProtectionsUrl:i,getPaymentMethodSetUrl:l,request:d,fetch:m}=e;if(!["GET","POST"].includes(d.method))throw n=405,new Error("Method not allowed. Allowed methods: GET, POST.");const h=new URL(d.url),y=a(/\/payment_presets\/(.+)\/fraud_protections/,{presetId:1}).exec(h.pathname).groups.presetId,f=await o(m(l(y)));if("GET"===d.method){const e=parseInt(null!==(t=h.searchParams.get("offset"))&&void 0!==t?t:"0"),a=parseInt(null!==(s=h.searchParams.get("limit"))&&void 0!==s?s:"20"),i=new URL(f._links["fx:payment_method_set_fraud_protections"].href);i.searchParams.set("offset",String(Math.max(0,e-1))),i.searchParams.set("limit",String(a));const l=await o(m(i.toString())),c=await Promise.all(l._embedded["fx:payment_method_set_fraud_protections"].map((async e=>o(m(e._links["fx:fraud_protection"].href))))),u=function(e){const{paymentMethodSetFraudProtections:t,fraudProtections:a,paymentPresetId:s,base:n}=e,r=new URL(`/payment_presets/${s}/fraud_protections`,n);r.search=new URL(t._links.self.href).search;const o=new URL(r.toString());o.search=new URL(t._links.first.href).search;const i=new URL(r.toString());i.search=new URL(t._links.last.href).search;const l=new URL(r.toString());l.search=new URL(t._links.prev.href).search;const d=new URL(r.toString());d.search=new URL(t._links.next.href).search;const m=a.map((e=>{const a=t._embedded["fx:payment_method_set_fraud_protections"].find((t=>t.fraud_protection_uri===e._links.self.href));return p({paymentMethodSetFraudProtectionId:new URL(a._links.self.href).pathname.split("/").pop(),fraudProtection:e,paymentPresetId:s,base:n})}));return{_links:{first:{href:o.toString()},last:{href:i.toString()},prev:{href:l.toString()},next:{href:d.toString()},self:{href:r.toString()}},_embedded:{"fx:fraud_protections":m},returned_items:t.returned_items,total_items:t.total_items,offset:t.offset,limit:t.limit}}({paymentMethodSetFraudProtections:l,fraudProtections:c,paymentPresetId:y,base:new URL(d.url).origin});n=200,r=JSON.stringify(u)}else{const e=await d.json();delete e.helper;const t=m(i,{method:"POST",body:JSON.stringify(e)}),a=await o(t),s=await o(m(f._links["fx:payment_method_set_fraud_protections"].href,{method:"POST",body:JSON.stringify({payment_method_set_uri:f._links.self.href,fraud_protection_uri:a._links.self.href})})),l=p({paymentMethodSetFraudProtectionId:new URL(s._links.self.href).pathname.split("/").pop(),fraudProtection:a,paymentPresetId:y,base:new URL(d.url).origin});n=200,r=JSON.stringify(l)}}catch(e){r=e instanceof Error?e.message:String(e),n=null!=n?n:500}return new Response(r,{status:n})}async function y(e){let t,s;try{const{getPaymentMethodSetUrl:n,getFraudProtectionUrl:r,request:i,fetch:l}=e;if(!["GET","PATCH","DELETE"].includes(i.method))throw t=405,new Error("Method not allowed. Allowed methods: GET, PATCH, DELETE.");const d=a(/\/payment_presets\/(.+)\/fraud_protections\/(.+)/,{presetId:1,protectionId:2}),{presetId:m,protectionId:h}=d.exec(i.url).groups,y=n(m),f=h.substring(0,h.indexOf("C"));if("DELETE"===i.method){const e=(await o(l(y)))._links["fx:payment_method_set_fraud_protections"].href,t=new URL(e);t.searchParams.set("fraud_protection_id",f);const a=await o(l(t.toString())),s=a._embedded["fx:payment_method_set_fraud_protections"].map((e=>o(l(e._links.self.href,{method:"DELETE"}))));await Promise.all(s)}let c=await i.text();try{const e=JSON.parse(c);delete e.helper,c=JSON.stringify(e)}catch(e){}const u=l(r(f),{method:i.method,body:"PATCH"===i.method?c:null}),w=await o(u);s="DELETE"===i.method?JSON.stringify({message:"Fraud protection was successfully deleted."}):JSON.stringify(p({paymentMethodSetFraudProtectionId:h.substring(h.indexOf("C")+1),fraudProtection:w,paymentPresetId:m,base:new URL(i.url).origin}))}catch(e){s=e instanceof Error?e.message:String(e),t=null!=t?t:500}return new Response(s,{status:t})}const f=["_links"];function c(e){const{paymentPresetId:t,helper:a,base:r}=e,o="paymentGateway"in e?e.paymentGateway:e.hostedPaymentGateway,{_links:i}=o,l=s(o,f),d=new URL(i.self.href).pathname.split("/").pop();let m;m="paymentMethodSetHostedPaymentGatewayId"in e?`H${d}C${e.paymentMethodSetHostedPaymentGatewayId}`:`R${d}`;const p=new URL(`./payment_presets/${t}`,r),h=new URL(`./payment_presets/${t}/payment_methods/${m}`,r);return n(n({_links:{self:{href:h.toString()},"fx:store":i["fx:store"],"fx:payment_preset":{href:p.toString()}}},l),{},{helper:a})}async function u(e){var t,s,n,r;let i,l;try{const{hostedPaymentGatewaysHelperUrl:d,paymentGatewaysHelperUrl:m,hostedPaymentGatewaysUrl:p,getPaymentMethodSetUrl:h,paymentGatewaysUrl:y,request:f,fetch:u}=e;if(!["GET","POST"].includes(f.method))throw i=405,new Error("Method not allowed. Allowed methods: GET, POST.");const w=new URL(f.url),_=a(/\/payment_presets\/(.+)\/payment_methods/,{presetId:1}).exec(w.pathname).groups.presetId,[g,P,S]=await Promise.all([o(u(d)),o(u(m)),o(u(h(_)))]);if("GET"===f.method){const e=parseInt(null!==(t=w.searchParams.get("offset"))&&void 0!==t?t:"0"),a=parseInt(null!==(s=w.searchParams.get("limit"))&&void 0!==s?s:"20"),r=new URL(S._links["fx:payment_method_set_hosted_payment_gateways"].href);r.searchParams.set("offset",String(Math.max(0,e-1))),r.searchParams.set("limit",String(a));const d=null===(n=S._links["fx:payment_gateway"])||void 0===n?void 0:n.href,[m,p]=await Promise.all([d&&0===e?o(u(d)):null,o(u(r.toString()))]),h=await Promise.all(p._embedded["fx:payment_method_set_hosted_payment_gateways"].map((async e=>o(u(e._links["fx:hosted_payment_gateway"].href))))),y=function(e){var t,a;const{paymentMethodSetHostedPaymentGateways:s,hostedPaymentGatewaysHelper:n,hostedPaymentGateways:r,paymentGatewaysHelper:o,paymentPresetId:i,paymentGateway:l,query:d,base:m}=e,p=new URLSearchParams(d),h=parseInt(null!==(t=p.get("offset"))&&void 0!==t?t:"0"),y=parseInt(null!==(a=p.get("limit"))&&void 0!==a?a:"20"),f=s.total_items+(l?1:0),u=s.returned_items+(l&&"not-on-page"!==l?1:0),w=new URL(`/payment_presets/${i}/payment_methods`,m);w.search=d;const _=new URL(w.toString()),g=new URL(w.toString()),P=new URL(w.toString()),S=new URL(w.toString());_.searchParams.set("limit",String(y)),_.searchParams.set("offset",String(h)),g.searchParams.set("limit",String(y)),g.searchParams.set("offset",String(Math.max(0,f-y))),P.searchParams.set("limit",String(y)),P.searchParams.set("offset",String(Math.max(0,h-y))),S.searchParams.set("limit",String(y)),S.searchParams.set("offset",String(Math.min(h+y,Math.max(0,f-y))));const U=[...l&&"not-on-page"!==l?[l]:[],...r].map((e=>{const t=s._embedded["fx:payment_method_set_hosted_payment_gateways"].find((t=>t.hosted_payment_gateway_uri===e._links.self.href));return c(t?{paymentMethodSetHostedPaymentGatewayId:new URL(t._links.self.href).pathname.split("/").pop(),hostedPaymentGateway:e,paymentPresetId:i,helper:n.values[e.type],base:m}:{paymentPresetId:i,paymentGateway:e,helper:o.values[e.type],base:m})}));return{_links:{first:{href:_.toString()},last:{href:g.toString()},prev:{href:P.toString()},next:{href:S.toString()},self:{href:w.toString()}},_embedded:{"fx:payment_methods":U},returned_items:u,total_items:f,offset:h,limit:y}}({paymentMethodSetHostedPaymentGateways:p,hostedPaymentGatewaysHelper:g,paymentGatewaysHelper:P,hostedPaymentGateways:h,paymentPresetId:_,paymentGateway:m||(d?"not-on-page":void 0),query:new URL(f.url).search,base:new URL(f.url).origin});i=200,l=JSON.stringify(y)}else{const e=await f.clone().json(),t=!!g.values[null!==(r=e.type)&&void 0!==r?r:""];if(delete e.helper,t){const t=await o(u(p,{method:"POST",body:JSON.stringify(e)})),a=await o(u(S._links["fx:payment_method_set_hosted_payment_gateways"].href,{method:"POST",body:JSON.stringify({payment_method_set_uri:S._links.self.href,hosted_payment_gateway_uri:t._links.self.href})})),s=c({paymentMethodSetHostedPaymentGatewayId:new URL(a._links.self.href).pathname.split("/").pop(),hostedPaymentGateway:t,paymentPresetId:_,helper:g.values[t.type],base:new URL(f.url).origin});i=200,l=JSON.stringify(s)}else{const t=u(y,{method:f.method,body:JSON.stringify(e)}),a=await o(t),s={gateway_uri:a._links.self.href};await Promise.all([o(u(S._links.self.href,{method:"PATCH",body:JSON.stringify(s)})),S.gateway_uri?o(u(S.gateway_uri,{method:"DELETE"})):null]);const n=c({paymentPresetId:_,paymentGateway:a,helper:P.values[a.type],base:new URL(f.url).origin});i=200,l=JSON.stringify(n)}}}catch(e){l=e instanceof Error?e.message:String(e),i=null!=i?i:500}return new Response(l,{status:i})}const w=["_links"];function _(e){const{paymentMethodSet:t,base:a}=e,{_links:r}=t,o=s(t,w),i=new URL(t._links.self.href).pathname.split("/").pop(),l=new URL(`./payment_presets/${i}`,a),d=new URL(`./payment_presets/${i}/payment_methods`,a),m=new URL(`./payment_presets/${i}/fraud_protections`,a),p=new URL(`./payment_presets/${i}/available_payment_methods`,a),h=new URL(`./payment_presets/${i}/available_fraud_protections`,a);return n({_links:{self:{href:l.toString()},"fx:store":r["fx:store"],"fx:payment_methods":{href:d.toString()},"fx:fraud_protections":{href:m.toString()},"fx:available_payment_methods":{href:p.toString()},"fx:available_fraud_protections":{href:h.toString()}}},o)}const g=["_embedded","_links"];async function P(e){let t,a;try{const{paymentMethodSetsUrl:r,request:i,fetch:l}=e;if(!["GET","POST"].includes(i.method))throw t=405,new Error("Method not allowed. Allowed methods: GET, POST.");const d=new URL(i.url),m=new URL(r);let p;if(m.search=d.search,"POST"===i.method){const e=l(m.toString(),{method:"POST",body:await i.text()});p=_({paymentMethodSet:await o(e),base:d.origin})}else p=function(e){const{paymentMethodSets:t,base:a}=e,{_embedded:r,_links:o}=t,i=s(t,g),l=new URL("./payment_presets",a),d=new URL(o.first.href);l.search=d.search;const m=new URL("./payment_presets",a),p=new URL(o.last.href);m.search=p.search;const h=new URL("./payment_presets",a),y=new URL(o.prev.href);h.search=y.search;const f=new URL("./payment_presets",a),c=new URL(o.next.href);f.search=c.search;const u=new URL("./payment_presets",a),w=new URL(o.self.href);return u.search=w.search,n(n({},i),{},{_links:{first:{href:l.toString()},last:{href:m.toString()},prev:{href:h.toString()},next:{href:f.toString()},self:{href:u.toString()}},_embedded:{"fx:payment_presets":r["fx:payment_method_sets"].map((e=>_({paymentMethodSet:e,base:a})))}})}({paymentMethodSets:await o(l(m.toString())),base:d.origin});a=JSON.stringify(p),t=200}catch(e){a=e instanceof Error?e.message:String(e),t=null!=t?t:500}return new Response(a,{status:t})}async function S(e){let t,s;try{const{getPaymentMethodSetUrl:n,request:r,fetch:i}=e;if(!["GET","PATCH","DELETE"].includes(r.method))throw t=405,new Error("Method not allowed. Allowed methods: GET, PATCH, DELETE.");const l=a(/payment_presets\/(.+)/,{presetId:1}).exec(r.url).groups.presetId,d=new URL(r.url),m=new URL(n(l));m.search=d.search;const p=await o(i(m.toString(),{method:r.method,body:"PATCH"===r.method?await r.text():null}));s="DELETE"===r.method?JSON.stringify({message:"Payment preset was successfully deleted."}):JSON.stringify(_({paymentMethodSet:p,base:new URL(r.url).origin}))}catch(e){s=e instanceof Error?e.message:String(e),t=null!=t?t:500}return new Response(s,{status:t})}async function U(e){let t,s;try{const{hostedPaymentGatewaysHelperUrl:n,paymentGatewaysHelperUrl:r,getPaymentMethodSetHostedPaymentGatewayUrl:i,getHostedPaymentGatewayUrl:l,getPaymentMethodSetUrl:d,getPaymentGatewayUrl:m,request:p,fetch:h}=e;if(!["GET","PATCH","DELETE"].includes(p.method))throw t=405,new Error("Method not allowed. Allowed methods: GET, PATCH, DELETE.");const y=a(/\/payment_presets\/(.+)\/payment_methods\/(.+)/,{presetId:1,methodId:2}),{presetId:f,methodId:u}=y.exec(p.url).groups,w=u.startsWith("H"),_=d(f),g=u.substring(1,w?u.indexOf("C"):void 0),P=o(h(n)),S=o(h(r));if("DELETE"===p.method)if(w){const e=i(u.substring(u.indexOf("C")+1));await o(h(e,{method:"DELETE"}))}else{const e={gateway_uri:""},t=JSON.stringify(e);await o(h(_,{method:"PATCH",body:t}))}let U=await p.text();try{const e=JSON.parse(U);delete e.helper,U=JSON.stringify(e)}catch(e){}if(w){const e=h(l(g),{method:p.method,body:"PATCH"===p.method?U:null}),t=await P,a=await o(e);s="DELETE"===p.method?JSON.stringify({message:"Payment method was successfully deleted."}):JSON.stringify(c({paymentMethodSetHostedPaymentGatewayId:u.substring(u.indexOf("C")+1),hostedPaymentGateway:a,paymentPresetId:f,helper:t.values[a.type],base:new URL(p.url).origin}))}else{const e=h(m(g),{method:p.method,body:"PATCH"===p.method?U:null}),t=await S,a=await o(e);s="DELETE"===p.method?JSON.stringify({message:"Payment method was successfully deleted."}):JSON.stringify(c({paymentGateway:a,paymentPresetId:f,helper:t.values[a.type],base:new URL(p.url).origin}))}}catch(e){s=e instanceof Error?e.message:String(e),t=null!=t?t:500}return new Response(s,{status:t})}class b extends e{constructor(){super(...arguments),this.paymentMethodSetHostedPaymentGatewayBaseUrl=null,this.paymentMethodSetHostedPaymentGatewaysUrl=null,this.hostedPaymentGatewaysHelperUrl=null,this.hostedPaymentGatewayBaseUrl=null,this.hostedPaymentGatewaysUrl=null,this.paymentGatewaysHelperUrl=null,this.paymentMethodSetBaseUrl=null,this.paymentMethodSetsUrl=null,this.fraudProtectionBaseUrl=null,this.fraudProtectionsUrl=null,this.paymentGatewayBaseUrl=null,this.paymentGatewaysUrl=null,this.__api=new r(this),this.__fetch=this.__api.fetch.bind(this.__api),this.__handleFetch=e=>{var s,n,r,o,l;if(!(e instanceof t))return;if(!e.request.url.startsWith("https://foxy-payments-api.element/"))return;if(e.defaultPrevented)return;const{paymentMethodSetHostedPaymentGatewaysUrl:m,hostedPaymentGatewaysHelperUrl:p,paymentGatewaysHelperUrl:f,hostedPaymentGatewaysUrl:c,paymentMethodSetsUrl:w,fraudProtectionsUrl:_,paymentGatewaysUrl:g}=this,b=null!==(s=this.paymentMethodSetHostedPaymentGatewayBaseUrl)&&void 0!==s?s:this.paymentMethodSetHostedPaymentGatewaysUrl,G=null!==(n=this.hostedPaymentGatewayBaseUrl)&&void 0!==n?n:this.hostedPaymentGatewaysUrl,L=null!==(r=this.paymentMethodSetBaseUrl)&&void 0!==r?r:this.paymentMethodSetsUrl,E=null!==(o=this.fraudProtectionBaseUrl)&&void 0!==o?o:this.fraudProtectionsUrl,R=null!==(l=this.paymentGatewayBaseUrl)&&void 0!==l?l:this.paymentGatewaysUrl;if(null===m)return;if(null===b)return;if(null===p)return;if(null===f)return;if(null===c)return;if(null===G)return;if(null===w)return;if(null===L)return;if(null===_)return;if(null===E)return;if(null===g)return;if(null===R)return;const v=e=>t=>{const a=new URL(e);return a.pathname.endsWith("/")||(a.pathname+="/"),a.pathname+=t,a.toString()},x=function(e){const t=[[a(/\/payment_presets\/(.+?)\/payment_methods\/(.+?)/,{presetId:1,methodId:2}),U],[a(/\/payment_presets\/(.+?)\/available_fraud_protections/,{presetId:1}),d],[a(/\/payment_presets\/(.+?)\/available_payment_methods/,{presetId:1}),i],[a(/\/payment_presets\/(.+?)\/fraud_protections\/(.+?)/,{presetId:1,protectionId:2}),y],[a(/\/payment_presets\/(.+?)\/fraud_protections/,{presetId:1}),h],[a(/\/payment_presets\/(.+?)\/payment_methods/,{presetId:1}),u],[a(/\/payment_presets\/(.+?)/,{presetId:1}),S],[/\/payment_presets/,P]];for(const[a,s]of t)if(a.test(new URL(e.request.url).pathname))return s(e);return null}({hostedPaymentGatewaysHelperUrl:p,paymentGatewaysHelperUrl:f,hostedPaymentGatewaysUrl:c,paymentMethodSetsUrl:w,fraudProtectionsUrl:_,paymentGatewaysUrl:g,getPaymentMethodSetHostedPaymentGatewayUrl:v(m),getHostedPaymentGatewayUrl:v(G),getPaymentMethodSetUrl:v(L),getFraudProtectionUrl:v(E),getPaymentGatewayUrl:v(R),request:e.request,fetch:this.__fetch});x&&(e.preventDefault(),e.respondWith(x))}}static get properties(){return{paymentMethodSetHostedPaymentGatewayBaseUrl:{attribute:"payment-method-set-hosted-payment-gateway-base-url"},paymentMethodSetHostedPaymentGatewaysUrl:{attribute:"payment-method-set-hosted-payment-gateways-url"},hostedPaymentGatewaysHelperUrl:{attribute:"hosted-payment-gateways-helper-url"},hostedPaymentGatewayBaseUrl:{attribute:"hosted-payment-gateway-base-url"},hostedPaymentGatewaysUrl:{attribute:"hosted-payment-gateways-url"},paymentGatewaysHelperUrl:{attribute:"payment-gateways-helper-url"},paymentMethodSetBaseUrl:{attribute:"payment-method-set-base-url"},paymentMethodSetsUrl:{attribute:"payment-method-sets-url"},fraudProtectionBaseUrl:{attribute:"fraud-protection-base-url"},fraudProtectionsUrl:{attribute:"fraud-protections-url"},paymentGatewayBaseUrl:{attribute:"payment-gateway-base-url"},paymentGatewaysUrl:{attribute:"payment-gateways-url"}}}connectedCallback(){super.connectedCallback(),this.addEventListener("fetch",this.__handleFetch)}createRenderRoot(){return this}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("fetch",this.__handleFetch)}}customElements.define("foxy-payments-api",b);export{b as PaymentsApi};
|
|
1
|
+
import{L as e}from"./shared-ba5c42c7.js";import{F as t}from"./shared-343d1fd7.js";import{aM as a,aH as s,_ as n}from"./shared-d1195c27.js";import{A as r}from"./shared-7e9fdf64.js";async function o(e){const t=await e;if(!t.ok)throw new Error(await t.text());return t.json()}async function i(e){var t;let s,n;try{const{hostedPaymentGatewaysHelperUrl:r,paymentGatewaysHelperUrl:i,getPaymentMethodSetUrl:l,request:d,fetch:m}=e;if("GET"!==d.method)throw s=405,new Error("Method not allowed. Allowed methods: GET.");const p=a(/\/payment_presets\/(.+)\/available_payment_methods/,{presetId:1}).exec(new URL(d.url).pathname).groups.presetId,h=o(m(r)),y=o(m(i)),f=await o(m(l(p))),c=(async()=>{const e=[];for(;;){const t=new URL(d.url).origin,a=new URL(`${t}/payment_presets/${p}/payment_methods`);a.searchParams.set("offset",e.length.toString()),a.searchParams.set("limit","200");const s=await o(m(a.toString()));if(e.push(...s._embedded["fx:payment_methods"]),s._embedded["fx:payment_methods"].length<200)break}return e})(),u=null===(t=f._links["fx:payment_gateway"])||void 0===t?void 0:t.href,w=u?await o(m(u)):void 0,_=function(e){const{hostedPaymentGatewaysHelper:t,paymentGatewaysHelper:a,paymentPresetId:s,paymentMethods:n,paymentGateway:r,base:o}=e,i=new URL(`./payment_presets/${s}/available_payment_methods`,o),l={};return Object.entries(t.values).forEach((([e,t])=>{l[e]=t;const a=n.find((t=>t.type===e));a&&(l[e].conflict={type:a.type,name:a.description})})),Object.entries(a.values).forEach((([e,t])=>{l[e]=t,r&&(l[e].conflict={type:r.type,name:r.description})})),{_links:{self:{href:i.toString()}},values:l}}({hostedPaymentGatewaysHelper:await h,paymentGatewaysHelper:await y,paymentPresetId:p,paymentGateway:w,paymentMethods:await c,base:new URL(d.url).origin});n=JSON.stringify(_),s=200}catch(e){n=e instanceof Error?e.message:String(e),s=null!=s?s:500}return new Response(n,{status:s})}function l(e){const{paymentPresetId:t,fraudProtections:a,base:s}=e,n=new URL(`./payment_presets/${t}/available_fraud_protections`,s),r={minfraud:{name:"MaxMind minFraud",uses_rejection_threshold:!0,json:null},google_recaptcha:{name:"Google reCAPTCHA",uses_rejection_threshold:!1,json:{blocks:[{id:"",parent_id:"",fields:[{id:"config",name:"Configuration",type:"select",description:"",default_value:"disabled",options:[{name:"Disabled",value:"disabled"},{name:"Always enabled",value:"enabled_always"},{name:"Enabled by errors",value:"enabled_by_errors"}]},{id:"site_key",name:"Site Key",type:"text",optional:!0,description:"",default_value:""},{id:"private_key",name:"Secret Key",type:"text",optional:!0,description:"",default_value:""}]}]}},custom_precheckout_hook:{name:"Pre-Checkout Webhook",uses_rejection_threshold:!1,json:{blocks:[{id:"",parent_id:"",fields:[{id:"enabled",name:"Enabled",type:"checkbox",default_value:!1},{id:"url",name:"URL",type:"text",description:"Url of your Pre-Checkout Hook",default_value:""},{id:"failure_handling",name:"Failure handling",type:"select",description:"Determines what happens to the checkout submission if your webhook fails to respond correctly.",default_value:"",options:[{name:"Reject",value:"reject"},{name:"Approve",value:"approve"}]}]}]}}};for(const e in r){const t=null==a?void 0:a.find((t=>t.type===e));t&&(r[e].conflict={type:t.type,name:t.description})}return{_links:{self:{href:n.toString()}},values:r}}async function d(e){let t,s;try{const{request:n,fetch:r}=e;if("GET"!==n.method)throw t=405,new Error("Method not allowed. Allowed methods: GET.");const i=a(/\/payment_presets\/(.+)\/available_fraud_protections/,{presetId:1}).exec(new URL(n.url).pathname).groups.presetId,d=(async()=>{const e=[];for(;;){const t=new URL(n.url).origin,a=new URL(`${t}/payment_presets/${i}/fraud_protections`);a.searchParams.set("offset",e.length.toString()),a.searchParams.set("limit","200");const s=await o(r(a.toString()));if(e.push(...s._embedded["fx:fraud_protections"]),s._embedded["fx:fraud_protections"].length<200)break}return e})(),m=l({fraudProtections:await d,paymentPresetId:i,base:new URL(n.url).origin});s=JSON.stringify(m),t=200}catch(e){s=e instanceof Error?e.message:String(e),t=null!=t?t:500}return new Response(s,{status:t})}const m=["_links"];function p(e){const{paymentMethodSetFraudProtectionId:t,paymentPresetId:a,fraudProtection:r,base:o}=e,{_links:i}=r,d=s(r,m),p=l({paymentPresetId:a,base:o}),h=`${new URL(i.self.href).pathname.split("/").pop()}C${t}`,y=new URL(`./payment_presets/${a}`,o),f=new URL(`./payment_presets/${a}/fraud_protections/${h}`,o);return n(n({_links:{self:{href:f.toString()},"fx:store":i["fx:store"],"fx:payment_preset":{href:y.toString()}}},d),{},{helper:p.values[r.type]})}async function h(e){var t,s;let n,r;try{const{fraudProtectionsUrl:i,getPaymentMethodSetUrl:l,request:d,fetch:m}=e;if(!["GET","POST"].includes(d.method))throw n=405,new Error("Method not allowed. Allowed methods: GET, POST.");const h=new URL(d.url),y=a(/\/payment_presets\/(.+)\/fraud_protections/,{presetId:1}).exec(h.pathname).groups.presetId,f=await o(m(l(y)));if("GET"===d.method){const e=parseInt(null!==(t=h.searchParams.get("offset"))&&void 0!==t?t:"0"),a=parseInt(null!==(s=h.searchParams.get("limit"))&&void 0!==s?s:"20"),i=new URL(f._links["fx:payment_method_set_fraud_protections"].href);i.searchParams.set("offset",String(Math.max(0,e-1))),i.searchParams.set("limit",String(a));const l=await o(m(i.toString())),c=await Promise.all(l._embedded["fx:payment_method_set_fraud_protections"].map((async e=>o(m(e._links["fx:fraud_protection"].href))))),u=function(e){const{paymentMethodSetFraudProtections:t,fraudProtections:a,paymentPresetId:s,base:n}=e,r=new URL(`/payment_presets/${s}/fraud_protections`,n);r.search=new URL(t._links.self.href).search;const o=new URL(r.toString());o.search=new URL(t._links.first.href).search;const i=new URL(r.toString());i.search=new URL(t._links.last.href).search;const l=new URL(r.toString());l.search=new URL(t._links.prev.href).search;const d=new URL(r.toString());d.search=new URL(t._links.next.href).search;const m=a.map((e=>{const a=t._embedded["fx:payment_method_set_fraud_protections"].find((t=>t.fraud_protection_uri===e._links.self.href));return p({paymentMethodSetFraudProtectionId:new URL(a._links.self.href).pathname.split("/").pop(),fraudProtection:e,paymentPresetId:s,base:n})}));return{_links:{first:{href:o.toString()},last:{href:i.toString()},prev:{href:l.toString()},next:{href:d.toString()},self:{href:r.toString()}},_embedded:{"fx:fraud_protections":m},returned_items:t.returned_items,total_items:t.total_items,offset:t.offset,limit:t.limit}}({paymentMethodSetFraudProtections:l,fraudProtections:c,paymentPresetId:y,base:new URL(d.url).origin});n=200,r=JSON.stringify(u)}else{const e=await d.json();delete e.helper;const t=m(i,{method:"POST",body:JSON.stringify(e)}),a=await o(t),s=await o(m(f._links["fx:payment_method_set_fraud_protections"].href,{method:"POST",body:JSON.stringify({payment_method_set_uri:f._links.self.href,fraud_protection_uri:a._links.self.href})})),l=p({paymentMethodSetFraudProtectionId:new URL(s._links.self.href).pathname.split("/").pop(),fraudProtection:a,paymentPresetId:y,base:new URL(d.url).origin});n=200,r=JSON.stringify(l)}}catch(e){r=e instanceof Error?e.message:String(e),n=null!=n?n:500}return new Response(r,{status:n})}async function y(e){let t,s;try{const{getPaymentMethodSetUrl:n,getFraudProtectionUrl:r,request:i,fetch:l}=e;if(!["GET","PATCH","DELETE"].includes(i.method))throw t=405,new Error("Method not allowed. Allowed methods: GET, PATCH, DELETE.");const d=a(/\/payment_presets\/(.+)\/fraud_protections\/(.+)/,{presetId:1,protectionId:2}),{presetId:m,protectionId:h}=d.exec(i.url).groups,y=n(m),f=h.substring(0,h.indexOf("C"));if("DELETE"===i.method){const e=(await o(l(y)))._links["fx:payment_method_set_fraud_protections"].href,t=new URL(e);t.searchParams.set("fraud_protection_id",f);const a=await o(l(t.toString())),s=a._embedded["fx:payment_method_set_fraud_protections"].map((e=>o(l(e._links.self.href,{method:"DELETE"}))));await Promise.all(s)}let c=await i.text();try{const e=JSON.parse(c);delete e.helper,c=JSON.stringify(e)}catch(e){}const u=l(r(f),{method:i.method,body:"PATCH"===i.method?c:null}),w=await o(u);s="DELETE"===i.method?JSON.stringify({message:"Fraud protection was successfully deleted."}):JSON.stringify(p({paymentMethodSetFraudProtectionId:h.substring(h.indexOf("C")+1),fraudProtection:w,paymentPresetId:m,base:new URL(i.url).origin}))}catch(e){s=e instanceof Error?e.message:String(e),t=null!=t?t:500}return new Response(s,{status:t})}const f=["_links"];function c(e){const{paymentPresetId:t,helper:a,base:r}=e,o="paymentGateway"in e?e.paymentGateway:e.hostedPaymentGateway,{_links:i}=o,l=s(o,f),d=new URL(i.self.href).pathname.split("/").pop();let m;m="paymentMethodSetHostedPaymentGatewayId"in e?`H${d}C${e.paymentMethodSetHostedPaymentGatewayId}`:`R${d}`;const p=new URL(`./payment_presets/${t}`,r),h=new URL(`./payment_presets/${t}/payment_methods/${m}`,r);return n(n({_links:{self:{href:h.toString()},"fx:store":i["fx:store"],"fx:payment_preset":{href:p.toString()}}},l),{},{helper:a})}async function u(e){var t,s,n,r;let i,l;try{const{hostedPaymentGatewaysHelperUrl:d,paymentGatewaysHelperUrl:m,hostedPaymentGatewaysUrl:p,getPaymentMethodSetUrl:h,paymentGatewaysUrl:y,request:f,fetch:u}=e;if(!["GET","POST"].includes(f.method))throw i=405,new Error("Method not allowed. Allowed methods: GET, POST.");const w=new URL(f.url),_=a(/\/payment_presets\/(.+)\/payment_methods/,{presetId:1}).exec(w.pathname).groups.presetId,[g,P,S]=await Promise.all([o(u(d)),o(u(m)),o(u(h(_)))]);if("GET"===f.method){const e=parseInt(null!==(t=w.searchParams.get("offset"))&&void 0!==t?t:"0"),a=parseInt(null!==(s=w.searchParams.get("limit"))&&void 0!==s?s:"20"),r=new URL(S._links["fx:payment_method_set_hosted_payment_gateways"].href);r.searchParams.set("offset",String(Math.max(0,e-1))),r.searchParams.set("limit",String(a));const d=null===(n=S._links["fx:payment_gateway"])||void 0===n?void 0:n.href,[m,p]=await Promise.all([d&&0===e?o(u(d)):null,o(u(r.toString()))]),h=await Promise.all(p._embedded["fx:payment_method_set_hosted_payment_gateways"].map((async e=>o(u(e._links["fx:hosted_payment_gateway"].href))))),y=function(e){var t,a;const{paymentMethodSetHostedPaymentGateways:s,hostedPaymentGatewaysHelper:n,hostedPaymentGateways:r,paymentGatewaysHelper:o,paymentPresetId:i,paymentGateway:l,query:d,base:m}=e,p=new URLSearchParams(d),h=parseInt(null!==(t=p.get("offset"))&&void 0!==t?t:"0"),y=parseInt(null!==(a=p.get("limit"))&&void 0!==a?a:"20"),f=s.total_items+(l?1:0),u=s.returned_items+(l&&"not-on-page"!==l?1:0),w=new URL(`/payment_presets/${i}/payment_methods`,m);w.search=d;const _=new URL(w.toString()),g=new URL(w.toString()),P=new URL(w.toString()),S=new URL(w.toString());_.searchParams.set("limit",String(y)),_.searchParams.set("offset",String(h)),g.searchParams.set("limit",String(y)),g.searchParams.set("offset",String(Math.max(0,f-y))),P.searchParams.set("limit",String(y)),P.searchParams.set("offset",String(Math.max(0,h-y))),S.searchParams.set("limit",String(y)),S.searchParams.set("offset",String(Math.min(h+y,Math.max(0,f-y))));const U=[...l&&"not-on-page"!==l?[l]:[],...r].map((e=>{const t=s._embedded["fx:payment_method_set_hosted_payment_gateways"].find((t=>t.hosted_payment_gateway_uri===e._links.self.href));return c(t?{paymentMethodSetHostedPaymentGatewayId:new URL(t._links.self.href).pathname.split("/").pop(),hostedPaymentGateway:e,paymentPresetId:i,helper:n.values[e.type],base:m}:{paymentPresetId:i,paymentGateway:e,helper:o.values[e.type],base:m})}));return{_links:{first:{href:_.toString()},last:{href:g.toString()},prev:{href:P.toString()},next:{href:S.toString()},self:{href:w.toString()}},_embedded:{"fx:payment_methods":U},returned_items:u,total_items:f,offset:h,limit:y}}({paymentMethodSetHostedPaymentGateways:p,hostedPaymentGatewaysHelper:g,paymentGatewaysHelper:P,hostedPaymentGateways:h,paymentPresetId:_,paymentGateway:m||(d?"not-on-page":void 0),query:new URL(f.url).search,base:new URL(f.url).origin});i=200,l=JSON.stringify(y)}else{const e=await f.clone().json(),t=!!g.values[null!==(r=e.type)&&void 0!==r?r:""];if(delete e.helper,t){const t=await o(u(p,{method:"POST",body:JSON.stringify(e)})),a=await o(u(S._links["fx:payment_method_set_hosted_payment_gateways"].href,{method:"POST",body:JSON.stringify({payment_method_set_uri:S._links.self.href,hosted_payment_gateway_uri:t._links.self.href})})),s=c({paymentMethodSetHostedPaymentGatewayId:new URL(a._links.self.href).pathname.split("/").pop(),hostedPaymentGateway:t,paymentPresetId:_,helper:g.values[t.type],base:new URL(f.url).origin});i=200,l=JSON.stringify(s)}else{const t=u(y,{method:f.method,body:JSON.stringify(e)}),a=await o(t),s={gateway_uri:a._links.self.href};await Promise.all([o(u(S._links.self.href,{method:"PATCH",body:JSON.stringify(s)})),S.gateway_uri?o(u(S.gateway_uri,{method:"DELETE"})):null]);const n=c({paymentPresetId:_,paymentGateway:a,helper:P.values[a.type],base:new URL(f.url).origin});i=200,l=JSON.stringify(n)}}}catch(e){l=e instanceof Error?e.message:String(e),i=null!=i?i:500}return new Response(l,{status:i})}const w=["_links"];function _(e){const{paymentMethodSet:t,base:a}=e,{_links:r}=t,o=s(t,w),i=new URL(t._links.self.href).pathname.split("/").pop(),l=new URL(`./payment_presets/${i}`,a),d=new URL(`./payment_presets/${i}/payment_methods`,a),m=new URL(`./payment_presets/${i}/fraud_protections`,a),p=new URL(`./payment_presets/${i}/available_payment_methods`,a),h=new URL(`./payment_presets/${i}/available_fraud_protections`,a);return n({_links:{self:{href:l.toString()},"fx:store":r["fx:store"],"fx:payment_methods":{href:d.toString()},"fx:fraud_protections":{href:m.toString()},"fx:available_payment_methods":{href:p.toString()},"fx:available_fraud_protections":{href:h.toString()}}},o)}const g=["_embedded","_links"];async function P(e){let t,a;try{const{paymentMethodSetsUrl:r,request:i,fetch:l}=e;if(!["GET","POST"].includes(i.method))throw t=405,new Error("Method not allowed. Allowed methods: GET, POST.");const d=new URL(i.url),m=new URL(r);let p;if(m.search=d.search,"POST"===i.method){const e=l(m.toString(),{method:"POST",body:await i.text()});p=_({paymentMethodSet:await o(e),base:d.origin})}else p=function(e){const{paymentMethodSets:t,base:a}=e,{_embedded:r,_links:o}=t,i=s(t,g),l=new URL("./payment_presets",a),d=new URL(o.first.href);l.search=d.search;const m=new URL("./payment_presets",a),p=new URL(o.last.href);m.search=p.search;const h=new URL("./payment_presets",a),y=new URL(o.prev.href);h.search=y.search;const f=new URL("./payment_presets",a),c=new URL(o.next.href);f.search=c.search;const u=new URL("./payment_presets",a),w=new URL(o.self.href);return u.search=w.search,n(n({},i),{},{_links:{first:{href:l.toString()},last:{href:m.toString()},prev:{href:h.toString()},next:{href:f.toString()},self:{href:u.toString()}},_embedded:{"fx:payment_presets":r["fx:payment_method_sets"].map((e=>_({paymentMethodSet:e,base:a})))}})}({paymentMethodSets:await o(l(m.toString())),base:d.origin});a=JSON.stringify(p),t=200}catch(e){a=e instanceof Error?e.message:String(e),t=null!=t?t:500}return new Response(a,{status:t})}async function S(e){let t,s;try{const{getPaymentMethodSetUrl:n,request:r,fetch:i}=e;if(!["GET","PATCH","DELETE"].includes(r.method))throw t=405,new Error("Method not allowed. Allowed methods: GET, PATCH, DELETE.");const l=a(/payment_presets\/(.+)/,{presetId:1}).exec(r.url).groups.presetId,d=new URL(r.url),m=new URL(n(l));m.search=d.search;const p=await o(i(m.toString(),{method:r.method,body:"PATCH"===r.method?await r.text():null}));s="DELETE"===r.method?JSON.stringify({message:"Payment preset was successfully deleted."}):JSON.stringify(_({paymentMethodSet:p,base:new URL(r.url).origin}))}catch(e){s=e instanceof Error?e.message:String(e),t=null!=t?t:500}return new Response(s,{status:t})}async function U(e){let t,s;try{const{hostedPaymentGatewaysHelperUrl:n,paymentGatewaysHelperUrl:r,getPaymentMethodSetHostedPaymentGatewayUrl:i,getHostedPaymentGatewayUrl:l,getPaymentMethodSetUrl:d,getPaymentGatewayUrl:m,request:p,fetch:h}=e;if(!["GET","PATCH","DELETE"].includes(p.method))throw t=405,new Error("Method not allowed. Allowed methods: GET, PATCH, DELETE.");const y=a(/\/payment_presets\/(.+)\/payment_methods\/(.+)/,{presetId:1,methodId:2}),{presetId:f,methodId:u}=y.exec(p.url).groups,w=u.startsWith("H"),_=d(f),g=u.substring(1,w?u.indexOf("C"):void 0),P=o(h(n)),S=o(h(r));if("DELETE"===p.method)if(w){const e=i(u.substring(u.indexOf("C")+1));await o(h(e,{method:"DELETE"}))}else{const e={gateway_uri:""},t=JSON.stringify(e);await o(h(_,{method:"PATCH",body:t}))}let U=await p.text();try{const e=JSON.parse(U);delete e.helper,U=JSON.stringify(e)}catch(e){}if(w){const e=h(l(g),{method:p.method,body:"PATCH"===p.method?U:null}),t=await P,a=await o(e);s="DELETE"===p.method?JSON.stringify({message:"Payment method was successfully deleted."}):JSON.stringify(c({paymentMethodSetHostedPaymentGatewayId:u.substring(u.indexOf("C")+1),hostedPaymentGateway:a,paymentPresetId:f,helper:t.values[a.type],base:new URL(p.url).origin}))}else{const e=h(m(g),{method:p.method,body:"PATCH"===p.method?U:null}),t=await S,a=await o(e);s="DELETE"===p.method?JSON.stringify({message:"Payment method was successfully deleted."}):JSON.stringify(c({paymentGateway:a,paymentPresetId:f,helper:t.values[a.type],base:new URL(p.url).origin}))}}catch(e){s=e instanceof Error?e.message:String(e),t=null!=t?t:500}return new Response(s,{status:t})}class b extends e{constructor(){super(...arguments),this.paymentMethodSetHostedPaymentGatewayBaseUrl=null,this.paymentMethodSetHostedPaymentGatewaysUrl=null,this.hostedPaymentGatewaysHelperUrl=null,this.hostedPaymentGatewayBaseUrl=null,this.hostedPaymentGatewaysUrl=null,this.paymentGatewaysHelperUrl=null,this.paymentMethodSetBaseUrl=null,this.paymentMethodSetsUrl=null,this.fraudProtectionBaseUrl=null,this.fraudProtectionsUrl=null,this.paymentGatewayBaseUrl=null,this.paymentGatewaysUrl=null,this.__api=new r(this),this.__fetch=this.__api.fetch.bind(this.__api),this.__handleFetch=e=>{var s,n,r,o,l;if(!(e instanceof t))return;if(!e.request.url.startsWith("https://foxy-payments-api.element/"))return;if(e.defaultPrevented)return;const{paymentMethodSetHostedPaymentGatewaysUrl:m,hostedPaymentGatewaysHelperUrl:p,paymentGatewaysHelperUrl:f,hostedPaymentGatewaysUrl:c,paymentMethodSetsUrl:w,fraudProtectionsUrl:_,paymentGatewaysUrl:g}=this,b=null!==(s=this.paymentMethodSetHostedPaymentGatewayBaseUrl)&&void 0!==s?s:this.paymentMethodSetHostedPaymentGatewaysUrl,G=null!==(n=this.hostedPaymentGatewayBaseUrl)&&void 0!==n?n:this.hostedPaymentGatewaysUrl,L=null!==(r=this.paymentMethodSetBaseUrl)&&void 0!==r?r:this.paymentMethodSetsUrl,E=null!==(o=this.fraudProtectionBaseUrl)&&void 0!==o?o:this.fraudProtectionsUrl,R=null!==(l=this.paymentGatewayBaseUrl)&&void 0!==l?l:this.paymentGatewaysUrl;if(null===m)return;if(null===b)return;if(null===p)return;if(null===f)return;if(null===c)return;if(null===G)return;if(null===w)return;if(null===L)return;if(null===_)return;if(null===E)return;if(null===g)return;if(null===R)return;const v=e=>t=>{const a=new URL(e);return a.pathname.endsWith("/")||(a.pathname+="/"),a.pathname+=t,a.toString()},x=function(e){const t=[[a(/\/payment_presets\/(.+?)\/payment_methods\/(.+?)/,{presetId:1,methodId:2}),U],[a(/\/payment_presets\/(.+?)\/available_fraud_protections/,{presetId:1}),d],[a(/\/payment_presets\/(.+?)\/available_payment_methods/,{presetId:1}),i],[a(/\/payment_presets\/(.+?)\/fraud_protections\/(.+?)/,{presetId:1,protectionId:2}),y],[a(/\/payment_presets\/(.+?)\/fraud_protections/,{presetId:1}),h],[a(/\/payment_presets\/(.+?)\/payment_methods/,{presetId:1}),u],[a(/\/payment_presets\/(.+?)/,{presetId:1}),S],[/\/payment_presets/,P]];for(const[a,s]of t)if(a.test(new URL(e.request.url).pathname))return s(e);return null}({hostedPaymentGatewaysHelperUrl:p,paymentGatewaysHelperUrl:f,hostedPaymentGatewaysUrl:c,paymentMethodSetsUrl:w,fraudProtectionsUrl:_,paymentGatewaysUrl:g,getPaymentMethodSetHostedPaymentGatewayUrl:v(m),getHostedPaymentGatewayUrl:v(G),getPaymentMethodSetUrl:v(L),getFraudProtectionUrl:v(E),getPaymentGatewayUrl:v(R),request:e.request,fetch:this.__fetch});x&&(e.preventDefault(),e.respondWith(x))}}static get properties(){return{paymentMethodSetHostedPaymentGatewayBaseUrl:{attribute:"payment-method-set-hosted-payment-gateway-base-url"},paymentMethodSetHostedPaymentGatewaysUrl:{attribute:"payment-method-set-hosted-payment-gateways-url"},hostedPaymentGatewaysHelperUrl:{attribute:"hosted-payment-gateways-helper-url"},hostedPaymentGatewayBaseUrl:{attribute:"hosted-payment-gateway-base-url"},hostedPaymentGatewaysUrl:{attribute:"hosted-payment-gateways-url"},paymentGatewaysHelperUrl:{attribute:"payment-gateways-helper-url"},paymentMethodSetBaseUrl:{attribute:"payment-method-set-base-url"},paymentMethodSetsUrl:{attribute:"payment-method-sets-url"},fraudProtectionBaseUrl:{attribute:"fraud-protection-base-url"},fraudProtectionsUrl:{attribute:"fraud-protections-url"},paymentGatewayBaseUrl:{attribute:"payment-gateway-base-url"},paymentGatewaysUrl:{attribute:"payment-gateways-url"}}}connectedCallback(){super.connectedCallback(),this.addEventListener("fetch",this.__handleFetch)}createRenderRoot(){return this}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("fetch",this.__handleFetch)}}customElements.define("foxy-payments-api",b);export{b as PaymentsApi};
|
|
@@ -49,7 +49,7 @@ export class AdminSubscriptionForm extends Base {
|
|
|
49
49
|
</foxy-internal-admin-subscription-form-error>
|
|
50
50
|
|
|
51
51
|
<foxy-internal-summary-control infer="general">
|
|
52
|
-
<foxy-internal-date-control layout="summary-item"
|
|
52
|
+
<foxy-internal-date-control layout="summary-item" infer="start-date">
|
|
53
53
|
</foxy-internal-date-control>
|
|
54
54
|
<foxy-internal-frequency-control
|
|
55
55
|
layout="summary-item"
|
|
@@ -57,13 +57,9 @@ export class AdminSubscriptionForm extends Base {
|
|
|
57
57
|
allow-twice-a-month
|
|
58
58
|
>
|
|
59
59
|
</foxy-internal-frequency-control>
|
|
60
|
-
<foxy-internal-date-control
|
|
61
|
-
layout="summary-item"
|
|
62
|
-
format="iso-long"
|
|
63
|
-
infer="next-transaction-date"
|
|
64
|
-
>
|
|
60
|
+
<foxy-internal-date-control layout="summary-item" infer="next-transaction-date">
|
|
65
61
|
</foxy-internal-date-control>
|
|
66
|
-
<foxy-internal-date-control layout="summary-item"
|
|
62
|
+
<foxy-internal-date-control layout="summary-item" infer="end-date">
|
|
67
63
|
</foxy-internal-date-control>
|
|
68
64
|
</foxy-internal-summary-control>
|
|
69
65
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AdminSubscriptionForm.js","sourceRoot":"","sources":["../../../../src/elements/public/AdminSubscriptionForm/AdminSubscriptionForm.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,oDAAiD;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,MAAM,EAAE,GAAG,yBAAyB,CAAC;AACrC,MAAM,IAAI,GAAG,iBAAiB,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;AAEjD,MAAM,OAAO,qBAAsB,SAAQ,IAAU;IACnD,IAAI,cAAc;;QAChB,MAAM,WAAW,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC,CAAC;QAChE,IAAI,QAAC,IAAI,CAAC,IAAI,0CAAE,aAAa,CAAA;YAAE,WAAW,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;QACpE,IAAI,QAAC,IAAI,CAAC,IAAI,0CAAE,SAAS,CAAA;YAAE,WAAW,CAAC,OAAO,CAAC,aAAa,EAAE,eAAe,CAAC,CAAC;QAC/E,OAAO,IAAI,eAAe,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAC3D,CAAC;IAED,IAAI,qBAAqB;;QACvB,OAAO,EAAE,OAAO,EAAE,OAAA,IAAI,CAAC,IAAI,0CAAE,SAAS,EAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC;IACnE,CAAC;IAED,6DAA6D;IAC7D,mBAAmB,CAAC,IAAU;QAC5B,OAAO,IAAI,CAAA;;;;;;;;KAQV,CAAC;IACJ,CAAC;IAED,UAAU;;QACR,IAAI,gBAAoC,CAAC;QAEzC,IAAI;YACF,MAAM,GAAG,GAAG,IAAI,GAAG,aAAC,IAAI,CAAC,IAAI,0CAAE,MAAM,CAAC,iBAAiB,EAAE,IAAI,mCAAI,EAAE,CAAC,CAAC;YACrE,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YACtC,gBAAgB,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAC;SACnC;QAAC,WAAM;YACN,gBAAgB,GAAG,SAAS,CAAC;SAC9B;QAED,OAAO,IAAI,CAAA;QACP,IAAI,CAAC,YAAY,EAAE
|
|
1
|
+
{"version":3,"file":"AdminSubscriptionForm.js","sourceRoot":"","sources":["../../../../src/elements/public/AdminSubscriptionForm/AdminSubscriptionForm.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,oDAAiD;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,MAAM,EAAE,GAAG,yBAAyB,CAAC;AACrC,MAAM,IAAI,GAAG,iBAAiB,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;AAEjD,MAAM,OAAO,qBAAsB,SAAQ,IAAU;IACnD,IAAI,cAAc;;QAChB,MAAM,WAAW,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC,CAAC;QAChE,IAAI,QAAC,IAAI,CAAC,IAAI,0CAAE,aAAa,CAAA;YAAE,WAAW,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;QACpE,IAAI,QAAC,IAAI,CAAC,IAAI,0CAAE,SAAS,CAAA;YAAE,WAAW,CAAC,OAAO,CAAC,aAAa,EAAE,eAAe,CAAC,CAAC;QAC/E,OAAO,IAAI,eAAe,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAC3D,CAAC;IAED,IAAI,qBAAqB;;QACvB,OAAO,EAAE,OAAO,EAAE,OAAA,IAAI,CAAC,IAAI,0CAAE,SAAS,EAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC;IACnE,CAAC;IAED,6DAA6D;IAC7D,mBAAmB,CAAC,IAAU;QAC5B,OAAO,IAAI,CAAA;;;;;;;;KAQV,CAAC;IACJ,CAAC;IAED,UAAU;;QACR,IAAI,gBAAoC,CAAC;QAEzC,IAAI;YACF,MAAM,GAAG,GAAG,IAAI,GAAG,aAAC,IAAI,CAAC,IAAI,0CAAE,MAAM,CAAC,iBAAiB,EAAE,IAAI,mCAAI,EAAE,CAAC,CAAC;YACrE,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YACtC,gBAAgB,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAC;SACnC;QAAC,WAAM;YACN,gBAAgB,GAAG,SAAS,CAAC;SAC9B;QAED,OAAO,IAAI,CAAA;QACP,IAAI,CAAC,YAAY,EAAE;;;;;;;;;;;;;;;;;;;;;;;mBAuBR,SAAS,OAAC,IAAI,CAAC,IAAI,0CAAE,SAAS,CAAC,yBAAyB,EAAE,aAAa,CAAC;;;;;;;QAOnF,IAAI,CAAC,oBAAoB,EAAE;;;;;gBAKnB,SAAS,aAAC,IAAI,CAAC,IAAI,0CAAE,MAAM,0CAAG,eAAe,EAAE,IAAI,CAAC;;;;;;;;;;gBAUpD,SAAS,CAAC,gBAAgB,CAAC;;;;;;;;;;QAUnC,KAAK,CAAC,UAAU,EAAE;KACrB,CAAC;IACJ,CAAC;CACF","sourcesContent":["import type { TemplateResult } from 'lit-html';\nimport type { Data } from './types';\n\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { BooleanSelector } from '@foxy.io/sdk/core';\nimport { InternalForm } from '../../internal/InternalForm/InternalForm';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { html } from 'lit-html';\n\nconst NS = 'admin-subscription-form';\nconst Base = TranslatableMixin(InternalForm, NS);\n\nexport class AdminSubscriptionForm extends Base<Data> {\n get hiddenSelector(): BooleanSelector {\n const alwaysMatch = ['delete', super.hiddenSelector.toString()];\n if (!this.data?.error_message) alwaysMatch.unshift('error-message');\n if (!this.data?.is_active) alwaysMatch.unshift('view-action', 'cancel-action');\n return new BooleanSelector(alwaysMatch.join(' ').trim());\n }\n\n get headerSubtitleOptions(): Record<string, unknown> {\n return { context: this.data?.is_active ? 'active' : 'inactive' };\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n renderHeaderActions(data: Data): TemplateResult {\n return html`\n <foxy-internal-admin-subscription-form-load-in-cart-action infer=\"view-action\">\n </foxy-internal-admin-subscription-form-load-in-cart-action>\n <foxy-internal-admin-subscription-form-load-in-cart-action\n action=\"cancel\"\n infer=\"cancel-action\"\n >\n </foxy-internal-admin-subscription-form-load-in-cart-action>\n `;\n }\n\n renderBody(): TemplateResult {\n let transactionsHref: string | undefined;\n\n try {\n const url = new URL(this.data?._links['fx:transactions'].href ?? '');\n url.searchParams.set('zoom', 'items');\n transactionsHref = url.toString();\n } catch {\n transactionsHref = undefined;\n }\n\n return html`\n ${this.renderHeader()}\n\n <foxy-internal-admin-subscription-form-error infer=\"error-message\">\n </foxy-internal-admin-subscription-form-error>\n\n <foxy-internal-summary-control infer=\"general\">\n <foxy-internal-date-control layout=\"summary-item\" infer=\"start-date\">\n </foxy-internal-date-control>\n <foxy-internal-frequency-control\n layout=\"summary-item\"\n infer=\"frequency\"\n allow-twice-a-month\n >\n </foxy-internal-frequency-control>\n <foxy-internal-date-control layout=\"summary-item\" infer=\"next-transaction-date\">\n </foxy-internal-date-control>\n <foxy-internal-date-control layout=\"summary-item\" infer=\"end-date\">\n </foxy-internal-date-control>\n </foxy-internal-summary-control>\n\n <foxy-internal-summary-control infer=\"overdue\">\n <foxy-internal-number-control\n layout=\"summary-item\"\n suffix=${ifDefined(this.data?._embedded['fx:transaction_template'].currency_code)}\n infer=\"past-due-amount\"\n min=\"0\"\n >\n </foxy-internal-number-control>\n </foxy-internal-summary-control>\n\n ${this.renderTemplateOrSlot()}\n\n <foxy-internal-async-list-control\n infer=\"attributes\"\n class=\"min-w-0\"\n first=${ifDefined(this.data?._links?.['fx:attributes'].href)}\n item=\"foxy-attribute-card\"\n form=\"foxy-attribute-form\"\n alert\n >\n </foxy-internal-async-list-control>\n\n <foxy-internal-async-list-control\n infer=\"transactions\"\n class=\"min-w-0\"\n first=${ifDefined(transactionsHref)}\n item=\"foxy-transaction-card\"\n form=\"foxy-transaction\"\n hide-create-button\n hide-delete-button\n alert\n wide\n >\n </foxy-internal-async-list-control>\n\n ${super.renderBody()}\n `;\n }\n}\n"]}
|
|
@@ -20,7 +20,7 @@ export function compose(params) {
|
|
|
20
20
|
id: 'config',
|
|
21
21
|
name: 'Configuration',
|
|
22
22
|
type: 'select',
|
|
23
|
-
description: '
|
|
23
|
+
description: '',
|
|
24
24
|
default_value: 'disabled',
|
|
25
25
|
options: [
|
|
26
26
|
{ name: 'Disabled', value: 'disabled' },
|
|
@@ -29,19 +29,19 @@ export function compose(params) {
|
|
|
29
29
|
],
|
|
30
30
|
},
|
|
31
31
|
{
|
|
32
|
-
id: '
|
|
33
|
-
name: '
|
|
32
|
+
id: 'site_key',
|
|
33
|
+
name: 'Site Key',
|
|
34
34
|
type: 'text',
|
|
35
35
|
optional: true,
|
|
36
|
-
description: '
|
|
36
|
+
description: '',
|
|
37
37
|
default_value: '',
|
|
38
38
|
},
|
|
39
39
|
{
|
|
40
|
-
id: '
|
|
41
|
-
name: '
|
|
40
|
+
id: 'private_key',
|
|
41
|
+
name: 'Secret Key',
|
|
42
42
|
type: 'text',
|
|
43
43
|
optional: true,
|
|
44
|
-
description: '
|
|
44
|
+
description: '',
|
|
45
45
|
default_value: '',
|
|
46
46
|
},
|
|
47
47
|
],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"available_fraud_protections.js","sourceRoot":"","sources":["../../../../../../src/elements/public/PaymentsApi/api/composers/available_fraud_protections.ts"],"names":[],"mappings":"AAQA,MAAM,UAAU,OAAO,CAAC,MAAc;IACpC,MAAM,EAAE,eAAe,EAAE,QAAQ,EAAE,gBAAgB,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC;IAC1E,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,qBAAqB,QAAQ,8BAA8B,EAAE,IAAI,CAAC,CAAC;IAE3F,MAAM,MAAM,GAAwC;QAClD,QAAQ,EAAE;YACR,IAAI,EAAE,kBAAkB;YACxB,wBAAwB,EAAE,IAAI;YAC9B,IAAI,EAAE,IAAI;SACX;QACD,gBAAgB,EAAE;YAChB,IAAI,EAAE,kBAAkB;YACxB,wBAAwB,EAAE,KAAK;YAC/B,IAAI,EAAE;gBACJ,MAAM,EAAE;oBACN;wBACE,EAAE,EAAE,EAAE;wBACN,SAAS,EAAE,EAAE;wBACb,MAAM,EAAE;4BACN;gCACE,EAAE,EAAE,QAAQ;gCACZ,IAAI,EAAE,eAAe;gCACrB,IAAI,EAAE,QAAQ;gCACd,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"available_fraud_protections.js","sourceRoot":"","sources":["../../../../../../src/elements/public/PaymentsApi/api/composers/available_fraud_protections.ts"],"names":[],"mappings":"AAQA,MAAM,UAAU,OAAO,CAAC,MAAc;IACpC,MAAM,EAAE,eAAe,EAAE,QAAQ,EAAE,gBAAgB,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC;IAC1E,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,qBAAqB,QAAQ,8BAA8B,EAAE,IAAI,CAAC,CAAC;IAE3F,MAAM,MAAM,GAAwC;QAClD,QAAQ,EAAE;YACR,IAAI,EAAE,kBAAkB;YACxB,wBAAwB,EAAE,IAAI;YAC9B,IAAI,EAAE,IAAI;SACX;QACD,gBAAgB,EAAE;YAChB,IAAI,EAAE,kBAAkB;YACxB,wBAAwB,EAAE,KAAK;YAC/B,IAAI,EAAE;gBACJ,MAAM,EAAE;oBACN;wBACE,EAAE,EAAE,EAAE;wBACN,SAAS,EAAE,EAAE;wBACb,MAAM,EAAE;4BACN;gCACE,EAAE,EAAE,QAAQ;gCACZ,IAAI,EAAE,eAAe;gCACrB,IAAI,EAAE,QAAQ;gCACd,WAAW,EAAE,EAAE;gCACf,aAAa,EAAE,UAAU;gCACzB,OAAO,EAAE;oCACP,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE;oCACvC,EAAE,IAAI,EAAE,gBAAgB,EAAE,KAAK,EAAE,gBAAgB,EAAE;oCACnD,EAAE,IAAI,EAAE,mBAAmB,EAAE,KAAK,EAAE,mBAAmB,EAAE;iCAC1D;6BACF;4BACD;gCACE,EAAE,EAAE,UAAU;gCACd,IAAI,EAAE,UAAU;gCAChB,IAAI,EAAE,MAAM;gCACZ,QAAQ,EAAE,IAAI;gCACd,WAAW,EAAE,EAAE;gCACf,aAAa,EAAE,EAAE;6BAClB;4BACD;gCACE,EAAE,EAAE,aAAa;gCACjB,IAAI,EAAE,YAAY;gCAClB,IAAI,EAAE,MAAM;gCACZ,QAAQ,EAAE,IAAI;gCACd,WAAW,EAAE,EAAE;gCACf,aAAa,EAAE,EAAE;6BAClB;yBACF;qBACF;iBACF;aACF;SACF;QACD,uBAAuB,EAAE;YACvB,IAAI,EAAE,sBAAsB;YAC5B,wBAAwB,EAAE,KAAK;YAC/B,IAAI,EAAE;gBACJ,MAAM,EAAE;oBACN;wBACE,EAAE,EAAE,EAAE;wBACN,SAAS,EAAE,EAAE;wBACb,MAAM,EAAE;4BACN;gCACE,EAAE,EAAE,SAAS;gCACb,IAAI,EAAE,SAAS;gCACf,IAAI,EAAE,UAAU;gCAChB,aAAa,EAAE,KAAK;6BACrB;4BACD;gCACE,EAAE,EAAE,KAAK;gCACT,IAAI,EAAE,KAAK;gCACX,IAAI,EAAE,MAAM;gCACZ,WAAW,EAAE,+BAA+B;gCAC5C,aAAa,EAAE,EAAE;6BAClB;4BACD;gCACE,EAAE,EAAE,kBAAkB;gCACtB,IAAI,EAAE,kBAAkB;gCACxB,IAAI,EAAE,QAAQ;gCACd,WAAW,EACT,gGAAgG;gCAClG,aAAa,EAAE,EAAE;gCACjB,OAAO,EAAE;oCACP,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;oCACnC,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE;iCACtC;6BACF;yBACF;qBACF;iBACF;aACF;SACF;KACF,CAAC;IAEF,KAAK,MAAM,IAAI,IAAI,MAAM,EAAE;QACzB,MAAM,EAAE,GAAG,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;QAC7C,IAAI,EAAE;YAAE,MAAM,CAAC,IAAI,CAAC,CAAC,QAAQ,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,WAAW,EAAE,CAAC;KACzE;IAED,OAAO,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,QAAQ,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC;AACpE,CAAC","sourcesContent":["import type { AvailableFraudProtections, FraudProtection } from '../types';\n\nexport type Params = {\n fraudProtections?: FraudProtection[];\n paymentPresetId: string;\n base: string;\n};\n\nexport function compose(params: Params): AvailableFraudProtections {\n const { paymentPresetId: presetId, fraudProtections: fps, base } = params;\n const selfURL = new URL(`./payment_presets/${presetId}/available_fraud_protections`, base);\n\n const values: AvailableFraudProtections['values'] = {\n minfraud: {\n name: 'MaxMind minFraud',\n uses_rejection_threshold: true,\n json: null,\n },\n google_recaptcha: {\n name: 'Google reCAPTCHA',\n uses_rejection_threshold: false,\n json: {\n blocks: [\n {\n id: '',\n parent_id: '',\n fields: [\n {\n id: 'config',\n name: 'Configuration',\n type: 'select',\n description: '',\n default_value: 'disabled',\n options: [\n { name: 'Disabled', value: 'disabled' },\n { name: 'Always enabled', value: 'enabled_always' },\n { name: 'Enabled by errors', value: 'enabled_by_errors' },\n ],\n },\n {\n id: 'site_key',\n name: 'Site Key',\n type: 'text',\n optional: true,\n description: '',\n default_value: '',\n },\n {\n id: 'private_key',\n name: 'Secret Key',\n type: 'text',\n optional: true,\n description: '',\n default_value: '',\n },\n ],\n },\n ],\n },\n },\n custom_precheckout_hook: {\n name: 'Pre-Checkout Webhook',\n uses_rejection_threshold: false,\n json: {\n blocks: [\n {\n id: '',\n parent_id: '',\n fields: [\n {\n id: 'enabled',\n name: 'Enabled',\n type: 'checkbox',\n default_value: false,\n },\n {\n id: 'url',\n name: 'URL',\n type: 'text',\n description: 'Url of your Pre-Checkout Hook',\n default_value: '',\n },\n {\n id: 'failure_handling',\n name: 'Failure handling',\n type: 'select',\n description:\n 'Determines what happens to the checkout submission if your webhook fails to respond correctly.',\n default_value: '',\n options: [\n { name: 'Reject', value: 'reject' },\n { name: 'Approve', value: 'approve' },\n ],\n },\n ],\n },\n ],\n },\n },\n };\n\n for (const type in values) {\n const fp = fps?.find(fp => fp.type === type);\n if (fp) values[type].conflict = { type: fp.type, name: fp.description };\n }\n\n return { _links: { self: { href: selfURL.toString() } }, values };\n}\n"]}
|