# Stripe payment integration — JobManager v4.1

Adds Stripe as a payment gateway for paid job-listing periods, alongside the
existing PayPal gateway. It mirrors this app's own PayPal integration: same plugin
layout, model style, dated migration, admin transactions grid, and the same
job-extension logic. The only behavioural difference from PayPal is that Stripe
Checkout is a hosted redirect rather than an in-page button.

## What was added

New plugin — `app/plugins/pjStripe/` (PLUGIN_ID 303, mirrors pjPaypal)
- `config/database.sql` — creates `plugin_stripe` + registers its field labels
- `config/updates/update_2026_07_06_10_00_00.sql` — Stripe options on the Payments
  tab (o_stripe_public_key / o_stripe_secret_key / o_stripe_cancel_url) + labels
- `controllers/pjStripe.controller.php` — createOrder / confirm / save / form +
  admin transactions grid (index / getStripe / getDetails)
- `models/pjStripe.model.php`, `views/pjStripe/*`, `web/js/pjStripe.js`

Wiring into the app (additions only, no lines removed)
- `app/config/options.inc.php` — `pjStripe` added to `$CONFIG['plugins']`
- `app/controllers/pjLoad.controller.php` — `pjActionConfirmStripe()` (the Stripe
  return handler; reuses the exact payment-insert + job-extend logic of
  `pjActionConfirmPayment`)
- `app/controllers/pjAdminJobs.controller.php` — `pjActionGetStripeForm()` (mirror
  of `pjActionGetPaymentForm()`)
- `app/views/pjAdminJobs/pjActionGetStripeForm.php` — renders the Stripe form
- `app/views/pjAdminJobs/pjActionPayment.php` — "Pay with Stripe" button + container
- `app/web/js/pjAdminJobs.js` — click handler that loads the Stripe form

## Install

1. Deploy this project (or copy it over your existing v4.1 tree).
2. Run the plugin SQL (prefix-less, like pjPaypal; the `joblisting_` prefix is
   applied on install):
   - `app/plugins/pjStripe/config/database.sql`
   - `app/plugins/pjStripe/config/updates/update_2026_07_06_10_00_00.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: enter your Stripe Publishable key and Secret key.

## Flow

Admin → a job's Extend page → **Pay with Stripe** for a paid period → the browser
loads the Stripe form, which creates a Checkout Session and redirects to Stripe.
On success Stripe returns to `pjLoad::pjActionConfirmStripe`, which verifies the
paid session, records the payment in `joblisting_payments`, and extends the job's
`expired` date — exactly as the PayPal flow does.

## Notes

- Amounts convert to Stripe minor units, with zero-decimal currencies handled.
- All Stripe calls use the framework `pjHttp`, the same transport pjPaypal uses.
- SQL couldn't be executed here (no database); it mirrors pjPaypal — run it against
  staging first.
- Test vs live is determined by the key prefix; there's no separate toggle.
