# Stripe payment integration — TicketBooking v2.1

Adds Stripe as a booking payment gateway alongside PayPal and Authorize.net, via
Stripe Checkout (hosted redirect). Mirrors this app's own PayPal wiring, which is
invoice-based (pjInvoice): the confirm looks up the invoice by the `custom` value,
then the booking, and marks booking + bookings_payments + invoice all paid.

## What was added
- Plugin `app/plugins/pjStripe/` (PLUGIN_ID 303): `plugin_stripe` table; adds
  `stripe` to `bookings`/`bookings_payments` enums; seeds `o_allow_stripe` +
  `o_stripe_public_key`/`o_stripe_private_key` (tab 2) + method label; Stripe
  Checkout over the framework `pjHttp`.
- `app/config/options.inc.php` — `pjStripe` registered
- `app/controllers/pjFront.controller.php` — `case 'stripe'` param builder (in the
  pjActionComplete switch) + `pjActionConfirmStripe()` return handler (mirrors the
  invoice-based `pjActionConfirmPaypal`)
- `app/views/pjFront/pjActionComplete.php` — `case 'stripe'` renders the form
- `app/views/pjAdminOptions/pjActionBooking.php` — Stripe key rows grouped under
  the Allow-Stripe toggle
- `app/web/js/pjAdminOptions.js` — show/hide toggle

## Migration notes
- Labels use the `::LOCALE::` token, which THIS app's pjInstaller expands (its own
  pjPaypal plugin uses the same token). Install the plugin SQL through the installer
  so the token expands; if running raw SQL by hand, replace `::LOCALE::` with your
  locale id(s).
- Stripe options are placed contiguously on the Payments tab right after the
  Authorize.net block: **Allow Stripe (16) → publishable key (17) → secret key
  (18)**, with the offline methods (cash/credit-card/bank/bank account) shifted to
  21–24. So the tab reads PayPal → Authorize → Stripe → cash/card/bank.

## Install
1. Deploy this project (or copy over your v2.1 tree).
2. Run `app/plugins/pjStripe/config/database.sql` (via the installer, per above).
3. Add `'pjStripe'` to the plugins array in your `config.inc.php` / `config.sample.php`.
4. Admin → Options → Payments: set **Allow Stripe payments = Yes** and enter your keys.

## Flow
Customer picks Stripe at checkout (shown when `o_allow_stripe = Yes`) → redirected to
Stripe Checkout → returns to `pjFront::pjActionConfirmStripe`, which verifies the
session, marks the booking (`o_payment_status`, `txn_id`), the online payment row,
and the invoice all `paid`, sends the confirmation email, and redirects to the
thank-you page.

## Note on EventTicketing
This app shares its codebase with EventTicketing v2.1 (the files touched here are
byte-identical, framework 1.5.5, same schema and tab layout), so the same integration
applies. The two projects differ only in an admin CSRF detail in
`pjAppController.controller.php` and some uploaded assets — neither affects this
front-facing payment wiring.

## Notes
- All Stripe calls use the framework `pjHttp`; no third-party SDK is bundled.
- SQL couldn't be executed here (no database); run it against staging first.
- Test vs live is determined by the key prefix.
