Skip to content

Developer notes

Item Value
Add-on id kv_stripe_payments (scheme 3.0, priority 1000), CS-Cart / CS-Cart Ultimate / Multi-Vendor / Multi-Vendor Ultimate 4.17.2 to 4.22.x, PHP 7.4 to 8.3
Processor “Stripe (Payment Element: cards, wallets, local methods)”, script app/addons/kv_stripe_payments/payments/kv_stripe_payments.php (start -> pay page; payment_notification.return / .cancel)
Storefront kv_stripe_payments.pay (GET, pay key = HMAC of order id + placement time + e-mail with a key derived from the store crypt key; Cache-Control: no-store), kv_stripe_payments.verify (POST JSON, CSRF hash, attempt key), kv_stripe_payments.webhook (POST raw body, c=<account>), kv_stripe_payments.cron (secret key)
Credentials ?:kv_stripe_payments_accounts: per company (0 = owner, vendor id in vendor mode) and mode: publishable key, restricted key and webhook signing secret (the last two sealed with AES-256-GCM, Secret)
Tables kv_stripe_payments_transactions (one row per PaymentIntent), kv_stripe_payments_ops (captures, cancels, refunds), kv_stripe_payments_hooks (event ids), kv_stripe_payments_log, kv_stripe_payments_jobs, kv_stripe_payments_accounts; transactions, ops and jobs are kept on uninstall (retention.json)
Hooks change_order_status_post (capture / cancel / refund at status), prepare_checkout_payment_methods (hide when unusable), init_templater_post (Upgrade Synchronizer while pending)
Server API Stripe REST API v1 over cURL, no SDK bundled (Tygh\Addons\KvStripePayments\Client\Api), pinned Stripe-Version: 2026-10-28.endive
Client Stripe.js https://js.stripe.com/endive/stripe.js (loaded by js/addons/kv_stripe_payments/pay.js), Payment Element
Test hook $config['kv_stripe_payments_base_url'] in config.local.php (loopback hosts only) points the client and Stripe.js at the mock
  • https://docs.stripe.com/api/versioning : “The current version is 2026-10-28.endive.”
  • https://docs.stripe.com/changelog : newest GA versions 2026-10-28.endive, 2026-09-30.endive (Endive), before them 2026-08-26.dahlia.
  • https://docs.stripe.com/changelog/endive : 2026-09-30.endive is the first (breaking) Endive version; 2026-10-28.endive is additive only. Breaking Endive changes checked against this add-on: “Removes the payment method types parameter from Payment Intents and Setup Intents” (not sent: automatic_payment_methods[enabled]=true + excluded_payment_method_types), “Removes support for the payment method types option in Elements” (not used: intent-first Elements), “Deprecates the payment request button” (not used: Payment Element), “Adds support for Data Share Only for 3D Secure authentication” (new three_d_secure.result value data_share_only: the add-on only stores and shows the value as text, no logic depends on it), “Requires billing details when Payment Element collection is disabled” (collection is not disabled). None needs a code change.
  • Payment Element with PaymentIntents, intent-first (“Accept a payment”, Elements + Payment Intents): the server creates the PaymentIntent from the order and the browser confirms with stripe.confirmPayment. The order total stays in charge of the amount; verify updates an unpaid PaymentIntent when the order changed (elements.fetchUpdates()).
  • Own pay page after the order is placed (like every redirect processor of CS-Cart): the checkout page stays fully cacheable-safe and the PaymentIntent exists only for real orders.
  • No stripe-php. Ten endpoints over cURL keep the package small and free of Composer; the one algorithm reproduced (webhook signature) is documented step by step by Stripe.
  • Restricted keys only. “Migrate a plugin to Stripe Apps or Stripe Connect”: “Make sure businesses give you restricted API keys that start with the prefix with rk_, not sk_.” Accounts::keyProblem() refuses sk_.
  • Pinned version, same train in the browser. “Set Stripe’s API version in your plugin”; “keep the Stripe.js version and server-side API version on the same release train”. Webhook payloads use the account’s default version; the handler reads only ids, type, livemode and dispute fields, and reads the PaymentIntent back with the pinned version.
  • Money held, not given back, on a mismatch. A payment whose amount or order total does not match is kept with flag mismatch and offered for “Accept as paid”, refund or cancel (the shop’s money rules). Second payments (duplicate) and payments of orders cancelled meanwhile (late) are cancelled / refunded automatically.
  • Multi-Vendor parent payments (owner mode): one PaymentIntent on the parent order; child orders refund their share (Transactions::shareLeft()), an authorization is captured once for the vendor orders that are not cancelled (PaymentService::sharedCaptureAmount()).
  • Core stripe add-on untouched. Separate processor script, tables and language variables; nothing of core is modified.

