integration-plugin 1.0.0
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/index.cjs +41 -0
- package/dist/index.js +41 -0
- package/package.json +21 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
var f=Object.create;var i=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var b=Object.getPrototypeOf,P=Object.prototype.hasOwnProperty;var h=(e,n)=>{for(var t in n)i(e,t,{get:n[t],enumerable:!0})},c=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of x(n))!P.call(e,r)&&r!==t&&i(e,r,{get:()=>n[r],enumerable:!(o=w(n,r))||o.enumerable});return e};var S=(e,n,t)=>(t=e!=null?f(b(e)):{},c(n||!e||!e.__esModule?i(t,"default",{value:e,enumerable:!0}):t,e)),I=e=>c(i({},"__esModule",{value:!0}),e);var R={};h(R,{createPayment:()=>u,initPlugin:()=>m});module.exports=I(R);var d=S(require("axios"),1),p="",l="",m=e=>{p=e.apiUrl,l=e.apiKey},y=()=>d.default.create({baseURL:p,headers:{"Content-Type":"application/json","X-API-KEY":l}});var u=async e=>{let o=(await y().post("/payments",{amount:e.amount,currency:e.currency,description:e.description})).data;return console.log("Payment response:",o),o.gatewayType==="RAZORPAY"&&await v(o),o.gatewayType==="STRIPE"&&await E(o),o},g=e=>new Promise(n=>{let t=document.createElement("script");t.src=e,t.onload=()=>n(!0),t.onerror=()=>n(!1),document.body.appendChild(t)}),v=async e=>{if(!await g(e.paymentUrl)){alert("Failed to load Razorpay SDK");return}let t={key:e.keyId,amount:e.amount,currency:e.currency,order_id:e.paymentId,name:"Payment",handler:function(r){console.log("Razorpay success:",r)},modal:{ondismiss:function(){console.log("Payment popup closed")}}};new window.Razorpay(t).open()},E=async e=>{if(!await g("https://js.stripe.com/v3/")){alert("Stripe SDK failed to load");return}let t=window.Stripe(e.publishableKey),o=document.createElement("div");o.id="stripe-payment-container",o.innerHTML=`
|
|
2
|
+
<div style="
|
|
3
|
+
position:fixed;
|
|
4
|
+
top:0;
|
|
5
|
+
left:0;
|
|
6
|
+
width:100%;
|
|
7
|
+
height:100%;
|
|
8
|
+
background:#00000080;
|
|
9
|
+
display:flex;
|
|
10
|
+
align-items:center;
|
|
11
|
+
justify-content:center;
|
|
12
|
+
z-index:9999;
|
|
13
|
+
">
|
|
14
|
+
<div style="
|
|
15
|
+
background:white;
|
|
16
|
+
padding:30px;
|
|
17
|
+
border-radius:10px;
|
|
18
|
+
width:400px;
|
|
19
|
+
">
|
|
20
|
+
<h3>Stripe Payment</h3>
|
|
21
|
+
<div id="stripe-card-element" style="
|
|
22
|
+
border:1px solid #ddd;
|
|
23
|
+
padding:10px;
|
|
24
|
+
margin-top:10px;
|
|
25
|
+
margin-bottom:20px;
|
|
26
|
+
"></div>
|
|
27
|
+
|
|
28
|
+
<button id="stripe-pay-btn" style="
|
|
29
|
+
width:100%;
|
|
30
|
+
padding:10px;
|
|
31
|
+
background:#6772e5;
|
|
32
|
+
color:white;
|
|
33
|
+
border:none;
|
|
34
|
+
border-radius:5px;
|
|
35
|
+
cursor:pointer;
|
|
36
|
+
">
|
|
37
|
+
Pay
|
|
38
|
+
</button>
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
`,document.body.appendChild(o);let s=t.elements().create("card");s.mount("#stripe-card-element"),document.getElementById("stripe-pay-btn").addEventListener("click",async()=>{let a=await t.confirmCardPayment(e.clientSecret,{payment_method:{card:s}});a.error?alert(a.error.message):(console.log("Stripe payment success:",a.paymentIntent),a.paymentIntent.status==="succeeded"&&(alert("Payment successful"),document.getElementById("stripe-payment-container").remove()))})};0&&(module.exports={createPayment,initPlugin});
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import l from"axios";var s="",c="",m=e=>{s=e.apiUrl,c=e.apiKey},d=()=>l.create({baseURL:s,headers:{"Content-Type":"application/json","X-API-KEY":c}});var y=async e=>{let t=(await d().post("/payments",{amount:e.amount,currency:e.currency,description:e.description})).data;return console.log("Payment response:",t),t.gatewayType==="RAZORPAY"&&await u(t),t.gatewayType==="STRIPE"&&await g(t),t},p=e=>new Promise(o=>{let n=document.createElement("script");n.src=e,n.onload=()=>o(!0),n.onerror=()=>o(!1),document.body.appendChild(n)}),u=async e=>{if(!await p(e.paymentUrl)){alert("Failed to load Razorpay SDK");return}let n={key:e.keyId,amount:e.amount,currency:e.currency,order_id:e.paymentId,name:"Payment",handler:function(a){console.log("Razorpay success:",a)},modal:{ondismiss:function(){console.log("Payment popup closed")}}};new window.Razorpay(n).open()},g=async e=>{if(!await p("https://js.stripe.com/v3/")){alert("Stripe SDK failed to load");return}let n=window.Stripe(e.publishableKey),t=document.createElement("div");t.id="stripe-payment-container",t.innerHTML=`
|
|
2
|
+
<div style="
|
|
3
|
+
position:fixed;
|
|
4
|
+
top:0;
|
|
5
|
+
left:0;
|
|
6
|
+
width:100%;
|
|
7
|
+
height:100%;
|
|
8
|
+
background:#00000080;
|
|
9
|
+
display:flex;
|
|
10
|
+
align-items:center;
|
|
11
|
+
justify-content:center;
|
|
12
|
+
z-index:9999;
|
|
13
|
+
">
|
|
14
|
+
<div style="
|
|
15
|
+
background:white;
|
|
16
|
+
padding:30px;
|
|
17
|
+
border-radius:10px;
|
|
18
|
+
width:400px;
|
|
19
|
+
">
|
|
20
|
+
<h3>Stripe Payment</h3>
|
|
21
|
+
<div id="stripe-card-element" style="
|
|
22
|
+
border:1px solid #ddd;
|
|
23
|
+
padding:10px;
|
|
24
|
+
margin-top:10px;
|
|
25
|
+
margin-bottom:20px;
|
|
26
|
+
"></div>
|
|
27
|
+
|
|
28
|
+
<button id="stripe-pay-btn" style="
|
|
29
|
+
width:100%;
|
|
30
|
+
padding:10px;
|
|
31
|
+
background:#6772e5;
|
|
32
|
+
color:white;
|
|
33
|
+
border:none;
|
|
34
|
+
border-radius:5px;
|
|
35
|
+
cursor:pointer;
|
|
36
|
+
">
|
|
37
|
+
Pay
|
|
38
|
+
</button>
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
`,document.body.appendChild(t);let i=n.elements().create("card");i.mount("#stripe-card-element"),document.getElementById("stripe-pay-btn").addEventListener("click",async()=>{let r=await n.confirmCardPayment(e.clientSecret,{payment_method:{card:i}});r.error?alert(r.error.message):(console.log("Stripe payment success:",r.paymentIntent),r.paymentIntent.status==="succeeded"&&(alert("Payment successful"),document.getElementById("stripe-payment-container").remove()))})};export{y as createPayment,m as initPlugin};
|
package/package.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "integration-plugin",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Payment gateway integration plugin (Razorpay, Stripe)",
|
|
5
|
+
"main": "dist/index.cjs",
|
|
6
|
+
"module": "dist/index.js",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsup"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"axios": "^1.6.0"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"tsup": "^8.5.1",
|
|
19
|
+
"typescript": "^5.9.3"
|
|
20
|
+
}
|
|
21
|
+
}
|