Skip to content

Payments — acceptance criteria

Settling a payment

4 scenarios — these are acceptance criteria for what the service must do, not a description of what it does.

binding spec features/settle-payment.feature @ 2.0.0 — the spec of record. It states what must be; implementations converge on it, never the reverse.

Enforced by
  • check:version — any change must bump the artifact and service versions; a silent edit fails CI
  • bound by implementations in strict mode — an unbound scenario fails their build
  • check:intent — every schema element added to a contract must be named here
  • gherkin-lint
Version history
VersionFirst releasedService version
2.0.02026-08-273.0.0
1.1.02026-08-232.0.0
1.0.02026-08-231.0.0
Consume it

Settlement is terminal. Authorisation is not.

Settlement emits exactly one event

  • Givenan authorised payment p-1 for order o-1 of 2500 pence
  • Whenthe processor confirms settlement
  • Thena PaymentSettled event is published on payments.settled.v2
  • Andthe event data amount_pence is 2500

Settlement events are CloudEvents envelopes

  • Givenan authorised payment p-3 for order o-3 of 1000 pence
  • Whenthe processor confirms settlement
  • Thena PaymentSettled event is published on payments.settled.v2
  • Andthe envelope carries specversion 1.0, a unique id and a time
  • Andthe envelope source is /payments and its type is com.hungovercoders.payments.settled.v2
  • Andthe envelope subject is the payment_id, with datacontenttype application/json
  • Andthe data carries the payment_id, order_id, settled_at and amount_pence
  • Andhandlers dedupe on the envelope id

Duplicate settlement callbacks are idempotent

  • Givenpayment p-1 has already settled
  • Whenthe processor sends the settlement callback again
  • Thenno second PaymentSettled event is published

A reversal after authorisation does not emit settlement

  • Givenan authorised payment p-2
  • Whenthe authorisation is reversed
  • Thenno PaymentSettled event is published for p-2
Raw Gherkin
Feature: Settling a payment
  Settlement is terminal. Authorisation is not.

  Scenario: Settlement emits exactly one event
    Given an authorised payment "p-1" for order "o-1" of 2500 pence
    When the processor confirms settlement
    Then a "PaymentSettled" event is published on "payments.settled.v2"
    And the event data amount_pence is 2500

  Scenario: Settlement events are CloudEvents envelopes
    Given an authorised payment "p-3" for order "o-3" of 1000 pence
    When the processor confirms settlement
    Then a "PaymentSettled" event is published on "payments.settled.v2"
    And the envelope carries specversion "1.0", a unique id and a time
    And the envelope source is /payments and its type is com.hungovercoders.payments.settled.v2
    And the envelope subject is the payment_id, with datacontenttype "application/json"
    And the data carries the payment_id, order_id, settled_at and amount_pence
    And handlers dedupe on the envelope id

  Scenario: Duplicate settlement callbacks are idempotent
    Given payment "p-1" has already settled
    When the processor sends the settlement callback again
    Then no second "PaymentSettled" event is published

  Scenario: A reversal after authorisation does not emit settlement
    Given an authorised payment "p-2"
    When the authorisation is reversed
    Then no "PaymentSettled" event is published for "p-2"