# Stripe payment integration — CleaningBusinessSoftware v2.1

Adds Stripe as a payment gateway for enquiry (booking) payments, alongside the
existing PayPal and Authorize.net gateways. It follows this app's own conventions:
the Stripe Checkout mechanics come from the CinemaBooking reference (same booking
framework and the same `Yes|No` option format this app already uses), while the
wiring mirrors how PayPal is integrated here (o_allow_* method gating, per-gateway
confirm handler, enquiry + enquiries_payments tracking). The only behavioural
difference from PayPal is that Stripe Checkout is a hosted redirect.

## What was added

New plugin — `app/plugins/pjStripe/` (PLUGIN_ID 303)
- `config/database.sql` — creates `plugin_stripe`, adds `stripe` to the
  `enquiries` and `enquiries_payments` payment_method enums, and seeds the Stripe
  options (o_allow_stripe / o_stripe_public_key / o_stripe_private_key, tab 2, in
  the app's own Yes|No enum format) + the payment-method label + redirect message
- `controllers/pjStripe.controller.php` + `components/pjStripeSDK*` — Stripe
  Checkout over the framework `pjHttp`
- `models/pjStripe.model.php`, `views/pjStripe/pjActionForm.php`

Wiring into the app (additions only, no lines removed)
- `app/config/options.inc.php` — `pjStripe` added to `$CONFIG['plugins']`
- `app/controllers/pjFront.controller.php` — `case 'stripe'` builds the payment
  params (mirrors the paypal/authorize cases) + `pjActionConfirmStripe()`, the
  Stripe return handler (mirrors `pjActionConfirmPaypal`, reuses the same
  enquiry-status + enquiries_payments-paid + email logic)
- `app/views/pjFront/pjActionGetPaymentForm.php` — `case 'stripe'` renders the form
- `app/views/pjAdminOptions/pjActionEnquiry.php` — Stripe key rows grouped under
  the Allow-Stripe toggle (mirrors the PayPal group)
- `app/web/js/pjAdminOptions.js` — show/hide the Stripe key rows on toggle

## Install

1. Deploy this project (or copy it over your existing v2.1 tree).
2. Run the plugin SQL (prefix-less, like pjPaypal; the `cbs_` prefix is applied on
   install — add it by hand if running raw SQL):
   - `app/plugins/pjStripe/config/database.sql`
3. Add `'pjStripe'` to the plugins array in your `app/config/config.inc.php` and
   `app/config/config.sample.php` (the internal defaults in `options.inc.php` are
   already updated here).
4. Admin → Options → Payments: set **Allow Stripe payments = Yes** and enter your
   Publishable and Secret keys.

## Flow

At checkout the customer picks **Stripe** (shown because `o_allow_stripe` is Yes).
The Stripe form creates a Checkout Session and redirects to Stripe; on return,
`pjFront::pjActionConfirmStripe` verifies the paid session via the plugin, marks the
enquiry (status = `o_payment_status`, stores `txn_id`) and its online payment row
`paid`, sends the confirmation email, and redirects to the thank-you page — exactly
like the PayPal path.

## Notes

- All Stripe calls use the framework `pjHttp`; no third-party SDK is bundled.
- SQL couldn't be executed here (no database); it mirrors the CinemaBooking
  reference and this app's pjPaypal plugin — run it against staging first.
- Test vs live is determined by the key prefix; there's no separate toggle.