Every call, header and field, with its source

Section titled “Every call, header and field, with its source”

Sources, all read 2026-11-08 from docs.stripe.com (Markdown copies in the build workspace scratchpad/oc-stripe/apidocs/; api/versioning re-checked 2026-11-12; the example objects used by the unit tests are in tests/fixtures/): api/authentication, api/versioning, api/idempotent_requests, api/errors, error-low-level, error-codes, api/payment_intents/{create, update, retrieve, search, capture, cancel, object}, api/refunds/{create, list, object}, api/charges/object, api/payment_method_domains/create, payments/payment-methods/pmd-registration (API), payments/accept-a-payment (Elements + Payment Intents), payments/place-a-hold-on-a-payment-method, payments/paymentintents/lifecycle, js/initializing, js/elements_object/create, js/elements_object/create_payment_element, js/payment_intents/confirm_payment, sdks/stripejs-versioning, webhooks, currencies, keys/restricted-api-keys, stripe-apps/plugins/decide-migration, stripe-apps/reference/permissions, building-plugins.

Item Value Source
Base https://api.stripe.com (HTTPS only) api/authentication: “Make all API requests over HTTPS”
Auth Authorization: Basic base64(<restricted key>:) api/authentication: “HTTP Basic Auth. Provide your API key as the basic auth username value. You don’t need to provide a password.”
Version Stripe-Version: 2026-10-28.endive api/versioning
Body application/x-www-form-urlencoded, nested a[b]=v, lists a[]=v (Api::encode) every API reference curl example (-d "automatic_payment_methods[enabled]=true")
Idempotency Idempotency-Key: <32 hex> on every POST, stored before the request; never on GET api/idempotent_requests: “all POST requests accept idempotency keys. Don’t send idempotency keys in GET and DELETE requests”; “up to 255 characters”; “we suggest using V4 UUIDs, or another random string with enough entropy”
Errors non-2xx with error.type, error.code, error.decline_code, error.message, error.param api/errors
Retry rules network error, 409 (not of type idempotency_error), 429: same key again, unless Stripe-Should-Retry: false; 5xx: outcome indeterminate and cached for the key, reconcile by reading back; a resend answered with a 4xx that is not a replay (no Idempotent-Replayed: true) means the first try never ran: the operation is failed; idempotency_error: never retried error-low-level (“Retry with the same idempotency key and parameters within the first 24 hours”; “If a 409 indicates that another request with the same key is still executing, wait and retry with that key”; “Stripe caches 500 responses … Retrying with the same key returns the cached response”; “Don’t retry with a new idempotency key until you’ve resolved the original outcome”), error-codes (idempotency_key_in_use)
Window operations resent with their key for 23 h, then reconciled only api/idempotent_requests: keys removed “after they’re at least 24 hours old”
Request id Request-Id response header written to the log api/request_ids
Call Fields sent Fields read Source
GET /v1/payment_intents?limit=1 (connection test) limit object = list api/payment_intents list
POST /v1/payment_intents amount (Stripe minor unit), currency (lowercase), automatic_payment_methods[enabled]=true, capture_method (automatic_async or manual), description, `metadata[kv_ref order_id platform], excluded_payment_method_types[]= boleto, konbini, multibanco, oxxo (voucher methods waiting days inrequires_action), optional receipt_email` (live mode only)
POST /v1/payment_intents/{id} amount, currency amount, currency, status api/payment_intents/update; accept-a-payment “Fetch updates from the server” (elements.fetchUpdates)
GET /v1/payment_intents/{id}?expand[]=latest_charge expand[] status, amount, amount_capturable, amount_received, currency, metadata.kv_ref, last_payment_error.message, client_secret, latest_charge.{id, amount_refunded, payment_method_details.type, card.brand, card.last4, card.wallet.type, card.three_d_secure.result} api/payment_intents/retrieve, object; api/charges/object
GET /v1/payment_intents/search query=metadata['kv_ref']:'<ref>', limit data[] api/payment_intents/search (a miss is never taken as proof: “data is searchable in less than a minute … up to an hour behind during outages”; “not available to merchants in India”); used for creates that stayed unclear (5xx, or a network error / 409 / 429 that the same-key resend did not settle), and an unpaid PaymentIntent the browser never received cannot be paid. A signed webhook for such a PaymentIntent is matched by metadata.kv_ref and read by id (error-low-level: “include a local identifier in its metadata so you can match an object received through a webhook”)
POST /v1/payment_intents/{id}/capture amount_to_capture (only when lower than amount_capturable) status succeeded or processing, amount_received api/payment_intents/capture (“Defaults to the full amount_capturable”; “Uncaptured PaymentIntents are cancelled a set number of days (7 by default) after their creation”); lifecycle (“attempting to capture the funds moves it to processing or succeeded”)
POST /v1/payment_intents/{id}/cancel cancellation_reason (requested_by_customer, duplicate, abandoned) status canceled api/payment_intents/cancel (“For PaymentIntents with a status of requires_capture, the remaining amount_capturable is automatically refunded”)
POST /v1/refunds payment_intent, amount, optional reason (requested_by_customer, duplicate, fraudulent), `metadata[kv_op platform]` id, object refund
GET /v1/refunds?payment_intent=&limit=100 amount, currency, status (pending, requires_action, succeeded count; failed, canceled do not), metadata.kv_op, id api/refunds/list, object; refunds (“Handle failed refunds”)
POST /v1/payment_method_domains domain_name apple_pay.status, google_pay.status, link.status api/payment_method_domains/create; pmd-registration (API)

