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:
- Tokenization — Card details are never handled directly; Square issues a secure token
- Customer profiles — Square already maintains customer records (enabling auto-fill on the booking form); the custom code reuses these profiles rather than duplicating them
- Card-on-file — Square supports holding a card without charging it, then charging later — exactly the no-show/post-service pattern needed
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
- Custom PHP is required — no existing plugin combination handles this split-payment logic
- Square APIs must be used for tokenization to maintain security and preserve existing customer profile integration
- PHP is the correct language for this backend work due to WordPress/WooCommerce hook architecture
- Isahaque is the assigned developer; he confirmed the approach is feasible and has not yet started as of the meeting date
Action Items (from source meeting)
- [ ] Isahaque: Create Square API key for the Bookly/WooCommerce/Square integration
- [ ] Isahaque: Implement PHP for service hold/charge logic using Square APIs; notify Kimberly and Melissa if blockers arise
- [ ] Kimberly: Monitor implementation; available to review given JavaScript background, though PHP is required here
Related
- [2] — Client overview
- [3] — Bookly widget redesign (blocked on Lisa design approval)
- [1] — Custom JS on variation pages (separate maintenance concern)
- [4] — Real-time booking sync preventing double-bookings