﻿# Non-Periodic Auto Debit

## 1. Interaction Process

```mermaid
%%{init: {
  'theme': 'base',
  'themeVariables': {
    'primaryColor': '#e6f0ff',
    'primaryTextColor': '#333',
    'primaryBorderColor': '#5b9bd5',
    'lineColor': '#888',
    'actorMargin': 40,
    'noteBkgColor': '#0056b3',
    'noteTextColor': '#ffffff',
    'noteBorderColor': '#004a99'
  }
}}%%
sequenceDiagram
    participant User as User
    participant MServer as Merchant Server
    participant PM as PayerMax

    %% Initial Payment Logic Box
    rect rgb(235, 245, 255)
        Note over User, PM: Initial Payment
        User->>MServer: 1. User selects payment method
        MServer->>PM: 2. User initiates payment and binding request
(API Integration)
        PM-->>MServer: 3. PayerMax returns
payment and binding success info
        MServer-->>User: 4. Notify user of payment success
and binding completion
    end

    %% Subsequent Payment Logic Box
    rect rgb(235, 245, 255)
        Note over User, PM: Subsequent Payment
        MServer->>PM: 1. Merchant requests deduction from PayerMax
        PM-->>MServer: 2. PayerMax completes payment and
returns payment success info
        MServer-->>User: 3. Notify user of payment success
    end
```

## 2. Rules

- Merchant direct debits can be divided into initial and subsequent debits. The initial debit requires the user to bind a payment method, while subsequent debits are merchant-initiated and require no user interaction.

- For the initial debit, integration is supported using the cashier mode, API mode, and front-end component mode. Subsequent debits require no user interaction and can be completed using the API.

- For the initial debit, the transaction amount (totalAmount) supports 0 or a specific amount greater than 0. If the transaction amount is 0, only the payment method is bound. If the transaction amount is greater than 0, the payment is initiated and the payment method is bound. After a successful transaction, PayerMax generates a token (paymentTokenID) for the user's payment method and notifies the merchant for subsequent direct debits.

- For subsequent debits, the paymentTokenID is sent instead of the user's payment method to complete the debit.