succeeded -> captured / partial_refund / refunded; requires_capture -> authorized; processing -> pending (order in “Processing at Stripe”, waiting page, never cancelled); canceled -> canceled; requires_payment_method, requires_confirmation, requires_action -> open (not paid; after processing an explicit failure), except requires_action with next_action.type *_display_details or display_bank_transfer_instructions -> pending (an offline payment the customer still makes; never cancelled; such methods are excluded at create anyway). An amount that differs from the order -> error / MISMATCH, money kept, admin “Accept as paid”; only a duplicate (second payment of a paid order) is reversed automatically. Source: api/payment_intents/object status, payments/paymentintents/lifecycle.

Call Source
<script src="https://js.stripe.com/endive/stripe.js"> loaded once, from js.stripe.com only sdks/stripejs-versioning; accept-a-payment: “Always load Stripe.js directly from js.stripe.com to remain PCI compliant”
Stripe(publishableKey), stripe.registerAppInfo({name, version, url}) js/initializing; building-plugins “Client side and Stripe.js”
stripe.elements({clientSecret, appearance: {theme, variables.colorPrimary}}) js/elements_object/create; elements/appearance-api
elements.create('payment', {layout: {type}, defaultValues: {billingDetails: {name, email, phone, address}}}), events ready, loaderror js/elements_object/create_payment_element; accept-a-payment (“Use defaultValues to pass a customer email address”)
elements.fetchUpdates() after the server updated the amount accept-a-payment “Fetch updates from the server”
stripe.confirmPayment({elements, confirmParams: {return_url}, redirect: 'if_required'}); an error of type card_error or validation_error shows error.message js/payment_intents/confirm_payment (“When a non-redirect based payment method is successfully confirmed, stripe.confirmPayment will resolve with a {paymentIntent} object”)
return_url = <shop>/index.php?dispatch=payment_notification.return&payment=kv_stripe_payments&order_id=&key=<attempt key>; Stripe appends payment_intent, payment_intent_client_secret, redirect_status; they are not used: only the server read-back decides confirm_payment return_url (“You can also append your own query parameters”); accept-a-payment (“Inspect the status of the PaymentIntent”)

