Better Payment 0.11.1 API
    Preparing search index...

    Interface BetterPaymentHandlerOptions

    interface BetterPaymentHandlerOptions {
        allowedActions?: HandlerAction[] | "all";
        authorize?: (ctx: HandlerContext) => boolean | Promise<boolean>;
        basePath?: string;
        callbackRedirect?: (
            result: PaymentResponse,
            ctx: CallbackContext,
        ) => string | Promise<string | undefined> | undefined;
        exposeErrors?: boolean;
        exposeRawResponse?: boolean;
        idempotency?: false | HandlerIdempotencyOptions;
        onCallback?: (
            result: PaymentResponse,
            ctx: CallbackContext,
        ) => void | Promise<void>;
        transformRequest?: (
            ctx: HandlerContext,
        ) => object | Promise<object | undefined> | undefined;
    }
    Index
    allowedActions?: HandlerAction[] | "all"

    Actions exposed over HTTP. Default: DEFAULT_HANDLER_ACTIONS. Use 'all' to expose everything (requires authorize).

    authorize?: (ctx: HandlerContext) => boolean | Promise<boolean>

    Called before every action except the health check. Return false (or throw) to reject the request with 403. Required when privileged actions are enabled.

    Provider callbacks (callback, payment/complete-3ds) are signed by the provider and are called by the bank/customer browser, so the hook usually lets them through: if (CALLBACK_HANDLER_ACTIONS.includes(ctx.action)) return true.

    basePath?: string

    Path prefix the handler is mounted on. Default: '/api/pay'

    callbackRedirect?: (
        result: PaymentResponse,
        ctx: CallbackContext,
    ) => string | Promise<string | undefined> | undefined

    For browser callbacks (3D Secure return), return a URL to redirect the customer to (303). When undefined, the result is returned as JSON.

    exposeErrors?: boolean

    Include error messages of unexpected exceptions in 500 responses. Default: false

    exposeRawResponse?: boolean

    Include the provider's rawResponse in responses. It can hold merchant data (commission rates, fraud status) and stored-card keys, so it is left out by default. Your hooks (onCallback, events) always receive it. Default: false

    idempotency?: false | HandlerIdempotencyOptions

    Deduplication of provider callbacks and Idempotency-Key requests. On by default with an in-memory store; pass a shared store (Redis, DB) when running several instances, or false to turn it off.

    onCallback?: (
        result: PaymentResponse,
        ctx: CallbackContext,
    ) => void | Promise<void>

    Called with the verified result of a provider callback. Update your order here. Errors thrown here make the handler return 500 (PayTR will then retry the notification).

    transformRequest?: (
        ctx: HandlerContext,
    ) => object | Promise<object | undefined> | undefined

    Returns the body passed to the provider. Use it to set amounts, basket and buyer on the server instead of trusting the client, e.g. look up the order by id and build the payment request from your database.