better-auth-streampay 0.1.3 → 0.1.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 +10 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -121,12 +121,21 @@ npx prisma migrate dev # Prisma
|
|
|
121
121
|
| Option | Type | Description |
|
|
122
122
|
| ------------------------- | ---------- | ------------------------------------------------------------------ |
|
|
123
123
|
| `createConsumerOnSignUp` | `boolean` | Automatically create a StreamPay consumer when a user signs up |
|
|
124
|
+
| `claimExistingConsumerBy` | `"email" \| "phone" \| "both" \| null` | Reclaim a duplicate linked consumer by the selected identifier(s) |
|
|
124
125
|
| `getConsumerCreateParams` | `function` | Provide additional consumer fields (phone, language, IBAN, etc.) |
|
|
125
126
|
|
|
126
127
|
### Consumers
|
|
127
128
|
|
|
128
129
|
When `createConsumerOnSignUp` is enabled, a new StreamPay Consumer is automatically created when a new user signs up. All consumers are created with an `external_id` matching the user's database ID — no mapping table needed. The resulting consumer ID is stored as `streampayConsumerId` on the user row.
|
|
129
130
|
|
|
131
|
+
If StreamPay rejects sign-up with `DUPLICATE_CONSUMER`, the plugin normally reuses only stranded consumers whose `external_id` is empty. If you set `claimExistingConsumerBy`, the plugin can also reuse an existing consumer that matches the selected identifier even if it is already linked to a different `external_id`. The `after` hook then rewrites that `external_id` to the new Better Auth user id.
|
|
132
|
+
|
|
133
|
+
Claim modes:
|
|
134
|
+
- `null` / `undefined` — only reuse stranded consumers
|
|
135
|
+
- `"email"` — reclaim duplicates that match the same email
|
|
136
|
+
- `"phone"` — reclaim duplicates that match the same phone number
|
|
137
|
+
- `"both"` — reclaim duplicates that match either email or phone
|
|
138
|
+
|
|
130
139
|
Consumer data is also kept in sync:
|
|
131
140
|
- **User update** — name/email changes are synced to StreamPay
|
|
132
141
|
- **User delete** — the StreamPay consumer is deleted
|
|
@@ -137,6 +146,7 @@ Consumer data is also kept in sync:
|
|
|
137
146
|
streampay({
|
|
138
147
|
client: streamPayClient,
|
|
139
148
|
createConsumerOnSignUp: true,
|
|
149
|
+
claimExistingConsumerBy: "both",
|
|
140
150
|
getConsumerCreateParams: async ({ user }, request) => ({
|
|
141
151
|
phone_number: "+966501234567",
|
|
142
152
|
preferred_language: "ar",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "better-auth-streampay",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Community Better Auth plugin for StreamPay — consumers, checkout, portal, subscriptions, and signed webhooks. Not affiliated with Stream.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|