Skip to content

Commit 6dea6b2

Browse files
fix(enrichment): only bill Enrow verify on a completed verification
getCost returned a flat 0.25 credits regardless of output, so a job that fell back to the initial submit response (poll never completed, no qualification) was still metered. Charge 0.25 only when a qualification is present; 0 otherwise. Add a no-qualification test case. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent e1ef8ef commit 6dea6b2

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

apps/sim/tools/enrow-hosting.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,19 @@ describe('Enrow find_email pricing', () => {
5252
})
5353

5454
describe('Enrow verify_email pricing', () => {
55-
it('charges 0.25 credits per verification regardless of result', () => {
55+
it('charges 0.25 credits for a completed verification (valid or invalid)', () => {
5656
expect(cost(enrowVerifyEmailTool, {}, { qualification: 'valid' }).cost).toBeCloseTo(
5757
0.25 * ENROW_CREDIT_USD
5858
)
5959
expect(cost(enrowVerifyEmailTool, {}, { qualification: 'invalid' }).cost).toBeCloseTo(
6060
0.25 * ENROW_CREDIT_USD
6161
)
6262
})
63+
64+
it('charges 0 credits when the job did not complete (no qualification)', () => {
65+
expect(cost(enrowVerifyEmailTool, {}, { qualification: null }).cost).toBe(0)
66+
expect(cost(enrowVerifyEmailTool, {}, {}).cost).toBe(0)
67+
})
6368
})
6469

6570
describe('Enrow find_email postProcess polling', () => {

apps/sim/tools/enrow/verify_email.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,11 @@ export const enrowVerifyEmailTool: ToolConfig<EnrowVerifyEmailParams, EnrowVerif
4242
'Verify the deliverability of an email address using the Enrow async verifier. Submits a verification request and polls until the result is ready. Costs 0.25 credits per verification. (https://enrow.readme.io/reference/verify-single-email)',
4343
version: '1.0.0',
4444

45-
hosting: enrowHosting<EnrowVerifyEmailParams>((_params, _output) => {
46-
// 0.25 credits charged per verification call regardless of result
47-
return 0.25
45+
hosting: enrowHosting<EnrowVerifyEmailParams>((_params, output) => {
46+
// 0.25 credits per completed verification. Bill only when the job resolved
47+
// to a qualification — a fall-back to the initial submit response (poll never
48+
// finished) has no qualification and must not be charged.
49+
return output.qualification ? 0.25 : 0
4850
}),
4951

5052
params: {

0 commit comments

Comments
 (0)