Skip to content

Missing transaction field in RiskPayload type #188

@rfpaiva

Description

@rfpaiva

According to the official API Reference documentation from Castle https://reference.castle.io/#operation/risk the payload for the POST /risk endpoint includes an optional transaction field.

However, in the TypeScript definitions provided by the SDK (specifically the RiskPayload type), the transaction field is missing.

Problem:
When attempting to include transaction in a call to castle.risk(...), TypeScript raises a type error because the field is not defined in RiskPayload.

Expected behavior:
The RiskPayload type should include the optional transaction field, consistent with the API documentation.

Example:

const result = await castle.risk({
        request_token: req.headers['X-Castle-Request-Token'] as string,
        context: ContextPrepareService.call(req, { context: { ip: req.ip } }, castle.configuration),
        type: '$transaction',
        status: '$attempted',
        user: {
          id: req.body["id"]
        },
        transaction: {
          id: "123",
          type: "$transfer",
          base_amount: req.body.amount,
          ...
        }
 });

TypeScript error:
Object literal may only specify known properties, and 'transaction' does not exist in type 'RiskPayload'.

Suggested fix:
Update the RiskPayload type definition to include:
transaction?: { id?: string; type?: string; base_amount?: string; // other fields as per API docs };

SDK version: 2.3.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions