# B2B user creation and KYB
### 1) Business User creation (KYB satus pending)
```mermaid
sequenceDiagram
Participant Treezor
Participant Agent
Participant B2B Client
B2B Client ->> Agent: Register Client account (sharing KYB information, legal representative ID, majority shareholders ID..)
Agent ->> Agent: Verify, Approve and Create B2B Client instance
Agent ->> Treezor: Create Business User POST /user
Treezor -->> Agent: webhook user.create
Agent ->> Treezor: Add Tax residence to the business user POST /taxResidences
Agent ->> Treezor: Send the KYB documents for review POST/document
Treezor -->> Agent: webhook document.create
Agent ->> Treezor: Create Wallet linked to Business User POST /wallet
Treezor -->> Agent: webhook wallet.create
B2B Client ->> Treezor: SCTR
Treezor -->> Agent: webhook payin.create
Treezor -->> Agent: webhook document.update
```
:::info
:information_source: To ask for KYB review, the payin must be validated. The agent should either receive :
- a payin.create with payinStatus to VALIDATED
- a payin.update with payinStatus to VALIDATED (if the fund transfert takes some time)
:::
### 2) Legal Representative creation w/ liveness
Liveness verification is not mandatory here, please refer to the KYC document
```mermaid
sequenceDiagram
Participant Treezor
Participant Agent
Participant Enduser
Agent ->> Treezor: Create Physical users as Legal representatives POST /user
Treezor -->> Agent: webhook user.create
Agent ->> Treezor: Add Tax residence to the user POST /taxResidences
Agent ->>Treezor: (Optional for liveness) Send the KYC documents (Proof of adress) for review POST/document
Treezor -->> Agent: webhook document.create
Agent ->>Treezor: Ask for KYC review liveness POST/users/{id}/kycliveness (you receive KYC liveness URL in response)
Agent->>Enduser: KYC liveness URL sent to the enduser
Enduser->>Enduser:Perform liveness onboarding
Treezor-->>Agent: webhook kycliveness.create (kyc-status processing)
Treezor-->>Agent: webhook kycliveness.update (kyc-status processed) upon document analysis by the liveness provider
Agent ->>Treezor: Retrieve liveness document PUT /users/{id}/kycliveness
Treezor-->>Agent: webhook document.create
Agent ->>Treezor: Request KYC review PUT /users/{id}/Kycreview
Treezor ->> Treezor: KYC approval
Treezor-->>Agent: webhook user.kycreview
```
### 3) Majority Shareholders creation w/ liveness
Repeat the step 2 for each Majority Shareholders.
### 4) Validate the Business User
:::warning
:warning: Before doing this step, all Legal representative and Majority Shareholders must had their KYC reviewed & validated
:::
```mermaid
sequenceDiagram
Participant Treezor
Participant Agent
Participant B2B Client
Agent ->> Treezor: Ask for KYB review PUT /user{id}/Kycreview
Treezor -->> Agent: webhook user.kycreview (status pending)
Treezor ->> Treezor: KYB approval
Treezor -->> Agent: webhook user.kycreview (status validated)
```
# Charge the wallet of the agent (SCTR / SCTR Inst)
```mermaid
sequenceDiagram
Participant Treezor
Participant Agent
Participant B2B Client
B2B Client ->> Treezor: Send funds
Treezor -->> Agent: webhook payin.create
Treezor -->> Agent: webhook payin.update (status validated)
Treezor -->> Agent: webhook transaction.create
Treezor -->> Agent: webhook balance.update
```
## CARD creation flow - BULK Creation
### 1) Request bulk creation, and link the a card to an enduser
```mermaid
sequenceDiagram
Participant Treezor
Participant Agent
Participant Enduser
Agent ->> Treezor : Request card bulk POST /card/bulk
Treezor -->> Agent: webhook for each user, wallet and user creation (At the same time of the card creation, linked wallet and user are created. They are created anonymously)
Treezor ->> Agent : send all cards to the same adress
Agent ->> Enduser : Mail the card to the end user (the card is inactive)
Enduser ->> Enduser: Enter the card token in his application
Agent ->> Treezor : Activate the card with the card token PUT /cards/{cardToken}/public-token-activation \
Treezor -->> Agent: webhook card.activate (user id )
Agent->> Treezor : Fetch the user and wallet linked to the card GET/card if needed (information already in the wekhook activate)
Agent ->> Treezor : Update the user to link it to the card user PUT /user
Treezor -->> Agent: webhook user.updated
Agent ->>Treezor: Register the card for 3DS POST/cards/Register3DS
```
### 2) Activate the card and identify the user
```mermaid
sequenceDiagram
Participant Treezor
Participant Agent
Agent ->>Treezor: If KYC review is needed, Send the KYC documents (Proof of adress) for review POST/document
Treezor -->> Agent: webhook document.create
Agent ->>Treezor: Ask for KYC review liveness POST/users{id}/kycliveness
Treezor -->> Agent: webhook kycliveness.create (w/ URL)
Agent->>Enduser: KYC liveness URL sent to the enduser
Enduser->>Enduser:Perform liveness onboarding
Treezor ->> Treezor: KYC approval
Treezor -->> Agent: webhook kycliveness.update (status validated)
Agent ->> Treezor: Update the PIN code of the card PUT /setpin
Treezor -->> Agent: webhook card.update
Enduser->>Enduser : go to the ATM/POS physical to valide the pin change and be activate the use of the card (link to the /setpin)
````
# Create End-users (beneficiaries) of the agent (skip this step if you are using bulk card creation)
The benefiaciaries are created as ME wallet onwner so they do not need to have a KYC
```mermaid
sequenceDiagram
Participant Treezor
Participant Agent
Agent ->> Treezor: Create Physical User POST /user
Treezor -->> Agent: webhook user.create
````
If a KYC review is needed:
```mermaid
sequenceDiagram
Participant Treezor
Participant Agent
Agent ->>Treezor: Ask for KYC review liveness POST/users/{id}/kycliveness (you receive KYC liveness URL in response)
Agent->>Enduser: KYC liveness URL sent to the enduser
Enduser->>Enduser:Perform liveness onboarding
Treezor-->>Agent: webhook kycliveness.create (kyc-status processing)
Treezor-->>Agent: webhook kycliveness.update (kyc-status processed) upon document analysis by the liveness provider
Agent ->>Treezor: Retrieve liveness document PUT /users/{id}/kycliveness
Treezor-->>Agent: webhook document.create
Agent ->>Treezor: Request KYC review PUT /users/{id}/Kycreview
Treezor ->> Treezor: KYC approval
Treezor-->>Agent: webhook user.kycreview
```
```mermaid
sequenceDiagram
Participant Treezor
Participant Agent
Agent ->> Treezor: Create Wallet linked to Physical User POST /wallet
Treezor -->> Agent: webhook wallet.create
```
Charge the beneficiary wallet:
```mermaid
sequenceDiagram
Participant Treezor
Participant Agent
Agent ->> Treezor: Charge money from B2B user's wallet POST transfers \
Treezor -->> Agent: webhook transfer.create
Treezor -->> Agent: webhook payin.update (status validated)
Treezor -->> Agent: webhook transaction.create
Treezor -->> Agent: webhook balance.update
```
# Make a card transaction
If you want to apply Merchant id restriction (MID), Merchant category restrictions (MCC) restrcition or country restriction, you must before creating the card create the restriction using :
- POST /v1/merchantIdRestrictionGroups
- POST /v1/countryRestrictionGroups
- POST /v1/mccRestrictionGroups
### 1) Create a card linked to the end-user
```mermaid
sequenceDiagram
Participant Imprimeur
Participant Treezor
Participant Agent
Participant Enduser
Agent ->>Treezor: Create the physical card POST/cards/requestPhysical
Treezor -->> Agent: webhook card.requestphysical
Treezor ->>Imprimeur: Create the physical card
Imprimeur->> Enduser : Mail the card
Agent ->>Treezor: Register the card for 3DS POST/cards/Register3DS
Treezor -->> Agent: webhook card.register3DS
Agent ->>Treezor: Set the PIN code PUT/cards/setpin
Treezor -->> Agent: webhook card.setpin
Enduser->>Agent : Activate the card
Agent ->>Treezor: Activate the card PUT cards/{id}/Activate/
Treezor -->> Agent: webhook card.activate
```
### 2) Make the transaction
```mermaid
sequenceDiagram
Participant Treezor
Participant Agent
Participant Enduser
Participant Merchant
Enduser ->> Merchant : Initiate a payment
Treezor -->>Agent: webhook card.transaction (status A)
Treezor -->> Agent: webhook card.transaction (status S)
Treezor -->> Agent: webhook balance.updated
```