Skip to content

[18.0][IMP] subscription_oca: Add automatic recurring payment#1463

Open
chrisandrewmann wants to merge 1 commit into
OCA:18.0from
chrisandrewmann:18.0-imp-subscription_oca-autopay
Open

[18.0][IMP] subscription_oca: Add automatic recurring payment#1463
chrisandrewmann wants to merge 1 commit into
OCA:18.0from
chrisandrewmann:18.0-imp-subscription_oca-autopay

Conversation

@chrisandrewmann

@chrisandrewmann chrisandrewmann commented Jun 14, 2026

Copy link
Copy Markdown

Adds automatic recurring payment to subscription_oca. When enabled, a subscription charges the customer's saved payment token on each billing run, removing the manual collection step for merchant-initiated recurring payments (stored card, BACS/SEPA direct debit, etc. via a tokenizing payment provider).

Purpose

subscription_oca could only generate invoices; collecting payment was always manual. This closes that gap while guaranteeing a customer is never sent an invoice for money that has not actually been collected.

Changes

  • Charge before posting. The invoice is kept in draft and is only posted and reconciled once the payment succeeds. A failed charge never posts an owed invoice and never consumes an invoice number.
  • New field Automatic payment boolean on the subscription template, compatible with every invoicing mode (including Draft for silent billing).
  • New Payment Token field on the subscription: suggested from the partner's most recent token, constrained to the same commercial partner, and carried over automatically from the originating eCommerce or initial portal sale order payment.
  • Success: invoice posted, reconciled, and (per invoicing mode) the paid invoice emailed — never an "amount due" document.
  • Asynchronous capture: transaction left pending, invoice posted later on provider webhook confirmation; billing continues normally.
  • Failure: invoice stays draft, subscription flagged with Payment Exception, a to-do activity is raised (visible in list/kanban), and the next invoice date is not advanced so the period is retried after a fix.
  • The cron skips flagged subscriptions and isolates each one in a savepoint so a single rejected charge can't roll back the batch. Payment Exception is a public field so external retry integrations can set/clear it.
  • Add tests for the success, pending, failure, retry and silent-draft paths.
  • New manifest dependency: account_payment.
  • Version bumped minor: 18.0.1.0.018.0.2.0.0.
  • Added updated USAGE.md - See usage guide for manual testing

Invoicing mode behaviour with automatic payment

Invoicing mode On a successful charge
Draft Invoice posted, no email (silent background billing)
Invoice Invoice posted, paid invoice emailed
Invoice & send Invoice posted, paid invoice emailed
Sale order & Invoice Sale order confirmed, invoice posted (no email)

History

This supersedes and improves upon #1331 (an 16.0 PR by @adasatorres, which stuck open with unresolved test failures). It is a fresh 18.0 implementation that keeps the spirit — automatic token-based collection on the billing cron — while addressing its main limitations:

  • auto_create_payment boolean instead of a new invoicing-mode option, so automatic payment composes with every mode
    (including Draft for silent billing) rather than being one mode.
  • Charge before posting: [16.0][IMP] subscription_oca: recurrent payment #1331 posts and sends the invoice and then marks it paid (or sends it for manual payment when no token exists); here the invoice stays in draft until the charge succeeds, so a failed charge never posts an
    owed invoice, never burns an invoice number, and the customer is never sent an "amount due" document for money already taken.
  • Explicit failure handling: a payment_exception flag, a to-do activity in list/kanban, an unchanged next-invoice date for retry, and a cron that skips flagged subscriptions — instead of silently falling back to manual collection.
  • Robustness: per-subscription savepoint isolation in the cron, support for asynchronous (pending) capture posted on webhook confirmation, automatic token hand-off from the originating sale order.

Credit to @adasatorres for the original PR

@chrisandrewmann chrisandrewmann changed the title [IMP] subscription_oca: add automatic payment [18.0][IMP] subscription_oca: add automatic payment Jun 14, 2026
@chrisandrewmann chrisandrewmann force-pushed the 18.0-imp-subscription_oca-autopay branch from 997db94 to 3f7992c Compare June 14, 2026 06:58
@chrisandrewmann

chrisandrewmann commented Jun 14, 2026

Copy link
Copy Markdown
Author

@tarteo @yvaucher @carlos-domatix @rousseldenis

Would appreciate your input in testing and hopefully getting merged this time around! I think it's a feature we've all needed for a while.

@chrisandrewmann chrisandrewmann force-pushed the 18.0-imp-subscription_oca-autopay branch 5 times, most recently from 5039eb0 to 2e656ed Compare June 15, 2026 15:40
@chrisandrewmann chrisandrewmann force-pushed the 18.0-imp-subscription_oca-autopay branch from 2e656ed to a02fb6a Compare June 15, 2026 15:41
@chrisandrewmann chrisandrewmann changed the title [18.0][IMP] subscription_oca: add automatic payment [18.0][IMP] subscription_oca: Add automatic recurring payment Jun 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants