Add pre-authorization (confirmation_mode) support to Merchant resources#165
Open
paulosouza-stark wants to merge 1 commit into
Open
Add pre-authorization (confirmation_mode) support to Merchant resources#165paulosouza-stark wants to merge 1 commit into
paulosouza-stark wants to merge 1 commit into
Conversation
nicolasalmeida-stark
approved these changes
Jun 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description and impact
The
feat/pre-approvebranch ofapi-v2-ms-card-merchantintroduced manual confirmation mode (pre-authorization) for merchant purchases: a newconfirmationModefield (automatic/manual, defaultautomatic) onMerchantSessionandMerchantPurchase. Inmanualmode the purchase is approved but only captured after an explicit confirmation (PATCH /merchant-purchase/{id}withstatus=confirmed), and a newDELETE /merchant-purchase/{id}endpoint cancels (approved) or fully reverses (confirmed) a purchase.The Python SDK did not expose
confirmationModenor the delete endpoint, so integrators could not use pre-authorization through the SDK. This PR adds that support.Planning card: ACQ-413.
Change
confirmation_modeattribute to theMerchantSession,MerchantPurchaseandMerchantSession.Purchaseresources. It is serialized asconfirmationModeand omitted whenNone(so the server defaultautomaticapplies).starkcore.from_api_jsonsilently drops unknown fields, so the attribute must exist in the resource for the value to be exposed on responses.merchantpurchase.delete(id)→DELETE /merchant-purchase/{id}(cancels anapprovedpurchase or fully reverses aconfirmedone; the operation is inferred server-side from the current status).merchantpurchase.update(id, status="confirmed", amount=...).README.md(field in the session/purchase examples + new Confirm/Cancel a MerchantPurchase sections),CHANGELOG.md([Unreleased]), and the builders/tests undertests/.POST /merchant-purchase/{id}route listed in the servicepermissions.yamlwas intentionally not implemented (it has no handler). Themanual + debitrestriction is enforced server-side; the SDK just forwards the value.SDK usage examples
1. Create a pre-authorization session (
confirmation_mode="manual")2. Create a purchase directly in manual mode (optional — credit only)
3. Confirm (capture) the pre-authorized purchase
4. Cancel an approved purchase / fully reverse a confirmed one
Rollback Plan
e82170e(Added pre-authorization) and/or pin the dependency to the previously released SDK version.Acceptance Criteria
merchantsession.create(...)withconfirmation_mode="manual"returns a session andconfirmation_moderound-trips on the response.approved(not captured) until confirmed.merchantpurchase.update(id, status="confirmed", amount=...)confirms (captures) a manual purchase.merchantpurchase.delete(id)cancels anapprovedpurchase and fully reverses aconfirmedone.