@paygood1/collect-core 0.6.0 → 0.6.1
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 +46 -1
- package/package.json +1 -1
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-staging.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-staging.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"),
|