wiki/knowledge/woocommerce/payment-tokenization-woocommerce.md · 716 words · 2025-11-11

Payment Tokenization in WooCommerce

Overview

When building a unified WooCommerce checkout that handles both product purchases and service bookings, a key requirement is the ability to capture a credit card at checkout without immediately charging it — and then charge that card later (e.g., at time of service, or if a no-show fee applies). This is distinct from simply processing a zero-dollar transaction.

This pattern is sometimes called payment tokenization: storing a card reference (token) that can be used for future charges, without storing raw card data.

The Problem

WooCommerce itself does not natively store credit card details for future charges. It delegates payment processing entirely to third-party gateways (Stripe, Square, etc.). The challenge is that:

  1. The gateway (e.g., Square) has the tokenization infrastructure and bank relationships.
  2. WooCommerce's checkout UI does not expose a "save card for later" option by default.
  3. Simply setting the order subtotal to zero (to allow a free booking reservation) does not capture a card token — it just processes a $0 transaction.

This distinction surfaced during the [1] project, where engineer Ishak built a unified checkout that correctly shows the service price but sets the subtotal to zero, allowing product payment while reserving the service slot. However, the ability to re-charge that card later remained unresolved.

"The actual saving of the credit card through WooCommerce, where we use some sort of tokenization, where we then are able to recharge that card — I'm not sure that we've found that solution yet."
— Chris Østergaard, 2025-11-11 call

Investigation Paths

1. Native WooCommerce Plugin Feature

Some WooCommerce payment gateway plugins (particularly the official WooCommerce Square plugin) include built-in tokenization support. This may surface as a "Save card for future use" checkbox in the checkout form. The key questions to verify:

2. Custom Hook / Code Solution

If native plugin support is insufficient, a custom hook may be required. WooCommerce provides action and filter hooks throughout the checkout and order lifecycle. Relevant hooks to investigate:

This approach requires more development effort but gives full control over when and how the card is stored.

3. Square Cards API (Direct Integration)

Square has a dedicated Cards API for storing cards on file. If WooCommerce's gateway plugin does not expose tokenization natively, a custom integration could:

  1. Collect card details via Square's Web Payments SDK at checkout.
  2. Store the card on file via the Cards API.
  3. Return a card_id to be associated with the WooCommerce order or customer record.
  4. Use that card_id for future charges via the Payments API.

This is the most robust path but requires the most custom development.

Open Questions (as of 2025-11-11)

Owner: Ishak (engineer) — investigating as of the 2025-11-11 call. Results to be presented at the following week's meeting.

This question arose in the context of a broader architecture where:

See [2] for the full system design.

The tokenization requirement exists because La Marie Beauty needs to hold a card on file for potential no-show charges — a common pattern in appointment-based businesses.

Sources

  1. Index|La Marie Beauty
  2. Bookly Woocommerce Square Architecture|Bookly + Woocommerce + Square Architecture
  3. Bookly Square Api Sync|Bookly To Square Api Sync And Double Booking Risk
  4. Index|La Marie Beauty — Client Index
  5. 2025 11 11 La Marie Beauty Project Call|La Marie Beauty Project Call — 2025 11 11