Checking access…

Skip to main content
Audience: CCG Platform Engineers

Customer Creation During Payment

Platform engineers working on CustomerCheckCommand and the PENDING_FOR_CUSTOMER_CREATION state. See the request walkthrough, reference, and troubleshooting guide for the corresponding details.

KEY RULES
  • Customer creation is supported only when a valid customer object is provided in the payment request.
  • Guest payments do not create customers and are not affected by this flow.
  • The transaction is paused at the CC_TRANSACTION level β€” no child CC_PAYMENT rows are created until the customer is provisioned.
  • Customer creation failure is terminal: the transaction transitions to FAILED and no retries are attempted automatically.
Verified against source (2026-11-25)

A separate internal note (confirmed 2026-11-23) claimed USER_INITIATED_PAYMENT never parks in PENDING_FOR_CUSTOMER_CREATION and that merchant-initiated lookup/creation runs asynchronously after 202. That does not match the current wallet-payment-service source (CustomerCheckCommand.java, main branch) or its test suite β€” both confirm the attribution below (USER_INITIATED_PAYMENT parks; MERCHANT_INITIATED_PAYMENT creates synchronously inline) is correct as currently implemented. This page continues to document the verified, source-confirmed behavior; the 2026-11-23 note should be treated as stale or describing unmerged/planned work, not current behavior.

Overview​

When a v2 payment is submitted and the customer lookup or creation fails, the system must never return a synchronous error from POST /v2/payments. All customer-related failures are post-processing β€” the API always returns 202 Accepted immediately, and the result is surfaced asynchronously through GET /v2/payments polling.

There are two distinct async failure paths:

  1. USER_INITIATED_PAYMENT β€” customer not found: The transaction is parked in PENDING_FOR_CUSTOMER_CREATION and resumes when the customer service provisions the customer asynchronously.
  2. Any flow β€” customer service rejects the request (e.g. invalid metadata, bad identifier): The transaction transitions to FAILED with the customer-service error preserved, and a PAYMENT_UPDATED event is published. The caller discovers this via GET /v2/payments polling.

This mechanism mirrors the equivalent V1 behaviour on the cc_payment table but is implemented entirely within the V2 domain model (Transaction aggregate / CC_TRANSACTION table).

End-to-End Sequences​

Path A β€” USER_INITIATED_PAYMENT: Customer Not Found (Park & Resume)​

Path B β€” Any Flow: Customer Service Rejects Request (Async FAILED)​

V1 vs V2 Comparison​

CapabilityV1V2
New customer detectioncustomerClient.searchCustomer() in command handlerCustomerCheckCommand (post-processing command)
Pending state entityCC_PAYMENT row set to PENDING_FOR_CUSTOMER_CREATIONCC_TRANSACTION row set to PENDING_FOR_CUSTOMER_CREATION
Child payments created while pendingNo (guarded in handleExistingPayment())No (guarded in TransactionService.triggerOrchestration())
Resumption triggerCustomerConsumer.handlePayments()CustomerConsumer.handleV2Transactions()
Customer lookup on resumePaymentRepository.findByCustomerIdAndPaymentStatus()TransactionRepository.findByCustomerIdAndStatus()
Failure handlinghandlePaymentError() β†’ FAILEDtransaction.failOnCustomerCreationFailure() β†’ FAILED
Merchant-initiated synchronous createfindOrCreateCustomer() inlineCustomerCheckCommand.findOrCreateCustomer() inline
Split-tender supportNot applicable (V1 is single-payment)βœ… Supported