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.
- Customer creation is supported only when a valid
customerobject 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_TRANSACTIONlevel β no childCC_PAYMENTrows are created until the customer is provisioned. - Customer creation failure is terminal: the transaction transitions to
FAILEDand no retries are attempted automatically.
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:
USER_INITIATED_PAYMENTβ customer not found: The transaction is parked inPENDING_FOR_CUSTOMER_CREATIONand resumes when the customer service provisions the customer asynchronously.- Any flow β customer service rejects the request (e.g. invalid metadata, bad identifier): The transaction transitions to
FAILEDwith the customer-service error preserved, and aPAYMENT_UPDATEDevent is published. The caller discovers this viaGET /v2/paymentspolling.
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β
| Capability | V1 | V2 |
|---|---|---|
| New customer detection | customerClient.searchCustomer() in command handler | CustomerCheckCommand (post-processing command) |
| Pending state entity | CC_PAYMENT row set to PENDING_FOR_CUSTOMER_CREATION | CC_TRANSACTION row set to PENDING_FOR_CUSTOMER_CREATION |
| Child payments created while pending | No (guarded in handleExistingPayment()) | No (guarded in TransactionService.triggerOrchestration()) |
| Resumption trigger | CustomerConsumer.handlePayments() | CustomerConsumer.handleV2Transactions() |
| Customer lookup on resume | PaymentRepository.findByCustomerIdAndPaymentStatus() | TransactionRepository.findByCustomerIdAndStatus() |
| Failure handling | handlePaymentError() β FAILED | transaction.failOnCustomerCreationFailure() β FAILED |
| Merchant-initiated synchronous create | findOrCreateCustomer() inline | CustomerCheckCommand.findOrCreateCustomer() inline |
| Split-tender support | Not applicable (V1 is single-payment) | β Supported |
Related Documentationβ
- Payment Lifecycle States
- Single Payment Flow
- Split-Tender Payment Flow
- Pay with Wallet β the standard V2 payment flow without new-customer creation
- Error Strategy
- V2 Payment Request Lifecycle
- Commons Library
- Error Codes
- How to Submit a Payment with Customer Creation
- Customer Creation During Payment β Reference
- Troubleshoot Customer Creation During Payment