@paygood1/collect-core 0.6.0 → 0.7.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/README.md
CHANGED
|
@@ -8,6 +8,50 @@ Framework-agnostic SDK for collecting and tokenizing payment instruments using a
|
|
|
8
8
|
npm install @paygood1/collect-core
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
+
## Session key bootstrap
|
|
12
|
+
|
|
13
|
+
Before mounting the component, your backend must create a tokenization session key
|
|
14
|
+
in two steps:
|
|
15
|
+
|
|
16
|
+
1. `POST /tokenization/intents` with your merchant API key as bearer auth and a
|
|
17
|
+
`customerId` in the request body.
|
|
18
|
+
2. Use the `token` value returned from step 1 as bearer auth on
|
|
19
|
+
`POST /tokenization/sessions`.
|
|
20
|
+
|
|
21
|
+
The sessions response includes `sessionKey`. Pass that value into
|
|
22
|
+
`createCardCollectCore` as `sessionKey`.
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
// Server-side example
|
|
26
|
+
const intentResponse = await fetch("https://api-sandbox.paygood.co/tokenization/intents", {
|
|
27
|
+
method: "POST",
|
|
28
|
+
headers: {
|
|
29
|
+
Authorization: "Bearer YOUR_MERCHANT_API_KEY",
|
|
30
|
+
"Content-Type": "application/json"
|
|
31
|
+
},
|
|
32
|
+
body: JSON.stringify({ customerId: "cust_123" })
|
|
33
|
+
});
|
|
34
|
+
const { token } = await intentResponse.json();
|
|
35
|
+
|
|
36
|
+
const sessionResponse = await fetch("https://api-sandbox.paygood.co/tokenization/sessions", {
|
|
37
|
+
method: "POST",
|
|
38
|
+
headers: {
|
|
39
|
+
Authorization: `Bearer ${token}`,
|
|
40
|
+
"Content-Type": "application/json"
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
const { sessionKey } = await sessionResponse.json();
|
|
44
|
+
|
|
45
|
+
const core = await createCardCollectCore({
|
|
46
|
+
mode: "sandbox",
|
|
47
|
+
market: "US",
|
|
48
|
+
sessionKey
|
|
49
|
+
});
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Perform both requests server-side. Do not expose your merchant API key in the
|
|
53
|
+
browser.
|
|
54
|
+
|
|
11
55
|
## Usage
|
|
12
56
|
|
|
13
57
|
```ts
|
|
@@ -16,7 +60,8 @@ import { createCardCollectCore } from "@paygood1/collect-core";
|
|
|
16
60
|
const core = await createCardCollectCore(
|
|
17
61
|
{
|
|
18
62
|
mode: "sandbox",
|
|
19
|
-
market: "US"
|
|
63
|
+
market: "US",
|
|
64
|
+
sessionKey
|
|
20
65
|
},
|
|
21
66
|
{
|
|
22
67
|
onReady: () => console.log("ready"),
|
|
@@ -43,10 +88,3 @@ interface TokenizationResult {
|
|
|
43
88
|
```
|
|
44
89
|
|
|
45
90
|
`instrument` is an optional field you can pass in the `createCardCollectCore` init config object; it defaults to `"card"` when omitted.
|
|
46
|
-
|
|
47
|
-
`mode` controls the internal whitelabel URL:
|
|
48
|
-
- `sandbox` -> `https://elements-dev.paygood.co/`
|
|
49
|
-
- `production` -> `https://elements.paygood.com`
|
|
50
|
-
|
|
51
|
-
Set `useStockDomain: true` to omit the PayGood whitelabel domain and use Basis Theory's
|
|
52
|
-
default Elements origin (`https://js.basistheory.com`) instead.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/internal/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAiBxE,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,eAAe,GAAG,MAAM,CAEjE;AAED,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,eAAe,EACrB,cAAc,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/internal/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAiBxE,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,eAAe,GAAG,MAAM,CAEjE;AAED,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,eAAe,EACrB,cAAc,UAAO,GACpB,MAAM,GAAG,SAAS,CAMpB;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,eAAe,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAU1F;AAED,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,eAAe,GAAG,sBAAsB,CAE1F"}
|
package/dist/internal/config.js
CHANGED
|
@@ -3,7 +3,7 @@ const WHITELABEL_DOMAINS = {
|
|
|
3
3
|
production: "https://elements.paygood.com"
|
|
4
4
|
};
|
|
5
5
|
const TOKENIZATION_API_BASE_URLS = {
|
|
6
|
-
sandbox: "https://
|
|
6
|
+
sandbox: "https://api-sandbox.paygood.co",
|
|
7
7
|
production: ""
|
|
8
8
|
};
|
|
9
9
|
const MODE_DEFAULT_ENVIRONMENT = {
|
|
@@ -13,7 +13,7 @@ const MODE_DEFAULT_ENVIRONMENT = {
|
|
|
13
13
|
export function getWhitelabelDomain(mode) {
|
|
14
14
|
return WHITELABEL_DOMAINS[mode];
|
|
15
15
|
}
|
|
16
|
-
export function resolveCustomDomain(mode, useStockDomain) {
|
|
16
|
+
export function resolveCustomDomain(mode, useStockDomain = true) {
|
|
17
17
|
if (useStockDomain) {
|
|
18
18
|
return undefined;
|
|
19
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/internal/config.ts"],"names":[],"mappings":"AAEA,MAAM,kBAAkB,GAAoC;IAC1D,OAAO,EAAE,kCAAkC;IAC3C,UAAU,EAAE,8BAA8B;CAC3C,CAAC;AAEF,MAAM,0BAA0B,GAAoC;IAClE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/internal/config.ts"],"names":[],"mappings":"AAEA,MAAM,kBAAkB,GAAoC;IAC1D,OAAO,EAAE,kCAAkC;IAC3C,UAAU,EAAE,8BAA8B;CAC3C,CAAC;AAEF,MAAM,0BAA0B,GAAoC;IAClE,OAAO,EAAE,gCAAgC;IACzC,UAAU,EAAE,EAAE;CACf,CAAC;AAEF,MAAM,wBAAwB,GAAoD;IAChF,OAAO,EAAE,MAAM;IACf,UAAU,EAAE,IAAI;CACjB,CAAC;AAEF,MAAM,UAAU,mBAAmB,CAAC,IAAqB;IACvD,OAAO,kBAAkB,CAAC,IAAI,CAAC,CAAC;AAClC,CAAC;AAED,MAAM,UAAU,mBAAmB,CACjC,IAAqB,EACrB,cAAc,GAAG,IAAI;IAErB,IAAI,cAAc,EAAE,CAAC;QACnB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,kBAAkB,CAAC,IAAI,CAAC,CAAC;AAClC,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,IAAqB,EAAE,QAAiB;IAChF,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;IACzB,CAAC;IAED,MAAM,OAAO,GAAG,0BAA0B,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;IACxD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,yCAAyC,IAAI,QAAQ,CAAC,CAAC;IACzE,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,4BAA4B,CAAC,IAAqB;IAChE,OAAO,wBAAwB,CAAC,IAAI,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -7,7 +7,7 @@ const configSchema = z.object({
|
|
|
7
7
|
debug: z.boolean().optional(),
|
|
8
8
|
tokenizationApiBaseUrl: z.string().optional(),
|
|
9
9
|
sessionKey: z.string().trim().min(1).optional(),
|
|
10
|
-
useStockDomain: z.boolean().default(
|
|
10
|
+
useStockDomain: z.boolean().default(true)
|
|
11
11
|
});
|
|
12
12
|
export function validateConfig(input) {
|
|
13
13
|
return configSchema.parse(input);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/validation/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5B,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC;IAC1D,WAAW,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC;IACzD,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC5B,UAAU,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC;IAC5D,KAAK,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAC7B,sBAAsB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC7C,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IAC/C,cAAc,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/validation/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5B,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC;IAC1D,WAAW,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC;IACzD,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC5B,UAAU,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC;IAC5D,KAAK,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAC7B,sBAAsB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC7C,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IAC/C,cAAc,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;CAC1C,CAAC,CAAC;AAEH,MAAM,UAAU,cAAc,CAAC,KAAwB;IACrD,OAAO,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AACnC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paygood1/collect-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Pure card collection module for PayGood",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -23,10 +23,11 @@
|
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@basis-theory/web-elements": "2.15.0",
|
|
26
|
+
"vite": "8.2.2",
|
|
26
27
|
"zod": "^3.23.8"
|
|
27
28
|
},
|
|
28
29
|
"devDependencies": {
|
|
29
30
|
"typescript": "^5.6.2",
|
|
30
|
-
"vitest": "^
|
|
31
|
+
"vitest": "^4.1.11"
|
|
31
32
|
}
|
|
32
33
|
}
|