sbcwallet 0.0.3 → 0.0.4
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 +51 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ import { createBusiness, createLoyaltyProgram } from 'sbcwallet'
|
|
|
22
22
|
|
|
23
23
|
const biz = createBusiness({
|
|
24
24
|
name: 'X Cafe',
|
|
25
|
-
programName: '
|
|
25
|
+
programName: 'x Rewards',
|
|
26
26
|
pointsLabel: 'Points',
|
|
27
27
|
wallet: {
|
|
28
28
|
googleWallet: {
|
|
@@ -42,7 +42,7 @@ const biz = createBusiness({
|
|
|
42
42
|
|
|
43
43
|
// Advanced passthrough: merged into the Apple pass.json payload
|
|
44
44
|
passOverrides: {
|
|
45
|
-
userInfo: { tenant: '
|
|
45
|
+
userInfo: { tenant: 'x' }
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
}
|
|
@@ -100,6 +100,23 @@ const { saveUrl } = await getGoogleObject('child', card)
|
|
|
100
100
|
console.log(saveUrl)
|
|
101
101
|
```
|
|
102
102
|
|
|
103
|
+
### Apple Wallet: generate a signed .pkpass
|
|
104
|
+
|
|
105
|
+
Apple Wallet issuance produces a `.pkpass` file that you deliver to the user (download link, email attachment, in-app webview, etc.).
|
|
106
|
+
|
|
107
|
+
```ts
|
|
108
|
+
import { getPkpassBuffer } from 'sbcwallet'
|
|
109
|
+
import { writeFile } from 'node:fs/promises'
|
|
110
|
+
|
|
111
|
+
const pkpass = await getPkpassBuffer('child', card)
|
|
112
|
+
await writeFile('loyalty.pkpass', pkpass)
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Notes:
|
|
116
|
+
- Apple Wallet passes must be **signed**. Configure the Apple certificate paths/password via environment variables (see Configuration).
|
|
117
|
+
- Multi-tenant branding is controlled via `wallet.appleWallet` (for the business) plus optional per-card overrides in `metadata.appleWallet`.
|
|
118
|
+
- Location surfacing on iOS is controlled by **PassKit fields** (for example `locations` and `relevantText`). This SDK wires these via `createLoyaltyProgram({ locations, relevantText })` and/or `wallet.appleWallet.passOverrides`.
|
|
119
|
+
|
|
103
120
|
## Location-based surfacing and notifications
|
|
104
121
|
|
|
105
122
|
This SDK supports two related concepts:
|
|
@@ -111,6 +128,11 @@ This SDK supports two related concepts:
|
|
|
111
128
|
2) Push-style notifications (server required)
|
|
112
129
|
- Google Wallet supports sending a message via the `addMessage` API. Your system decides *when* to send the message (for example, after your app detects the user is near the business).
|
|
113
130
|
|
|
131
|
+
Apple Wallet clarification:
|
|
132
|
+
- Apple Wallet does not provide a “send arbitrary push message to the pass” API like Google’s `addMessage`.
|
|
133
|
+
- Apple Wallet pass updates are typically done through the PassKit Web Service (`webServiceURL` + `authenticationToken`) plus APNs.
|
|
134
|
+
- This SDK supports those fields via `appleWallet.passOverrides`, but you must implement the web service and APNs delivery yourself.
|
|
135
|
+
|
|
114
136
|
```ts
|
|
115
137
|
import { pushLoyaltyMessage } from 'sbcwallet'
|
|
116
138
|
|
|
@@ -122,6 +144,27 @@ await pushLoyaltyMessage({
|
|
|
122
144
|
})
|
|
123
145
|
```
|
|
124
146
|
|
|
147
|
+
Apple Wallet example (advanced passthrough):
|
|
148
|
+
|
|
149
|
+
```ts
|
|
150
|
+
import { createBusiness } from 'sbcwallet'
|
|
151
|
+
|
|
152
|
+
createBusiness({
|
|
153
|
+
name: 'X Cafe',
|
|
154
|
+
wallet: {
|
|
155
|
+
appleWallet: {
|
|
156
|
+
// Any valid pass.json keys can be provided via passOverrides
|
|
157
|
+
passOverrides: {
|
|
158
|
+
webServiceURL: 'https://api.example.com/passes',
|
|
159
|
+
authenticationToken: 'your-secret-token',
|
|
160
|
+
// Optional: iOS lock-screen surfacing
|
|
161
|
+
relevantText: 'Welcome back — show this card at checkout'
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
})
|
|
166
|
+
```
|
|
167
|
+
|
|
125
168
|
## Demo server (multi-tenant)
|
|
126
169
|
|
|
127
170
|
```sh
|
|
@@ -136,7 +179,12 @@ For Google Wallet Save URLs to work on-device you must set:
|
|
|
136
179
|
- `GOOGLE_ISSUER_ID`
|
|
137
180
|
- `GOOGLE_SA_JSON`
|
|
138
181
|
|
|
139
|
-
For Apple Wallet signing
|
|
182
|
+
For Apple Wallet signing you must set (see APPLE_WALLET_SETUP.md for details):
|
|
183
|
+
- `APPLE_TEAM_ID`
|
|
184
|
+
- `APPLE_PASS_TYPE_ID`
|
|
185
|
+
- `APPLE_CERT_PATH`
|
|
186
|
+
- `APPLE_CERT_PASSWORD`
|
|
187
|
+
- `APPLE_WWDR_PATH`
|
|
140
188
|
|
|
141
189
|
## Development
|
|
142
190
|
|