cd2c1c6d08
CI / test (push) Successful in 10m27s
- Added return request handling in return.controller.js - Implemented webhook handling for PayHere payments in webhook.controller.js - Created models for coupon redemptions, invoices, orders, order items, payments, payment attempts, payment webhook events, refunds, return items, and return requests. - Developed services for order management, payment processing, refunds, and returns. - Introduced validation schemas for payment and return requests. - Created migration scripts for new database tables related to orders, payments, refunds, and returns. - Added unit tests for order state transitions and PayHere provider functionality.
2 lines
1023 B
JavaScript
2 lines
1023 B
JavaScript
const{z}=require("zod"),wrap=body=>z.object({body:body.strict(),params:z.object({}).passthrough(),query:z.object({}).passthrough()}),id=z.string().min(1).max(160);exports.fromCheckout=wrap(z.object({checkoutId:id}));exports.payment=wrap(z.object({provider:z.enum(["PAYHERE"]).default("PAYHERE"),method:z.string().min(1).max(50).default("ONLINE")}));exports.returnRequest=wrap(z.object({reasonCode:z.string().min(1).max(80),reasonText:z.string().max(500).optional(),items:z.array(z.object({orderItemId:id,quantity:z.number().int().positive(),resolution:z.enum(["REFUND","EXCHANGE"])}).strict()).min(1)}));exports.refund=wrap(z.object({paymentId:id,reasonCode:z.string().min(1).max(80),reasonText:z.string().max(500).optional(),items:z.array(z.object({orderItemId:id,quantity:z.number().int().positive()}).strict()).min(1)}));exports.returnComplete=wrap(z.object({conditions:z.array(z.object({returnItemId:id,condition:z.enum(["RESTOCKABLE","DAMAGED","NON_RESTOCKABLE"]),warehouseId:id.optional()}).strict()).default([])}));
|