# Payment Flow ## 1. Payment Status Flowchart ```mermaid stateDiagram-v2 state "Payment Request (1)" as 1 state "Payment Complete (2)" as 2 state "Payment Cancel (3)" as 3 state "Payment Fail (4)" as 4 state "Payment Pending (5)" as 5 state "Pending Cancel (6)" as 6 state "Partial Cancel (7)" as 7 state "Payment Register (9)" as 9 [*] --> 1 1 --> 4 1 --> 5 1 --> 2 : Domestic credit cards complete immediately 1 --> 9 1 --> [*] 5 --> 6 5 --> 2 : Capture / Deposit in pending state 5 --> [*] 6 --> [*] 2 --> 3 : Cancel entire payment 2 --> 7 : Cancel part of payment 2 --> [*] 7 --> 7 : Continue partial cancellation until fully cancelled 7 --> 3 : Becomes 'Payment Cancel' when fully cancelled 7 --> [*] 3 --> [*] 4 --> [*] 9 --> [*] ``` ## 2. General Payment Flow ### Key Steps Description 1. **Create Payment Intent**: The store server acquires session and authentication information from the PG via EBP in advance. 2. **User Authentication**: Perform authentication by redirecting to the EBP payment screen (2-1) or by directly implementing the PG SDK at the store (2-2). 3. **Payment Creation**: The stage where the actual payment is created and authorized based on the authenticated data. * **3-1. API Method**: The store server calls EBP's **Payment Creation API** after acquiring auth data from the browser to complete authorization. Finally, the Store redirects the user to the Success URL. * **3-2. Webhook Method**: The user approves the payment directly on the PG screen (or SDK), and the PG finalizes the authorization. The user is then **redirected to the Store's Success URL** by the PG. 4. **Authorization Result (Webhook)**: Regardless of the finalization method, EBP processes the authorization result received from the PG and sends an **Authorization Webhook** to the store. The store receives this notification to finalize the order processing and present the payment completion to the user. ```mermaid sequenceDiagram autonumber actor User as User participant Store as Store participant EBP as EBP participant PG as PG rect var(--mermaid-rect-gray) Note over User, PG: 1. Create Payment Intent User->>Store: Click checkout button Store->>EBP: Create Payment Intent (POST /api/v2/payment-intents) activate EBP EBP->>PG: Request payment session PG-->>EBP: Response session & keys (pgResponse) EBP-->>Store: Response paymentUrl & pgResponse deactivate EBP end rect var(--mermaid-rect-blue) Note over User, PG: 2. User Authentication alt 2-1. EBP Redirect Page (Wrapping) Store-->>User: Redirect to EBP payment page (paymentUrl) User->>EBP: Access EBP page & enter auth info EBP->>PG: Request payment authentication else 2-2. Merchant Direct SDK Implementation Store->>User: Render PG UI on Store page User->>PG: Enter auth info & request authentication via PG components end end rect var(--mermaid-rect-green) Note over User, PG: 3. Payment Creation alt 3-1. API Method (Store calls Payment Creation API) PG-->>User: Deliver authentication data User->>Store: Deliver auth data & request completion Store->>EBP: Request Payment Creation (POST /api/v2/payments) EBP->>PG: Final approval request PG-->>EBP: Response approval result EBP-->>EBP: Process authorized data EBP-->>Store: Response approval result Store-->>User: Redirect to Success URL else 3-2. Webhook Method (User creates payment directly via PG) PG->>PG: Approve payment PG-->>User: Redirect to Store Success URL end end rect var(--mermaid-rect-brown) Note over User, PG: 4. Authorization Result (Webhook) PG->>EBP: Authorization notice (Webhook) EBP->>EBP: Process authorized data EBP->>Store: Authorization notification (Webhook) Store-->>User: Display final payment complete page end ``` --- ### 2.2. Payment Result Notification (Async) [context] **PGI Async Section:** Retry 3 times on timeout, then call Notification Fail API (EBP_API_239).

**Core Payment Completion Processing:**
1. Validate payment completion.
2. Parse PG response data.
3. Process EBP payment completion.
4. Generate store response data.
5. Send store purchase history. [/context] ```mermaid sequenceDiagram autonumber 1 participant Store2 as Store participant Core as Core (EBP) participant PGI as PGI (EBP) participant PG as PG PG->>PGI: Payment Complete Webhook activate PG activate PGI PGI->>Core: Payment Complete Notification activate Core Note over Core: Notification (EBP_API_238) Note right of Core: Payment Pending: PG('5') Core->>Store2: Create Purchase History (Async) activate Store2 Store2-->>Core: Response deactivate Store2 Core-->>PGI: Response deactivate Core PGI-->>PG: Webhook Response deactivate PGI deactivate PG ``` > Pending state (before capture) may require partial cancellation processing. --- ### 2.3. Final Payment Completion via Capture ```mermaid sequenceDiagram autonumber 1 participant Store2 as Store participant Core as Core (EBP) participant PGI as PGI (EBP) participant PG as PG (PG) Store2->>Core: Request Capture activate Store2 activate Core Note over Core: Request (EBP_API_228) Core->>PGI: Request Capture activate PGI PGI->>PG: Request Capture activate PG PG-->>PGI: Response Capture Result deactivate PG PGI-->>Core: Response Capture Result deactivate PGI Note right of Core: Payment Complete: ('2') Core-->>Store2: Response Capture Result deactivate Core deactivate Store2 ``` --- ### 2.4. Purchase Confirmation [context] **Effect of Purchase Confirmation:**
1. Settlement proceeds for confirmed purchases.

