Base URL

http://localhost:8000/api/payment

Create Razorpay Order

POST /razorpay/create-order Vendor JWT Required

Description

Creates a Razorpay order for selected subscription plan.

Headers

Authorization: Bearer <vendor_token> Content-Type: application/json

Request Body

{ "plan_id": "planObjectId", "amount": 999 }

Success Response (201)

{ "success": true, "message": "Order created successfully", "data": { "order": { "_id": "paymentId", "amount": 999, "status": "CREATED" }, "key_id": "razorpay_key", "amount": 99900, "currency": "INR", "order_id": "razorpay_order_id" } }

Error Responses

401 Plan not found or invalid amount 500 Error creating order

Verify Payment

POST /razorpay/verify-payment Vendor JWT Required

Description

Verifies Razorpay payment signature, updates payment status, and activates vendor subscription upon successful verification.

Headers

Authorization: Bearer <vendor_token>
Content-Type: application/json

Request Body

{ "razorpay_order_id": "order_id", "razorpay_payment_id": "payment_id", "razorpay_signature": "signature" }

Success Responses

200 - Payment Already Verified
{ "success": true, "message": "Payment already verified", "data": { "_id": "paymentId", "status": "SUCCESS", "razorpayPaymentId": "payment_id" } }
200 - Payment Verified & Subscription Activated
{ "success": true, "message": "Payment verified and subscription activated", "data": { "payment": { "_id": "paymentId", "status": "SUCCESS", "razorpayPaymentId": "payment_id" }, "subscription": subscription_id } }

Error Responses

404 - Order not found
400 - Invalid payment signature
400 - Error while creating subscription
500 - Server error

Activate PAYG Plan

POST /payg/activate Vendor JWT Required

Description

Activate Pay-As-You-Go plan without online payment.

Headers

Authorization: Bearer <vendor_token> Content-Type: application/json

Request Body

{ "plan_id": "planObjectId" }

Success Response

{ "success": true, "message": "PAYG subscription activated", "data": { "_id": "subscriptionId", "status": "ACTIVE", "pricingSnapshot": { "employeeLimit": 10, "type": "PAYG" } } }

Error Responses

400 Invalid PAYG plan 401 Unauthorized 500 Server error