feat: Implement Phase 6 Shopping and Checkout
- Introduced authenticated shopping state and atomic checkout process without creating orders or payments. - Reused existing components from previous phases including identities, addresses, catalogues, pricing, and inventory. - Developed cart architecture to support one active cart per user with unique items per variant. - Implemented dynamic cart pricing with various precedence rules for promotions and coupons. - Created a wishlist feature that exposes only visible active products without reserving inventory. - Integrated inventory validation to ensure availability of items before adding to cart. - Developed a checkout architecture that locks the cart, revalidates pricing and shipping, and reserves inventory. - Added shipping zones, methods, and rates with configurable options for international shipping and duty/tax boundaries. - Implemented checkout snapshots to capture immutable checkout details. - Introduced idempotency for checkout requests to prevent duplicate processing. - Added functionality for coupon integration and business checkout validation. - Established permissions for managing shipping zones, methods, and rates. - Created comprehensive unit tests covering various aspects of the shopping and checkout processes. - Added cron job for handling checkout expiry reconciliation. - Created migration script to set up new database tables and constraints for carts, checkout sessions, and shipping.
This commit is contained in:
@@ -0,0 +1 @@
|
||||
module.exports=(s,D)=>{const M=s.define("CheckoutSession",{id:{type:D.STRING,primaryKey:true},checkout_number:{type:D.STRING(80),allowNull:false,unique:true},user_id:{type:D.STRING,allowNull:false},business_customer_id:D.STRING,cart_id:{type:D.STRING,allowNull:false},cart_version:{type:D.INTEGER,allowNull:false},status:{type:D.ENUM("PENDING","READY","EXPIRED","CANCELLED","CONVERTED"),allowNull:false,defaultValue:"PENDING"},currency:{type:D.STRING(3),allowNull:false},shipping_address_snapshot:{type:D.JSON,allowNull:false},billing_address_snapshot:{type:D.JSON,allowNull:false},shipping_method_id:{type:D.STRING,allowNull:false},shipping_snapshot:{type:D.JSON,allowNull:false},subtotal:{type:D.DECIMAL(15,2),allowNull:false},discount_total:{type:D.DECIMAL(15,2),allowNull:false},shipping_amount:{type:D.DECIMAL(15,2),allowNull:false},tax_amount:{type:D.DECIMAL(15,2),allowNull:false},duty_amount:D.DECIMAL(15,2),grand_total:{type:D.DECIMAL(15,2),allowNull:false},coupon_code:D.STRING(50),idempotency_key:{type:D.STRING(160),allowNull:false},request_fingerprint:{type:D.STRING(64),allowNull:false},expires_at:{type:D.DATE,allowNull:false}},{tableName:"checkout_sessions",timestamps:true,indexes:[{unique:true,fields:["user_id","idempotency_key"]}]});M.associate=db=>M.hasMany(db.CheckoutItem,{foreignKey:"checkout_session_id",as:"items"});return M;};
|
||||
Reference in New Issue
Block a user