Webhooks (Webhook::verify, PaymentService::webhook)

Section titled “Webhooks (Webhook::verify, PaymentService::webhook)”
Rule Source (docs.stripe.com/webhooks, “Verify webhook signatures manually”)
Raw body from php://input, header HTTP_STRIPE_SIGNATURE “Stripe requires the raw body of the request to perform signature verification”
Split the header on ,, then =; t = timestamp, every v1; ignore other schemes (v0) Step 1; “ignore all schemes that aren’t v1”
signed_payload = t . "." . body; HMAC-SHA256 keyed with the endpoint secret Steps 2 and 3
Constant-time compare with every v1 (rolled secrets) Step 4; “multiple signatures … when you roll an endpoint’s secret”
Tolerance 300 s, never 0 “default tolerance of 5 minutes”; “Don’t use a tolerance value of 0”
One secret per endpoint and mode; livemode must match the mode whose secret verified “If you use the same endpoint for both test and live API keys, the secret is different for each one”
Duplicates by event id; order independent; objects read back “Handle duplicate events”, “Event ordering”: “use the API to retrieve any missing objects”
Non-2xx is retried (live: up to three days); a failed read-back answers 503 and releases the event id “Automatic retries”

ISO 4217 exponents from tooling/release-templates/cscart/iso4217/gen.py (checked with --check); Stripe “amount” is the minor unit as Stripe defines it (currencies: “Currencies are two-decimal currencies unless otherwise specified”; zero-decimal list BIF CLP DJF GNF JPY KMF KRW MGA PYG RWF UGX VND VUV XAF XOF XPF; special case ISK “represent it as a two-decimal value, where the decimal amount is always 00”). Factor 1 where ISO and Stripe agree, 100 for ISK, refused where they disagree without a rule (MGA) or the page contradicts itself (UGX is on the zero-decimal list and in the special cases as two-decimal). Presentment currencies: union of the per-country lists on the currencies page (BHD, JOD, KWD, OMR, TND are not listed). Minimum amounts are left to Stripe (amount_too_small -> the customer is told).

  • The order is placed with status N (incomplete) before payment; the processor script sends the customer to the pay page. A processing payment moves the order to the “processing” status (default O) through fn_change_order_status(), so stock and e-mails behave like core payments; paid / failed statuses the same way.
  • The return handler never lets a still-processing payment look like a cancelled transaction: it empties the cart and the saved cart rows (?:user_session_products) and shows checkout.complete.
  • Full page cache (4.21): kv_stripe_payments.pay, payment_notification.* and POSTs are not cacheable dispatches; the checkout note is shown only on checkout pages, which are never cached.
  • Smarty 4/5: no Smarty plugins; templates use only core tags and modifiers.
  • tests/unit.php (PHP 8.1 and 8.3, no store, no network): money, statuses, webhook signature, the REST client contract (headers, form encoding, errors) with the official example objects in tests/fixtures/, key validation, log masking, operation proof, recurring-defect checks.
  • tests/mock-server/server.js: local stand-in of the Stripe REST API and Stripe.js, built from the API reference (never talks to Stripe).
  • tests/e2e/e2e.mjs (HTTP, dev store) and tests/e2e/vendor.mjs (Multi-Vendor): refuse to run unless the store’s base URL setting and the mock are loopback addresses.