# Stripe payment integration — AutoClassifieds v4.1

Adds Stripe as a payment option for paid listing periods, alongside the existing
PayPal gateway (single surface — a car seller pays to publish/extend a listing).
Mirrors this app's own PayPal listing-payment flow via Stripe Checkout (hosted
redirect).

## What was added
- Plugin `app/plugins/pjStripe/` (PLUGIN_ID 303): `plugin_stripe` table + admin
  transactions grid; Stripe Checkout over the framework `pjHttp`. Seeds the Stripe
  credential options (publishable / secret / cancel) on the Payments tab.
- `app/config/options.inc.php` — `pjStripe` registered
- `app/controllers/pjListings.controller.php` — `pjActionConfirmStripe()` (the
  Stripe return handler; reuses this app's own `pjActionConfirmPayment` logic:
  insert payment, `last_extend='paid'`, extend `expire`)
- `app/controllers/pjAdminListings.controller.php` — `pjActionGetStripeForm()`
  (mirror of `pjActionGetPaymentForm()`)
- `app/views/pjAdminListings/pjActionGetStripeForm.php` — renders the Stripe form
- `app/views/pjAdminListings/pjActionPayment.php` — "Pay with Stripe" button +
  container
- `app/web/js/pjAdminListings.js` — click handler

## 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).
- The Stripe credential fields are placed contiguously on the Payments tab right
  after the Authorize.net block: **publishable key (19) → secret key (20) → cancel
  page (21)**, and the offline methods (cash/credit-card/bank/bank account) shift to
  25–28. So the tab groups the gateways together (PayPal → Authorize → Stripe) then
  the offline toggles.

## Install
1. Deploy this project (or copy over your v4.1 tree).
2. Run `app/plugins/pjStripe/config/database.sql` and the file in
   `app/plugins/pjStripe/config/updates/` (via the installer, per above).
3. Add `'pjStripe'` to the plugins array in your `config.inc.php` / `config.sample.php`.
4. Admin → Options → Payments: enter your Stripe publishable + secret keys.

## Flow
Admin opens a listing's payment page → clicks **Pay with Stripe** for a period → the
Stripe form creates a Checkout Session and redirects to Stripe → on success Stripe
returns to `pjListings::pjActionConfirmStripe`, which verifies the paid session,
records the payment in `carlisting_payments`, and extends the listing's `expire`
date — exactly like the PayPal flow.

## 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.
