Repository navigation
Conversation
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
PaymentPlugin implements the taskflow Resumer. On the cancel command it closes the step's own checkout through CancelCheckoutSession and completes the step with payment_status "cancelled", dropping the client's payload. Any other command, such as the webhook's submit, passes through unchanged.
Resume closes the step's own checkout on the cancel command and completes the step as cancelled whatever the client sent. Other commands pass through, a settled checkout is refused, and a step with no recorded reference cancels nothing.
4f65d81 to
98402cc
Compare
PaymentPlugin.Resume calls payment.Service.CancelCheckoutSession (payment v0.6.0) and implements plugins.Resumer, which core added in the same commit range. Bump core to 5471ef1, the commit that holds both.
Summary
A trader on a pending payment step can't go back to choosing a payment method, and the checkout they opened stays payable. This lets the PAYMENT plugin act when its step is resumed with the
cancelcommand: it closes the step's own checkout and completes the step as cancelled, so the workflow can send the trader back to method selection.Type of Change
Changes Made
platform/payment:CancelCommand = "cancel", besideStepCommand.platform/tasktypes:PaymentPluginimplementsplugins.Resumer(feat(taskflow): let a plugin act on the call that resumes its step #404).cancel,Resumereads the checkout's reference from the step's own data, never from the request, and callsCancelCheckoutSession(feat(payment)!: cancel an unpaid checkout and record a payment that lands after it #430) with it and the step's callback token. It completes the step with{payment_status: "cancelled", reference_number}and drops the client's payload, so a client can't complete the step as paid.submit, passes through unchanged.payment.ErrPaymentSettled, so the caller can map it to 409.ExecuteandResumeshare one key for the stored reference.platform/go.mod:core/paymenttov0.6.0, and thecoreroot to5471ef1, the commit that holds both feat(taskflow): let a plugin act on the call that resumes its step #404 (Resumer) and feat(payment)!: cancel an unpaid checkout and record a payment that lands after it #430 (CancelCheckoutSession).tasktypesandpaymentREADMEs.Resumedoes not check who sent a command it passes through, so the step'sPRE_RESUMEauthz must let only thesystemcaller sendsubmit, and only the payer's roles sendcancel. The READMEs and theResumecomment say so.Testing
With
GOWORK=off, onpayment v0.6.0:go vet,go test ./...for the wholeplatformmodule, andgolangci-lintpass, andgo mod tidychanges nothing.New tests in
platform/tasktypes/payment_test.gocover: cancel closes the step's own checkout with its reference and token, the client's payload is ignored,submitand no command pass through without touching the checkout, a settled checkout is refused, a missing reference cancels nothing, andResumereads the keyExecutewrote. BreakingResumeso it always cancels, or so it takespayment_statusfrom the client's payload, made its tests fail.Checklist
Related Issues
Related to #391
Additional Notes
payment/v0.6.0is tagged on #430's merge commit (5471ef1), andplatform/go.modrequires it, so this builds on released versions.Next: OpenNSW/nsw-srilanka#1357 (draft) maps
ErrPaymentSettledto 409payment_settledin its step handler and documents thecancelcommand. Once this merges, it bumpscore/platformto this PR's commit.🤖 Generated with Claude Code
Summary by CodeRabbit