Created
February 4, 2026 05:11
-
-
Save mseptiaan/d9dba18750121d3de9be2e7e47249509 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| !function(n,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((n="undefined"!=typeof globalThis?globalThis:n||self).OPG={})}(this,function(n){"use strict";const e={isOpen:!1,url:null,callbacks:{}};let t={...e};function o(){return t.isOpen}const a=["settlement","capture"],r=["pending","challenge"],i=["deny","cancel","expire","failure"];var d,s;let l={...{sandbox:!0,sandboxPaymentUrl:null!==(d="https://pay-sandbox.ojire.online/pay")?d:"https://pay-sandbox.ojire.online/pay",productionPaymentUrl:null!==(s="https://pay.ojire.online/pay")?s:"https://pay.ojire.online/pay"}};function c(n){l={...l,...n}}const u="opg-payment-modal",p="opg-payment-backdrop",f="opg-payment-container",m="opg-payment-iframe",y="opg-payment-close",b="opg-payment-spinner";let g=null,v=null;function h(n){var e,o,d,s,l,c,u;const p=t.callbacks;if("COPY_TEXT"===n.data.type)return void navigator.clipboard.writeText(n.data.value);if("PAYMENT_SUCCESS"===(null===(e=n.data)||void 0===e?void 0:e.type)){const n={transactionStatus:"settlement",status:"success",rawData:{type:"PAYMENT_SUCCESS"}};return null===(o=p.onSuccess)||void 0===o||o.call(p,n),void k()}if("PAYMENT_RESULT"===(null===(d=n.data)||void 0===d?void 0:d.type)){const e=n.data.status;let t,o;switch(e){case"expired":t="expire",o="error";break;case"failed":default:t="failure",o="error";break;case"canceled":t="cancel",o="error"}const a={transactionStatus:t,status:o,rawData:{type:"PAYMENT_RESULT",status:e}};return null===(s=p.onError)||void 0===s||s.call(p,a),void k()}if("object"!=typeof(f=n.data)||null===f||"string"!=typeof f.transaction_status)return;var f;const m=function(n){const e=n.transaction_status;return{transactionStatus:e,status:(t=e,a.includes(t)?"success":r.includes(t)?"pending":(i.includes(t),"error")),rawData:n};var t}(n.data);switch(m.status){case"success":null===(l=p.onSuccess)||void 0===l||l.call(p,m);break;case"pending":null===(c=p.onPending)||void 0===c||c.call(p,m);break;case"error":null===(u=p.onError)||void 0===u||u.call(p,m)}}function x(n){"Escape"===n.key&&k()}function w(n){n.target.id===p&&k()}function E(n,e,o,a){const r=function(n){return`${l.sandbox?l.sandboxPaymentUrl:l.productionPaymentUrl}/${n}`}(e);if(document.getElementById(u))return;!function(){if(document.getElementById("opg-sdk-styles"))return;const n=document.createElement("style");n.id="opg-sdk-styles",n.textContent=`\n #${p} {\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background: rgba(0, 0, 0, 0.6);\n z-index: 999998;\n }\n\n #${f} {\n position: fixed;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n width: 90%;\n max-width: 480px;\n height: 80%;\n max-height: 700px;\n background: #fff;\n border-radius: 12px;\n box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);\n z-index: 999999;\n display: flex;\n flex-direction: column;\n overflow: hidden;\n }\n\n #${y} {\n position: absolute;\n top: 12px;\n right: 12px;\n width: 32px;\n height: 32px;\n border: none;\n background: rgba(0, 0, 0, 0.1);\n border-radius: 50%;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 10;\n transition: background 0.2s;\n }\n\n #${y}:hover {\n background: rgba(0, 0, 0, 0.2);\n }\n\n #${y}::before,\n #${y}::after {\n content: '';\n position: absolute;\n width: 16px;\n height: 2px;\n background: #333;\n }\n\n #${y}::before {\n transform: rotate(45deg);\n }\n\n #${y}::after {\n transform: rotate(-45deg);\n }\n\n #${m} {\n width: 100%;\n height: 100%;\n border: none;\n flex: 1;\n }\n\n #${b} {\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n width: 40px;\n height: 40px;\n border: 3px solid #f3f3f3;\n border-top: 3px solid #3498db;\n border-radius: 50%;\n animation: opg-spin 1s linear infinite;\n }\n\n @keyframes opg-spin {\n 0% { transform: translate(-50%, -50%) rotate(0deg); }\n 100% { transform: translate(-50%, -50%) rotate(360deg); }\n }\n\n #${b}.hidden {\n display: none;\n }\n `,document.head.appendChild(n)}(),document.body.style.overflow="hidden";const i=document.createElement("div");i.id=u;const d=document.createElement("div");d.id=p,d.addEventListener("click",w);const s=document.createElement("div");s.id=f;const c=document.createElement("button");c.id=y,c.type="button",c.setAttribute("aria-label","Close payment"),c.addEventListener("click",()=>k());const E=document.createElement("div");E.id=b;const P=document.createElement("iframe");var S;P.id=m,P.src=r,P.setAttribute("allow","payment"),P.setAttribute("allow","clipboard-write"),P.addEventListener("load",()=>{E.classList.add("hidden")}),P.onload=()=>{var e;null===(e=P.contentWindow)||void 0===e||e.postMessage({type:"INIT",clientSecret:n,publicKey:o,token:a},r)},s.appendChild(c),s.appendChild(E),s.appendChild(P),i.appendChild(d),i.appendChild(s),document.body.appendChild(i),g=h,v=x,window.addEventListener("message",g),document.addEventListener("keydown",v),S={isOpen:!0,url:r},t={...t,...S}}function k(){const n=document.getElementById(u);n&&(g&&(window.removeEventListener("message",g),g=null),v&&(document.removeEventListener("keydown",v),v=null),n.remove(),document.body.style.overflow="",t={...e,isOpen:!1,callbacks:t.callbacks})}var P,S,C;const $=null!==(S=null===(P=document.currentScript)||void 0===P?void 0:P.getAttribute("data-client-key"))&&void 0!==S?S:void 0;function T(n){if(o())return void console.warn("[opg-sdk] Payment modal is already open");if(!n.token)throw new Error("[opg-sdk] Payment token is required");if(!n.clientSecret)throw new Error("[opg-sdk] Payment clientSecret is required");if(!n.paymentId)throw new Error("[opg-sdk] Payment paymentId is required");if(!$)throw new Error("[opg-sdk] Payment publicKey is required");void 0!==n.sandbox&&c({sandbox:n.sandbox});const{clientSecret:e,paymentId:a,token:r,onSuccess:i,onPending:d,onError:s}=n;var l;l={onSuccess:i,onPending:d,onError:s},t.callbacks=l,E(e,a,$,r)}function L(){k()}function A(){return o()}function O(n){c(n)}function _(){return l.sandbox}c({sandbox:"false"!==(null===(C=document.currentScript)||void 0===C?void 0:C.getAttribute("data-sandbox"))});const j={openPayment:T,closePayment:L,isPaymentOpen:A,configure:O,isSandbox:_};n.closePayment=L,n.configure=O,n.default=j,n.isPaymentOpen=A,n.isSandbox=_,n.openPayment=T,Object.defineProperty(n,"__esModule",{value:!0})}); | |
| //# sourceMappingURL=opg-sdk.umd.js.map |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment