xendit-components-web 0.0.9 → 0.0.11
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/CHANGELOG.md +23 -0
- package/README.md +27 -13
- package/package.json +34 -28
- package/sdk/dist/index.d.ts +49 -0
- package/sdk/dist/index.esm.js +3 -2
- package/sdk/dist/index.esm.js.map +1 -1
- package/sdk/dist/index.umd.js +3 -2
- package/sdk/dist/index.umd.js.map +1 -1
- package/README.md.bak +0 -315
package/CHANGELOG.md
CHANGED
|
@@ -2,8 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
No unreleased changes.
|
|
4
4
|
|
|
5
|
+
# 0.0.11
|
|
6
|
+
|
|
7
|
+
### Notable
|
|
8
|
+
|
|
9
|
+
Disabled Google Translate using the `translate=no` attribute as it causes issues.
|
|
10
|
+
|
|
11
|
+
Added new public method `pollImmediately` to immediently check for updates.
|
|
12
|
+
|
|
13
|
+
Changed the layout of the default action container.
|
|
14
|
+
|
|
15
|
+
## Bug fixes
|
|
16
|
+
|
|
17
|
+
- Fixed UX bugs in the dropdown widget.
|
|
18
|
+
- Prevent auto-updating the phone number country code if the user already typed a phone number.
|
|
19
|
+
|
|
20
|
+
# 0.0.10
|
|
21
|
+
|
|
22
|
+
## Bug fixes
|
|
23
|
+
|
|
24
|
+
Fixed npm publish.
|
|
25
|
+
|
|
5
26
|
# 0.0.9
|
|
6
27
|
|
|
28
|
+
## Bug fixes
|
|
29
|
+
|
|
7
30
|
Missing `.d.ts` file is restored.
|
|
8
31
|
|
|
9
32
|
# 0.0.8
|
package/README.md
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
# xendit-components-web
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/xendit-components-web) [](https://github.com/xendit/xendit-components-web/actions/workflows/build-and-test.yml?query=branch%3Amain) [](https://app.codecov.io/gh/xendit/xendit-components-web)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
With Xendit Components, you can build a checkout experience tightly integrated into your site, powered by the Xendit Sessions API.
|
|
6
|
+
|
|
7
|
+
This SDK provides UI components for payment method selection, user input (e.g. credit cards), and user actions (e.g. 3DS), all of which can be customized to match your site's look & feel.
|
|
8
|
+
|
|
9
|
+
View a live demo [here](https://demo-store.xendit.co/) by choosing "Xendit Components". View the demo source code [here](https://github.com/xendit/demo-store/tree/main/src/integrations).
|
|
6
10
|
|
|
7
11
|
## Installation
|
|
8
12
|
|
|
@@ -15,10 +19,10 @@ npm install xendit-components-web --save
|
|
|
15
19
|
Or load it directly from our CDN:
|
|
16
20
|
|
|
17
21
|
```html
|
|
18
|
-
<script src="https://assets.xendit.co/components/
|
|
22
|
+
<script src="https://assets.xendit.co/components/v0.0.11/index.umd.js"></script>
|
|
19
23
|
```
|
|
20
24
|
|
|
21
|
-
Our npm package includes TypeScript types.
|
|
25
|
+
Our npm package includes TypeScript types. You also download the [.d.ts file](https://assets.xendit.co/components/v0.0.11/index.d.ts) directly.
|
|
22
26
|
|
|
23
27
|
## Sessions
|
|
24
28
|
|
|
@@ -36,11 +40,11 @@ Two types of sessions are available:
|
|
|
36
40
|
|
|
37
41
|
First, initialize the SDK either with either:
|
|
38
42
|
|
|
39
|
-
- `XenditComponentsTest` for
|
|
40
|
-
- `XenditComponents
|
|
43
|
+
- Use `XenditComponentsTest` to use mock payment methods for development and testing.
|
|
44
|
+
- Use `XenditComponents` to connect to the Xendit backend (including Xendit's test mode). This requires a `componentsSdkKey` option, which you can get by calling the Create Session endpoint. Create a session from your server, passing the `components_sdk_key` property back to your frontend.
|
|
41
45
|
|
|
42
46
|
```typescript
|
|
43
|
-
// For frontend development, use XenditComponentsTest
|
|
47
|
+
// For frontend development, use XenditComponentsTest, this provides built-in mock payment methods
|
|
44
48
|
const components: XenditComponents = new XenditComponentsTest({});
|
|
45
49
|
// For production or e2e testing, use XenditComponents, passing in the components_sdk_key from the Session object
|
|
46
50
|
const components: XenditComponents = new XenditComponents({ componentsSdkKey });
|
|
@@ -69,11 +73,9 @@ components.addEventListener("session-expired-or-canceled", () => {
|
|
|
69
73
|
|
|
70
74
|
### `XenditComponents` and `XenditComponentsTest`
|
|
71
75
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
For production and e2e testing, you need to pass the `componentsSdkKey`, which you can get when you create a Session on your server.
|
|
76
|
+
Constructor functions.
|
|
75
77
|
|
|
76
|
-
|
|
78
|
+
Both have the same API. `XenditComponents` will connect to Xendit servers, while `XenditComponentsTest` provides mock payment channels.
|
|
77
79
|
|
|
78
80
|
### `createChannelPickerComponent`
|
|
79
81
|
|
|
@@ -112,7 +114,7 @@ your own channel selection UI. Each channel has a `uiGroup` property which match
|
|
|
112
114
|
```typescript
|
|
113
115
|
const channel = components.getActiveChannels({ filter: "CARDS" })[0];
|
|
114
116
|
if (channel) {
|
|
115
|
-
const htmlElement = components.
|
|
117
|
+
const htmlElement = components.createChannelComponent(channel);
|
|
116
118
|
myContainer.replaceChildren(htmlElement);
|
|
117
119
|
}
|
|
118
120
|
```
|
|
@@ -129,7 +131,11 @@ values the user enters into any form fields. If you don't want that, use `destro
|
|
|
129
131
|
|
|
130
132
|
```typescript
|
|
131
133
|
components.addEventListener("action-begin", () => {
|
|
132
|
-
const htmlElement = components.createActionContainerComponent(
|
|
134
|
+
const htmlElement = components.createActionContainerComponent({
|
|
135
|
+
qrCode: {
|
|
136
|
+
qrCodeOnly: true,
|
|
137
|
+
},
|
|
138
|
+
});
|
|
133
139
|
myActionContainer.replaceChildren(htmlElement);
|
|
134
140
|
});
|
|
135
141
|
```
|
|
@@ -226,6 +232,14 @@ if (channel) {
|
|
|
226
232
|
|
|
227
233
|
Makes the provided channel the current channel.
|
|
228
234
|
|
|
235
|
+
### `pollImmediately`
|
|
236
|
+
|
|
237
|
+
```typescript
|
|
238
|
+
components.pollImmediately();
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
Immediately poll for the status of a submission. Only applicable while a submission is ongoing. Useful for handling payment affirmation (e.g. I have made the payment) by the user.
|
|
242
|
+
|
|
229
243
|
## Events
|
|
230
244
|
|
|
231
245
|
### `init`
|
package/package.json
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xendit-components-web",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"description": "Xendit frontend payment components SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Xendit",
|
|
7
7
|
"license": "MIT",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/xendit/xendit-components-web"
|
|
11
|
+
},
|
|
8
12
|
"keywords": [
|
|
9
13
|
"xendit",
|
|
10
14
|
"payment",
|
|
@@ -34,19 +38,31 @@
|
|
|
34
38
|
"default": "./sdk/dist/index.umd.js"
|
|
35
39
|
}
|
|
36
40
|
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"dev": "./build.ts dev",
|
|
43
|
+
"build": "./build.ts prod",
|
|
44
|
+
"test": "vitest run",
|
|
45
|
+
"test:watch": "vitest",
|
|
46
|
+
"test:run": "vitest run",
|
|
47
|
+
"test:debug": "vitest run --printConsoleTrace=true --silent=false",
|
|
48
|
+
"lint": "eslint . --ext .ts,.tsx",
|
|
49
|
+
"lint:fix": "eslint . --fix --ext .ts,.tsx",
|
|
50
|
+
"prettier": "prettier . --check",
|
|
51
|
+
"prettier:fix": "prettier . --check --write",
|
|
52
|
+
"prepare": "husky"
|
|
53
|
+
},
|
|
37
54
|
"dependencies": {
|
|
38
55
|
"card-validator": "^10.0.3",
|
|
39
56
|
"classnames": "^2.5.1",
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"react-circle-flags": "^0.0.24",
|
|
57
|
+
"i18next": "^25.8.0",
|
|
58
|
+
"libphonenumber-js": "^1.12.35",
|
|
59
|
+
"preact": "^10.28.2",
|
|
60
|
+
"qrcode": "^1.5.4",
|
|
45
61
|
"tslib": "^2.8.1"
|
|
46
62
|
},
|
|
47
63
|
"devDependencies": {
|
|
48
|
-
"@eslint/js": "^9.39.
|
|
49
|
-
"@microsoft/api-extractor": "^7.55.
|
|
64
|
+
"@eslint/js": "^9.39.2",
|
|
65
|
+
"@microsoft/api-extractor": "^7.55.2",
|
|
50
66
|
"@preact/preset-vite": "^2.10.2",
|
|
51
67
|
"@rollup/plugin-alias": "^6.0.0",
|
|
52
68
|
"@rollup/plugin-commonjs": "^29.0.0",
|
|
@@ -60,30 +76,20 @@
|
|
|
60
76
|
"@testing-library/user-event": "^14.6.1",
|
|
61
77
|
"@types/mime-types": "^3.0.1",
|
|
62
78
|
"@types/node": "^24.10.1",
|
|
63
|
-
"@
|
|
64
|
-
"
|
|
79
|
+
"@types/qrcode": "^1.5.6",
|
|
80
|
+
"@vitest/coverage-v8": "4.0.17",
|
|
81
|
+
"eslint": "^9.39.2",
|
|
65
82
|
"eslint-plugin-react-hooks": "^7.0.1",
|
|
66
83
|
"husky": "^9.1.7",
|
|
67
|
-
"jsdom": "^27.
|
|
84
|
+
"jsdom": "^27.4.0",
|
|
68
85
|
"lint-staged": "^16.2.7",
|
|
69
86
|
"mime-types": "^3.0.2",
|
|
70
|
-
"prettier": "^3.
|
|
71
|
-
"rollup": "^4.
|
|
87
|
+
"prettier": "^3.8.1",
|
|
88
|
+
"rollup": "^4.56.0",
|
|
72
89
|
"rollup-plugin-import-css": "^4.1.2",
|
|
73
90
|
"typescript": "^5.9.3",
|
|
74
|
-
"typescript-eslint": "^8.
|
|
75
|
-
"vitest": "^4.0.
|
|
91
|
+
"typescript-eslint": "^8.53.1",
|
|
92
|
+
"vitest": "^4.0.17"
|
|
76
93
|
},
|
|
77
|
-
"
|
|
78
|
-
|
|
79
|
-
"build": "./build.ts prod",
|
|
80
|
-
"test": "vitest run",
|
|
81
|
-
"test:watch": "vitest",
|
|
82
|
-
"test:run": "vitest run",
|
|
83
|
-
"test:debug": "vitest run --printConsoleTrace=true --silent=false",
|
|
84
|
-
"lint": "eslint . --ext .ts,.tsx",
|
|
85
|
-
"lint:fix": "eslint . --fix --ext .ts,.tsx",
|
|
86
|
-
"prettier": "prettier . --check",
|
|
87
|
-
"prettier:fix": "prettier . --check --write"
|
|
88
|
-
}
|
|
89
|
-
}
|
|
94
|
+
"packageManager": "pnpm@10.28.1"
|
|
95
|
+
}
|
package/sdk/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @public
|
|
3
|
+
* Options for configuring action containers.
|
|
4
|
+
*/
|
|
5
|
+
export declare interface ActionContainerOptions {
|
|
6
|
+
/**
|
|
7
|
+
* QR code specific options.
|
|
8
|
+
*/
|
|
9
|
+
qrCode?: {
|
|
10
|
+
/**
|
|
11
|
+
* If true, only the QR code will be displayed without any additional UI elements.
|
|
12
|
+
*/
|
|
13
|
+
qrCodeOnly?: boolean;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
1
17
|
/**
|
|
2
18
|
* @public
|
|
3
19
|
* Channel properties for a payment method or payment token.
|
|
@@ -199,6 +215,13 @@ export declare class XenditComponents extends EventTarget {
|
|
|
199
215
|
* the SDK will create an action container (in a modal dialog) for you.
|
|
200
216
|
*/
|
|
201
217
|
createActionContainerComponent(): HTMLElement;
|
|
218
|
+
/**
|
|
219
|
+
* @public
|
|
220
|
+
* Creates a container element for rendering action UIs with options.
|
|
221
|
+
*
|
|
222
|
+
* @param options - Configuration options for the action container
|
|
223
|
+
*/
|
|
224
|
+
createActionContainerComponent(options: ActionContainerOptions): HTMLElement;
|
|
202
225
|
/**
|
|
203
226
|
* @public
|
|
204
227
|
* Destroys a component of any type created by the SDK. Removes it from the DOM if necessary.
|
|
@@ -251,6 +274,20 @@ export declare class XenditComponents extends EventTarget {
|
|
|
251
274
|
* ```
|
|
252
275
|
*/
|
|
253
276
|
simulatePayment(): void;
|
|
277
|
+
/**
|
|
278
|
+
* @public
|
|
279
|
+
* Request an immediate poll for session status. Useful for handling payment
|
|
280
|
+
* affirmation (e.g. I have made the payment) by the user. The session must still
|
|
281
|
+
* be active.
|
|
282
|
+
*
|
|
283
|
+
* @example
|
|
284
|
+
* ```
|
|
285
|
+
* function onUserAffirmPayment() {
|
|
286
|
+
* components.pollImmediately();
|
|
287
|
+
* }
|
|
288
|
+
* ```
|
|
289
|
+
*/
|
|
290
|
+
pollImmediately(): void;
|
|
254
291
|
/**
|
|
255
292
|
* @public
|
|
256
293
|
* The `init` event lets you know when the session data has been loaded.
|
|
@@ -359,6 +396,18 @@ export declare class XenditComponents extends EventTarget {
|
|
|
359
396
|
* Fallback overload.
|
|
360
397
|
*/
|
|
361
398
|
removeEventListener<K extends keyof XenditEventMap>(type: K, listener: (this: XenditComponents, ev: XenditEventMap[K]) => void, options?: boolean | AddEventListenerOptions): void;
|
|
399
|
+
/**
|
|
400
|
+
* @public
|
|
401
|
+
* Formats a currency value according to the currency's conventions.
|
|
402
|
+
*
|
|
403
|
+
* e.g.
|
|
404
|
+
* ```
|
|
405
|
+
* USD 1000 -> "$1,000"
|
|
406
|
+
* USD 1000.5 -> "$1,000.50"
|
|
407
|
+
* IDR 1000000 -> "Rp1.000.000"
|
|
408
|
+
* PHP 1000 -> "₱1,000.00"
|
|
409
|
+
* ```
|
|
410
|
+
*/
|
|
362
411
|
static amountFormat(amount: number, currency: string): string;
|
|
363
412
|
}
|
|
364
413
|
|