@spritz-finance/api-client 0.4.14 → 0.4.16

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
@@ -247,6 +247,9 @@ const verificationStatus = userData.verificationStatus
247
247
  const verificationUrl = userData.verificationUrl
248
248
  const verifiedCountry = userData.verifiedCountry
249
249
  const canRetryVerification = userData.canRetryVerification
250
+
251
+ // Access verification metadata for failed verifications
252
+ const verificationMetadata = userData.verificationMetadata
250
253
  ```
251
254
 
252
255
  #### Method 2: Verification Token (Advanced Integration)
@@ -272,6 +275,44 @@ The verification token method is ideal when you want to:
272
275
 
273
276
  See the [Plaid Link documentation](https://plaid.com/docs/link/) for detailed integration instructions with the verification token.
274
277
 
278
+ ### Verification Metadata (Failed Verifications)
279
+
280
+ When a user's verification fails, Spritz now provides additional metadata to help understand the failure reason and provide better user experience. This metadata is particularly useful for handling duplicate identity scenarios.
281
+
282
+ #### Understanding Verification Metadata
283
+
284
+ The verification metadata is available when a verification has failed and includes:
285
+
286
+ - **`failureReason`**: The specific reason why the verification failed (e.g., `DuplicateIdentity`)
287
+ - **`details.matchedEmail`**: For duplicate identity failures, shows the email of the matched user (only if created through the same integration)
288
+
289
+ #### Duplicate Identity Handling
290
+
291
+ When a verification fails due to `DuplicateIdentity`, the system detects that the user has already been verified under a different account. The `matchedEmail` field helps determine:
292
+
293
+ - **If `matchedEmail` is populated**: The duplicate user was created through your integration
294
+ - **If `matchedEmail` is `null`**: The duplicate user was created through a different integration (e.g., the main Spritz app)
295
+
296
+ This allows you to provide appropriate guidance to your users:
297
+
298
+ ```typescript
299
+ const userData = await client.user.getCurrentUser()
300
+
301
+ if (userData.verificationMetadata?.failureReason === 'DuplicateIdentity') {
302
+ const matchedEmail = userData.verificationMetadata.details.matchedEmail
303
+
304
+ if (matchedEmail) {
305
+ // User exists within your integration
306
+ console.log(`This identity is already verified with account: ${matchedEmail}`)
307
+ // Guide user to use their existing account
308
+ } else {
309
+ // User exists in Spritz but not in your integration
310
+ console.log('This identity is already verified with another Spritz account')
311
+ // Inform user they need to use their original Spritz account
312
+ }
313
+ }
314
+ ```
315
+
275
316
  ## Payment Flow
276
317
 
277
318
  ### Basic payment flow
@@ -1090,6 +1131,26 @@ Upon receiving a webhook, your server will get a payload with the following stru
1090
1131
  }
1091
1132
  ```
1092
1133
 
1134
+ ### Managing webhooks
1135
+
1136
+ #### List all webhooks
1137
+
1138
+ To retrieve all webhooks configured for your integration:
1139
+
1140
+ ```typescript
1141
+ const webhooks = await client.webhook.list()
1142
+ // Returns an array of webhook configurations
1143
+ ```
1144
+
1145
+ #### Delete a webhook
1146
+
1147
+ To delete a specific webhook by its ID:
1148
+
1149
+ ```typescript
1150
+ const deletedWebhook = await client.webhook.delete('webhook-id-here')
1151
+ // Returns the deleted webhook object
1152
+ ```
1153
+
1093
1154
  ### Webhook security and signing
1094
1155
 
1095
1156
  Each webhook request is signed using an HMAC SHA256 signature, based on the exact JSON payload sent in the body. This signature is included in the Signature HTTP header of the request.