wiki/knowledge/woocommerce/lamarie-payment-logic.md · 551 words · 2026-04-05

LaMarie Payment Logic — Custom PHP & Square APIs

Overview

The La Marie Beauty (LMB) website requires a custom payment flow to handle a mixed cart containing both products and services. Neither WooCommerce nor Bookly supports this split-payment behavior out of the box — a custom PHP solution is required, integrated with Square's APIs for secure card tokenization.

This pattern is relevant to any WordPress/WooCommerce project that needs to differentiate payment behavior by item type at checkout.


The Problem

LMB's cart must support three purchase scenarios simultaneously:

Cart Contents Payment Behavior
Products only Charged in full at checkout
Services only Card held on file; charged post-service or for no-show/cancellation penalties
Mixed (products + services) Products charged immediately; services card-on-file only

Standard WooCommerce checkout treats all items identically. Bookly's payment handling does not natively support card-on-file holds. Neither plugin alone can express this split logic.


The Solution

Custom PHP via WordPress/WooCommerce Hooks

WordPress and WooCommerce expose a hook system that allows custom PHP to intercept and modify checkout behavior. The payment logic is implemented by hooking into these extension points rather than modifying core plugin files.

Why PHP (not JavaScript)?
- WordPress's backend is PHP-based
- WooCommerce hooks are PHP-only
- Backend payment processing must happen server-side for security

JavaScript is used separately for frontend UI (see [1]), but payment logic lives in PHP.

Square API Integration

Rather than building fully custom card storage, the solution leverages Square's existing APIs for:

Isahaque (PHP developer) confirmed he can create the Square API key directly and implement this integration.


Architecture Summary

Customer Checkout
      │
      ├─ Product in cart? ──► WooCommerce standard charge (full amount, immediate)
      │
      └─ Service in cart? ──► Custom PHP hook
                                    │
                                    └─ Square API: tokenize card, store on file
                                          │
                                          ├─ No-show/cancellation: charge penalty
                                          └─ Post-service: charge full service amount

Key Decisions


Action Items (from source meeting)


Sources

  1. Dynamic Product Pages
  2. Index
  3. Bookly Ui Customization
  4. Square Bookly Sync