@pabgw/vue 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.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/usePabPayment.d.ts +12 -0
- package/dist/usePabPayment.js +30 -0
- package/package.json +29 -0
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare function usePabPayment(): {
|
|
2
|
+
mount: (config: {
|
|
3
|
+
token?: string;
|
|
4
|
+
session?: string;
|
|
5
|
+
container: HTMLElement | string;
|
|
6
|
+
method?: string;
|
|
7
|
+
locale?: string;
|
|
8
|
+
baseUrl?: string;
|
|
9
|
+
}) => Promise<any>;
|
|
10
|
+
destroy: () => void;
|
|
11
|
+
pab: import("vue").Ref<any, any>;
|
|
12
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ref, onUnmounted } from 'vue';
|
|
2
|
+
const PAB_SDK_URL = 'https://quick2pay.pabgw.com/assets/sdk/v1/pabgw.js';
|
|
3
|
+
function loadPabSdk() {
|
|
4
|
+
if (window.PABGW)
|
|
5
|
+
return Promise.resolve();
|
|
6
|
+
return new Promise((resolve, reject) => {
|
|
7
|
+
const script = document.createElement('script');
|
|
8
|
+
script.src = PAB_SDK_URL;
|
|
9
|
+
script.onload = () => resolve();
|
|
10
|
+
script.onerror = () => reject(new Error('Failed to load PAB SDK'));
|
|
11
|
+
document.head.appendChild(script);
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
export function usePabPayment() {
|
|
15
|
+
const pabInstance = ref(null);
|
|
16
|
+
async function mount(config) {
|
|
17
|
+
await loadPabSdk();
|
|
18
|
+
const pab = new window.PABGW(config);
|
|
19
|
+
pabInstance.value = pab;
|
|
20
|
+
return pab;
|
|
21
|
+
}
|
|
22
|
+
function destroy() {
|
|
23
|
+
if (pabInstance.value) {
|
|
24
|
+
pabInstance.value.destroy();
|
|
25
|
+
pabInstance.value = null;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
onUnmounted(() => destroy());
|
|
29
|
+
return { mount, destroy, pab: pabInstance };
|
|
30
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pabgw/vue",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "PAB Gateway Payment Form — Vue 3 component",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": ["dist"],
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "vue-tsc --noEmit && tsc",
|
|
10
|
+
"prepublishOnly": "npm run build"
|
|
11
|
+
},
|
|
12
|
+
"peerDependencies": {
|
|
13
|
+
"vue": ">=3.0.0"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"vue": "^3.4.0",
|
|
17
|
+
"vue-tsc": "^2.0.0",
|
|
18
|
+
"typescript": "^5.0.0"
|
|
19
|
+
},
|
|
20
|
+
"keywords": ["pab", "payment", "gateway", "vue", "vue3", "stripe-elements-alternative"],
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "https://dev.azure.com/pabgw/PAB-Gateway"
|
|
25
|
+
},
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
}
|
|
29
|
+
}
|