---
title: LaMarie Payment Logic — Custom PHP & Square APIs
type: article
created: '2026-04-05'
updated: '2026-04-05'
source_docs:
- raw/2025-11-18-la-marie-beauty-project-call-102534050.md
tags:
- woocommerce
- square
- php
- payments
- bookly
- la-marie-beauty
- card-on-file
- booking-system
layer: 2
client_source: null
industry_context: null
transferable: true
---

# 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 [[wiki/clients/la-marie-beauty/dynamic-product-pages]]), 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

- [[wiki/clients/la-marie-beauty/index]] — Client overview
- [[wiki/clients/la-marie-beauty/bookly-ui-customization]] — Bookly widget redesign (blocked on Lisa design approval)
- [[wiki/clients/la-marie-beauty/dynamic-product-pages]] — Custom JS on variation pages (separate maintenance concern)
- [[wiki/knowledge/woocommerce/square-bookly-sync]] — Real-time booking sync preventing double-bookings