CrestApps Orchard Core Payments and Stripe
Payments are provider-neutral. A gateway is an ICheckoutPaymentProvider registered on the tenant; the checkout engine drives it, the durable ledger records it, and every consumer stays unaware of which gateway took the money. Stripe is the shipped card gateway. Installment plans (a Subscriptions sub-feature) build on the same contracts to keep a card and charge it on a schedule.
Related skills: orchardcore-checkout (the engine, steps, test provider), orchardcore-transactions (ledger screens, refunds console), orchardcore-pay-later (offline providers), orchardcore-subscriptions (recurring agreements), orchardcore-taxation, orchardcore-invoicing (invoices and their payment schedules), orchardcore-banking (money the business sends out: disbursements, checks, direct deposit).
Features and packages
| Feature ID | Name | Depends on | Notes |
| --- | --- | --- | --- |
| CrestApps.OrchardCore.Stripe | Stripe (Payment Providers) | CrestApps.OrchardCore.Users | With Checkout enabled it registers the card provider (key Stripe) automatically; with Workflows it adds Stripe events; with Point of Sale it adds stripe-terminal |
| CrestApps.OrchardCore.Subscriptions.Installments | Subscriptions - Installment Plans | Transactions, Checkout, OrchardCore.Users | Does not need the Subscriptions feature or Products; see references/installment-plans.md |
CrestApps.OrchardCore.Payments.Abstractions is a contracts package (namespace CrestApps.OrchardCore.Payments): Money, GatewayMode (Live, Testing), IPaymentEvent, PaymentEventBase, the event contexts and RemoteSubscriptionStatus. Provider contracts are in CrestApps.OrchardCore.Checkout.Abstractions (CrestApps.OrchardCore.Checkout.Services). Install CrestApps.OrchardCore.Stripe in the web/startup project.
{
"steps": [
{
"name": "Feature",
"enable": [
"CrestApps.OrchardCore.Checkout",
"CrestApps.OrchardCore.Stripe"
],
"disable": []
}
]
}
Guidelines
- Amounts are
decimaleverywhere. Compare withMoney.AreEqualandMoney.IsGreaterThan, round withMoney.Round(amount, currency), and convert to minor units only at the gateway boundary (Money.ToMinorUnits,StripeCurrency).CurrencyScale.GetDecimalPlacesknows JPY (0) and KWD (3);CurrencyScalenow lives inCrestApps.OrchardCore.Abstractions(namespaceCrestApps.OrchardCore.Currencies) so the catalog and taxation round without referencing payments. - Providers are tax-agnostic: they charge the amount the checkout gives them (tax included) and report the net and tax split back in
PaymentVerificationResult. - Never record a payment from a webhook alone. A webhook is a hint; the engine verifies through
VerifyAsyncagainst the gateway's API. - Never refund by calling a gateway. Use
ICheckoutRefundServiceso the refund is recorded first, capped at what remains, taxed from the original snapshot and locked against concurrent refunds. - Only server code sets
savePaymentMethod,offSession,savedCustomerReferenceandsavedPaymentMethodReference. - Read Stripe options through
IOptionsMonitor<StripeOptions>.CurrentValue; they refresh without a tenant restart when settings are saved. - All C# classes are
sealedexcept view models; recipes use{ "steps": [...] }.
Adding a gateway
- Implement
ICheckoutPaymentProviderunder a uniqueKey:DisplayName,Capabilities,BeginAsync,VerifyAsync,CancelAsync. - Declare honest
PaymentProviderCapabilities:SupportsOneTimePayments,SupportsRecurringPayments,SupportsHostedCheckout,SupportsEmbeddedElements,SupportsCombinedOneTimeAndRecurring,CollectsTaxDynamically,SupportsRefunds,SupportsSavedPaymentMethods,DefersPayment,AcceptsDelegatedCredentials(charges an AI agent's one-purchase credential on the server),AcceptsExternalAuthentication(takes a 3-D Secure result from outside). Seeorchardcore-checkoutfor the delegated and 3-D Secure provider data keys. A provider that claims refunds must implementICheckoutPaymentRefundProvider(an architecture test checks); one that claims recurring support must implementICheckoutRecurringPaymentProviderunder the same key or the engine refuses it. - Render its panel on the payment step with an
IDisplayDriver<CheckoutFlowPaymentMethod>whose result is.OnGroup(providerKey). - Optionally implement
ICheckoutPaymentProviderAvailability(rule itself out of a checkout),ICheckoutPaymentProviderDescription(line under the name),ICheckoutSavedPaymentMethodProvider(installments, off-session charges) andICheckoutPaymentClientConfigurationProvider(publishable values for API clients, never secrets). - Translate the gateway's webhooks into
IPaymentEventcalls and complete throughICheckoutEngine.TryCompleteAsync.
A complete provider with refunds and its panel is in references/custom-payment-provider.md.
| Result type | Use |
| --- | --- |
| PaymentBeginResult.Success(reference) | Begun; set ClientSecret, RedirectUrl or RequiresAction for the browser |
| PaymentBeginResult.Decline(message, reference) | The gateway refused the card; the attempt fails and the next try gets a new idempotency key |
| PaymentBeginResult.Failure(message) | Could not start (network, configuration) |
| PaymentVerificationResult | Status (PaymentStatus.Succeeded, Failed, Unknown), TransactionId, ReportsAuthoritativeAmount, Amount, TaxAmount, Currency, GatewayMode, RiskLevel, RiskScore |
| PaymentRefundResult.Success / Pending / Failed | Refund outcome with the provider's refund reference |
BeginPaymentContext carries the Session, the durable Attempt (ExpectedAmount, ExpectedTaxAmount, Currency, IdempotencyKey, ObligationId), the Invoice, return and cancel URLs and the sanitized ProviderData. Use Attempt.IdempotencyKey on every mutating gateway call.
Payment events
IPaymentEvent (derive from PaymentEventBase) is the normalized stream every gateway raises: PaymentSucceededAsync, PaymentIntentSucceededAsync, CustomerSubscriptionCreatedAsync, PaymentFailedAsync, PaymentCanceledAsync, PaymentRefundedAsync, PaymentDisputeCreatedAsync, PaymentDisputeUpdatedAsync (default method), SubscriptionPaymentFailedAsync (a renewal failed) and SubscriptionStatusChangedAsync (with RemoteSubscriptionStatus; Unknown means leave local state alone). Contexts carry GatewayId, GatewayMode and a Data bag; each method takes a CancellationToken.
using CrestApps.OrchardCore.Payments;
public sealed class DisputeAlertPaymentEvent : PaymentEventBase
{
public override Task PaymentDisputeCreatedAsync(PaymentDisputeCreatedContext context, CancellationToken cancellationToken = default)
{
// Alert the finance team. Reconcile against durable state; never mark anything paid here.
return Task.CompletedTask;
}
}
// services.AddScoped<IPaymentEvent, DisputeAlertPaymentEvent>();
Refunds
ICheckoutRefundService.RequestRefundAsync(new RequestPaymentRefundContext { SessionId, OriginalTransactionId, Amount, Reason }) returns the durable PaymentRefund (RefundStatus: Requested, Pending, Succeeded, Failed, Canceled, PendingManualReview). It resolves the settled attempt, refuses more than remains, derives refunded tax from the original TaxSnapshot through ITaxRefundCalculator, persists before calling the provider, and serializes refunds of one payment with IDistributedLock. A provider without ICheckoutPaymentRefundProvider gets PendingManualReview, closed by an operator under Commerce > Refunds.
Refunds observed at the gateway (for example from the Stripe dashboard) flow through ICheckoutRefundReconciliationService: matched by provider reference, idempotency key, then an open request of the same amount; an unmatched one is quarantined as PendingManualReview with remote_refund_without_local_request. For a transaction, prefer ITransactionCommandService.RefundAsync (see orchardcore-transactions); for an order, the order's Manage box. React to finished refunds with IPaymentRefundHandler.RefundSucceededAsync.
Stripe
Settings and connection
Settings > Payments > Stripe (group stripe, permission ManageStripeSettings). Choose Enable Production (off is test mode), paste the secret and publishable keys, Save, then Connect: the key is verified, the account id stored, a webhook to /stripe/webhook created with its signing secret, and the site domain registered for wallets (skipped on localhost). Disconnect deletes the provisioned webhook and clears stored credentials. StripeSettings: IsLive, Live|Test + PublishableKey, PrivateSecret, WebhookSecret, AccountId, WebhookId. Secrets are data-protected.
After upgrading, click Connect again so the auto-provisioned webhook subscribes to the newer events (subscription lifecycle, refunds, disputes).
Configuration from appsettings or the environment
The optional CrestApps_Stripe section (StripeConfigurationOptions, read per tenant from IShellConfiguration at tenant start) wins over the settings page one value at a time:
{
"OrchardCore": {
"CrestApps_Stripe": {
"IsLive": false,
"Test": {
"PublishableKey": "pk_test_...",
"SecretKey": "sk_test_...",
"WebhookSecret": "whsec_..."
}
}
}
}
OrchardCore__CrestApps_Stripe__IsLive=false
OrchardCore__CrestApps_Stripe__Test__SecretKey=sk_test_...
OrchardCore__Contoso__CrestApps_Stripe__Test__SecretKey=sk_test_...
Configured values show read-only on the page and are never written to the database. With a configured webhook secret, Connect does not create a webhook; register POST /stripe/webhook in the Stripe dashboard with that secret.
Recipe and deployment
StripeSettings has its own recipe and deployment step (not the Settings step). The deployment step exports no secrets and no account or webhook ids. The recipe step protects clear-text secrets, keeps stored secrets it does not carry, checks each key's prefix for its mode (pk_test_, sk_live_, whsec_) and ignores account and webhook ids.
{
"steps": [
{
"name": "StripeSettings",
"Settings": {
"IsLive": false,
"TestPublishableKey": "pk_test_...",
"TestPrivateSecret": "sk_test_...",
"TestWebhookSecret": "whsec_..."
}
}
]
}
What the provider does
- Card payments use Stripe Elements on the payment step:
BeginAsynccreates an unconfirmed PaymentIntent for the attempt's gross amount and returns its client secret;VerifyAsyncreads the PaymentIntent (with Radar risk) from Stripe. The hosted-checkout mode is gone. - Recurring obligations become real Stripe subscriptions with inline prices (
StripeRecurringPaymentProvider); one Stripe customer is resolved per checkout so a setup fee and a plan share the card. Cancel, pause (pause_collection) and resume reach Stripe. - Saved cards:
savePaymentMethod(installments) andoffSessioncharges; buyer wallets throughIStripeWalletServicewithsavedCardIdandrememberCardprovider data, listed ataccount/payment-methods. - A card the bank wants the cardholder to approve off-session (
authentication_required) is reported withPaymentBeginResult.AuthenticationRequired(...)(a decline that also setsRequiresAuthentication), surfaced asPaymentBeginOutcome.RequiresAuthentication. - A card kept at checkout is added to the customer's kept payment methods (
ISavedPaymentMethodStore, seeorchardcore-checkout), and any module can charge it later withITransactionCommandService.ChargeSavedPaymentMethodAsync(seeorchardcore-transactions). With Checkout on,account/payment-methodslists those first under Cards for automatic payments, with Make default (account/payment-methods/kept/{id}/default) and Remove (account/payment-methods/kept/{id}/remove);AccountPaymentMethodsViewModel.KeptPaymentMethodscarries them. - Apple Pay and Google Pay through the Express Checkout Element when the device has a wallet, the domain is registered and the page is HTTPS.
- Payments AI agents bring (
AcceptsDelegatedCredentials, used by Agentic Commerce, seeorchardcore-agentic-commerce): a Stripe shared payment token (stripe_shared_payment_token,spt_..., issued to the store's Stripe account by the agent's platform) is charged withpayment_method_data[shared_payment_granted_token]on the preview API version2026-09-30.preview(StripePaymentIntentService.SharedPaymentTokenApiVersion); a Google Pay token (google_pay_token) whose gateway is Stripe is charged with itstok_...card token (a token Stripe did not issue is refused). Each charge carries the attempt's idempotency key and metadatacheckout_attempt_id,checkout_session_idanddelegated, and is verified like any payment. A credential pays one purchase only: keeping the card or a recurring charge is refused. When the bank asks the buyer to approve, the result requires an action with Stripe's redirect page and carriesCardBrand. - Imported 3-D Secure results (
AcceptsExternalAuthentication): an agent's result is sent with Stripe's Import 3D Secure results (payment_method_options[card][three_d_secure][cryptogram],[electronic_commerce_indicator],[transaction_id],[version],[ares_trans_status]) anderror_on_requires_action=true. A PaymentIntent already waiting for approval is confirmed with the result (idempotency key: the attempt's key plus a hash of the result); a refused confirm cancels it. A result that does not allow payment never reaches Stripe. The account must have 3D Secure import enabled by Stripe. - Webhook
POST /stripe/webhook: signature verified first, one distributed lock and a processed-event record per event, handler writes committed with the marker;500asks Stripe to retry,409on lock contention. Events mapped:invoice.payment_succeeded,invoice.payment_failed,customer.subscription.created|updated|deleted,payment_intent.succeeded|payment_failed|canceled,charge.refunded,refund.created|updated|failed,charge.refund.updated,charge.dispute.created|updated|closed. - Workflow events (category Stripe, with
OrchardCore.Workflows):StripePaymentReceivedEvent,StripeSubscriptionCreatedEvent,StripePaymentIntentSucceededEvent,StripePaymentFailedEvent,StripePaymentCanceledEvent,StripePaymentRefundedEvent,StripeDisputeCreatedEvent,StripeRequestFailedEvent(401, 403 or no connection; throttled to once per five minutes per tenant).
Local development
stripe login
stripe listen --forward-to https://localhost:5001/stripe/webhook --skip-verify
stripe trigger payment_intent.succeeded
Paste the printed whsec_ into Test Webhook Signing Secret (Advanced) or set CrestApps_Stripe:Test:WebhookSecret. For automated tests without Stripe use the Test payments provider (orchardcore-checkout). On several nodes enable OrchardCore.Redis.Lock and OrchardCore.Redis.Cache so locks and payment signals are shared.
Upgrading from 2.x
PaymentMethodOptions,PaymentMethodand the subscription-specific Stripe endpoints are gone; payment methods are the registeredICheckoutPaymentProviders and their panels areIDisplayDriver<CheckoutFlowPaymentMethod>(notSubscriptionFlowPaymentMethod).- Money moved from
doubletodecimal; thedoubleoverloads ofStripeCurrencywere removed. StripePriceSyncServiceand Sync prices were removed; prices are sent inline.- Stripe's Checkout Mode setting was removed (Elements only).
IOptions<StripeOptions>readers must switch toIOptionsMonitor<StripeOptions>.- Reconnect Stripe after upgrading.
Troubleshooting
| Symptom | Fix |
| --- | --- |
| Settings page denied to a role with Manage Stripe Settings | Fixed in 3.0 by AddSiteSettingsPermission; update |
| Renewals or cancellations never recorded | Click Connect again to re-provision the webhook events |
| Webhook returns 400 | Wrong signing secret for the mode, or a configured secret shadowing a provisioned one |
| Card form missing | Publishable key not set for the active mode |
| Wallet buttons missing | Domain not registered, not HTTPS, or nothing due now |
| payment_method belongs to the Customer | Fixed in 3.0: one customer per checkout |
| The card could not be saved for later payments when retrying a checkout with another card | Fixed in 3.0 (#1055): the Stripe customer for a card-keeping checkout is keyed by the checkout and its payment method |
| Agent payment with a shared payment token fails | The token was issued to another Stripe account or business profile (set Stripe business profile in Agentic Commerce settings), or the account lacks Stripe's shared payment token preview |
| Agent's 3-D Secure result refused by Stripe | The account does not have Stripe's 3D Secure import feature |
| Off-session charge declined with authentication_required | Expected: reported as RequiresAuthentication; ask the customer to pay the invoice themselves |