Add the client plugin
ImportrazorpayClient from the client entry point and pass it to createAuthClient. Set subscription: true when your server has subscriptions enabled so the client registers subscription methods.
client.ts
razorpayClient is also exported as razorpayClientPlugin. The plugin id is "razorpay-client".
How endpoints map to client methods
Better Auth converts endpoint paths to camelCase methods onauthClient. Here are common examples:
POST vs GET calls
POST calls pass the body object directly:query object:
Response shape and error handling
Every client call returns{ data, error } following the Better Auth convention. On success, data contains the endpoint response. On failure, error includes error.code and error.message.
RAZORPAY_ERROR_CODES so you can compare against known codes:
Calling endpoints from the server
On the server, useauth.api.<name> with the request headers so Better Auth can resolve the session. Pass body for POST endpoints or query for GET endpoints.
POST /razorpay/create-order is auth.api.createRazorpayOrder, and GET /razorpay/order is auth.api.getRazorpayOrder.