@ludens-reklame/nets-easy-client
Advanced tools
Comparing version 1.0.0 to 1.0.1
"use strict"; | ||
(async () => { | ||
try { | ||
console.log("Loading checkout…"); | ||
await loadCheckout(); | ||
@@ -11,5 +10,2 @@ } | ||
} | ||
finally { | ||
console.log("Done loading checkout"); | ||
} | ||
})(); | ||
@@ -16,0 +12,0 @@ async function loadCheckout() { |
@@ -1,1 +0,1 @@ | ||
"use strict";(async()=>{try{console.log("Loading checkout…");await loadCheckout()}catch(t){window.alert("Noe galt skjedde, vennligst prøv igjen eller kontakt oss for hjelp.");console.error(t)}finally{console.log("Done loading checkout")}})();async function loadCheckout(){const t="https://test.checkout.dibspayment.eu/v1/checkout.js?v=1";const e="https://checkout.dibspayment.eu/v1/checkout.js?v=1";const o="/api/v1/front/checkout/providers/nets-easy";const n=new Event("checkout:loaded");const a=document.currentScript;if(!a){throw new Error("No current script")}const c=a.getAttribute("data-container-id");const r=a.getAttribute("data-checkout-path");const i=a.getAttribute("data-checkout-completed-path");if(!c||!r||!i){throw new Error("Missing required attributes")}const s=await fetch(`${o}/payments`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:r})});if(!s.ok){throw new Error("Failed to create payment")}const d=await s.json();const p=d.testModeEnabled?t:e;loadScript(p,function(){const e=new Dibs.Checkout({checkoutKey:d.checkoutKey,paymentId:d.paymentId,containerId:c,language:"nb-NO"});document.dispatchEvent(n);e.on("payment-completed",async function(t){try{if(!t||!t.paymentId){throw new Error("No paymentId in response")}const e=await fetch(`${o}/payments/${t.paymentId}/create-order`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:r})});if(!e.ok){throw new Error("Failed to create order")}if(i){window.location.href=i}}catch(t){console.error(t);window.alert("Noe galt skjedde, vennligst prøv igjen eller kontakt oss for hjelp.")}});document.addEventListener("cart:updating",function(){e.freezeCheckout()});document.addEventListener("cart:updated",async function(){try{const t=await fetch(`${o}/payments/${d.paymentId}/update`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:r})});if(!t.ok){throw new Error("Failed to update payment")}e.thawCheckout()}catch(t){console.error(t);window.alert("Noe galt skjedde, vennligst prøv igjen eller kontakt oss for hjelp.");window.location.reload()}})})}function loadScript(t,e){var o=document.createElement("script");o.type="text/javascript";o.onload=function(){e()};o.src=t;document.getElementsByTagName("head")[0].appendChild(o)} | ||
"use strict";(async()=>{try{await loadCheckout()}catch(t){window.alert("Noe galt skjedde, vennligst prøv igjen eller kontakt oss for hjelp.");console.error(t)}})();async function loadCheckout(){const t="https://test.checkout.dibspayment.eu/v1/checkout.js?v=1";const e="https://checkout.dibspayment.eu/v1/checkout.js?v=1";const o="/api/v1/front/checkout/providers/nets-easy";const n=new Event("checkout:loaded");const a=document.currentScript;if(!a){throw new Error("No current script")}const c=a.getAttribute("data-container-id");const r=a.getAttribute("data-checkout-path");const i=a.getAttribute("data-checkout-completed-path");if(!c||!r||!i){throw new Error("Missing required attributes")}const s=await fetch(`${o}/payments`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:r})});if(!s.ok){throw new Error("Failed to create payment")}const d=await s.json();const p=d.testModeEnabled?t:e;loadScript(p,function(){const e=new Dibs.Checkout({checkoutKey:d.checkoutKey,paymentId:d.paymentId,containerId:c,language:"nb-NO"});document.dispatchEvent(n);e.on("payment-completed",async function(t){try{if(!t||!t.paymentId){throw new Error("No paymentId in response")}const e=await fetch(`${o}/payments/${t.paymentId}/create-order`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:r})});if(!e.ok){throw new Error("Failed to create order")}if(i){window.location.href=i}}catch(t){console.error(t);window.alert("Noe galt skjedde, vennligst prøv igjen eller kontakt oss for hjelp.")}});document.addEventListener("cart:updating",function(){e.freezeCheckout()});document.addEventListener("cart:updated",async function(){try{const t=await fetch(`${o}/payments/${d.paymentId}/update`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:r})});if(!t.ok){throw new Error("Failed to update payment")}e.thawCheckout()}catch(t){console.error(t);window.alert("Noe galt skjedde, vennligst prøv igjen eller kontakt oss for hjelp.");window.location.reload()}})})}function loadScript(t,e){var o=document.createElement("script");o.type="text/javascript";o.onload=function(){e()};o.src=t;document.getElementsByTagName("head")[0].appendChild(o)} |
{ | ||
"name": "@ludens-reklame/nets-easy-client", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "NETS Easy for Rubics", | ||
"main": "dist/client.js", | ||
"main": "dist/client.min.js", | ||
"private": false, | ||
@@ -7,0 +7,0 @@ "scripts": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7225
114