**Conditions for Purchase Confirmation:**
1. User confirms purchase in order history.
2. Automatically confirmed by batch job a certain period after delivery completion.
[/context] ```mermaid sequenceDiagram autonumber 1 actor USER as User participant Store as Store participant Core as Core (EBP) USER->>Store: Confirm Purchase Store->>Core: Request Confirmation activate Store activate Core Note over Store, Core: Request (EBP_API_214) Core-->>Store: Response Purchase History Creation deactivate Core deactivate Store Store->>USER: Purchase Confirmation Alert ``` ## 3. Token Payment Flow ### 3.1. Token Registration Flow [context] **Token Registration:** The user requests token registration from the Store, which calls the PG screen via Core. [/context] ```mermaid sequenceDiagram actor USER as User participant Store as Store participant Core as EBP(Core) participant PGI as EBP(PGI) participant PG as PG (PG) autonumber rect var(--mermaid-rect-blue) Note over USER, Core: 1. Token Registration Initialization USER->>Store: Request Token Registration activate Store Store->>Core: Prepare Registration (EBP_API_120) activate Core Core-->>Store: Response Registration URL deactivate Core Store-->>USER: Redirect to Registration URL (HTTP 3xx) deactivate Store end rect var(--mermaid-rect-beige) Note over USER, PG: 2. User Authentication & Registration USER->>PGI: Redirect to Registration URL (HPP) activate PGI Note over PGI: EBP HPP (Redirect) PGI->>PG: Call PG Registration Screen activate PG Note over USER, PG: 3. User Input & Registration Authorization PG-->>PGI: Transfer Result (Callback/Redirect) deactivate PG end rect var(--mermaid-rect-gray) Note over USER, Store: 4. Notification PGI-->>USER: Redirect to Store Return URL (HTTP 3xx) deactivate PGI USER->>Store: Return to Complete Page Note over PG, Store: Asynchronous Processing (Webhook) PG->Core: Token Registration Webhook Core->>Store: Token Registration Webhook end rect var(--mermaid-rect-pink) Note over USER, Core: 5. PIN Registration (Optional: If required by Store) USER->>Store: Register PIN Store->>Core: Register Encrypted PIN (EBP_API_131) end ``` ### 3.2. Token Payment #### 3.2.1. Customer-Initiated Payment ```mermaid sequenceDiagram actor USER as User participant Store as Store participant Core as EBP(Core) participant PG as PG (PG) autonumber rect var(--mermaid-rect-green) Store ->> Core: Request Payment (EBP_API_230) activate Store Note over USER, Core: PIN Verification (Optional: If a PIN is registered) Store-->>USER: Request PIN Verification USER->>Store: Enter PIN Store->>Core: Verify Encrypted PIN (EBP_API_126) Core-->>Store: PIN Verification Result end rect var(--mermaid-rect-pink) Store ->> Core: Request Payment (EBP_API_230) activate Core Note right of Core: State: Payment Request('1') Core ->> PG : Process Payment Request PG -->> Core: Payment Complete Notification (Callback/Redirect) Core -->> Store: Create Purchase History & Deliver Data deactivate Core deactivate Store Store -->> USER: Display Order Complete Page end ``` #### 3.2.2. Merchant‑Initiated Subscription Payment ```mermaid sequenceDiagram actor USER as User participant Store as Store participant Core as EBP(Core) participant PGI as EBP(PGI) participant PG as PG (PG) autonumber rect var(--mermaid-rect-blue) activate Store Store ->> Core: Request Payment (EBP_API_230) activate Core Note right of Core: State: Payment Request('1') Core ->> PG : Process Payment Request PG -->> Core: Payment Complete Notification (Callback/Redirect) Core -->> Store: Create Purchase History & Deliver Data deactivate Core deactivate Store end ``` ### 3.3. Delete Registered Token [context] **Delete Token:** Deletes a registered token upon user request. [/context] ```mermaid sequenceDiagram autonumber 1 actor USER as User participant Store as Store participant Core as Core (EBP) participant PGI as PGI (EBP) USER->>Store: Request Token Deletion activate Store Note over Store, Core: Delete Token (EBP_API_124) Store->>Core: Call Delete Token API activate Core Core->>PGI: Request Deletion activate PGI PGI-->>Core: Response deactivate PGI Core-->>Store: Response Result deactivate Core Store-->>USER: Token Deletion Completion Message deactivate Store ``` ### 3.4. Query Registered Tokens [context] **Query Token:** The user queries the list of previously registered tokens. [/context] ```mermaid sequenceDiagram autonumber 1 actor USER as User participant Store as Store participant Core as Core (EBP) USER->>Store: Request Token List activate Store Note over Store, Core: Query Token (EBP_API_109) Store->>Core: Call Query Token API activate Core Core-->>Store: Response Token List deactivate Core Store-->>USER: Deliver Token List deactivate Store ```