Initial commit

This commit is contained in:
Yaser
2026-08-13 19:56:46 +03:30
commit de1d57a67b
474 changed files with 43185 additions and 0 deletions

View File

@@ -0,0 +1,95 @@
# KYC: Access mobile
###### Sprint: 3
### Outcome:
User should enter his number, after the validation app sends a sms with an otp code, the user must enter the code to prove to us that he has access to the entered number.
#### Endpoints:
POST {$domain}/api/v2/barong/resource/mobiles
POST {$domain}/api/v2/barong/resource/mobiles/send_code
POST {$domain}/api/v2/barong/resource/mobiles/verify
#### File destination:
{$Dalan_Path}/app/api/v2/resource/phones.rb
#### Commits:
bd7f980596
695b0b56e2
6dd40a9c42
e04a58b012
36167eda10
2089690fe0
90cbc48649
17a5bce849
63722fe22a
63977c330d
bff2746686
75490dcb22
f13ee3f4d5
2c05522f77
46c053b435
551e7cdba2
77d7b9a9b3
2da71b1097
#### What did we implement:
First of all we added a new service for our sms&call third party service(kavenegar).it needs its own initializer for private keys.in this service we also handle caching data(for storing keys and codes with expiration time) and creating OTP code by vault.
We created a new api for phones with our rules.
after verification every number, app create a new label(access_phone) if there were not that label.
note:
if user wants to enter new number:
1.if user has pending number --> legacy number will be update with new number
2.If user has verified access label --> new number must get access label to create in db and legacy one replaced
3.If user has verified ownership label --> new number must get both labels to create in db and legacy one replaced
```mermaid
sequenceDiagram
title: access phone
User->>Ranj: enter phone number with +98
Ranj-->>Dalan: post /mobiles params
Dalan->>Ranj: 400, message: 'Required params are empty'
Dalan->>Ranj: 401, message: 'Invalid bearer token'
Dalan->>Ranj: 404, message: 'Record is not found'
Dalan->>Ranj: 422, message: 'Validation errors'
Dalan->>Ranj: 422, message: 'code_doesnt_expired'(there is an active process for addding new mobile)
Dalan->>Ranj: 200, message: 'New phone was added'
note left of Dalan: if there is a pending number it will be replaced with new one
Dalan->>KaveNegar: send sms to User in case of success
KaveNegar->>User: SMS with code
Ranj->>User: show result
note right of User: if didnt catch sms
User->>Ranj: resend code
Ranj->>Dalan: Post mobiles/send_code params
Dalan->>Ranj: 400, message: 'Required params are empty'
Dalan->>Ranj: 401, message: 'Invalid bearer token'
Dalan->>Ranj: 404, message: 'Record is not found', 'phone.doesnt_exist'
Dalan->>Ranj: 422, message: 'Validation errors'
Dalan->>Ranj: 422, message: 'code_doesnt_expired' (expiration time doesnt finish)
Dalan->>KaveNegar: send sms to User in case of success
KaveNegar->>User: SMS with code
Ranj->>User: show result
User->>Ranj:enter code
Ranj->>Dalan: Post mobiles/verify params
Dalan->>Ranj: 401, message: 'Invalid bearer token'
Dalan->>Ranj: 404, message: 'Record is not found', 'phone.doesnt_exist'
Dalan->>Ranj: 422, message: 'Validation errors'
Dalan->>Ranj: 400, message: phone.verification_invalid
note right of Ranj: if user wants to replace a new verified phone and the legacy phone has owner_phone label, we should check ownership. if it doesnt legacy phone labels all changes will be rollback.
Dalan->>Ranj: success 2xx
Ranj->>User: show result
```

View File

@@ -0,0 +1,45 @@
# KYC: Bank information
### Outcome:
we checking ownership of card-numbers and ibans.
### Implementation description:
#### Endpoints:
Post {$domain}/api/v2/barong/resource/profiles/treasury
#### File destination:
- {$Dalan_Path}/app/api/v2/resource/profiles.rb
- {$Dalan_Path}/app/workers/kyc/local/treasury_worker.rb
- {$Dalan_Path}/app/services/jibit_service.rb
#### Commits:
- 40177a4f
- 816fb00e
- 9e17677b
- 63977c33
- c76f72fe
- 90cbc486
#### What did we implement:
We implemented a new model and table to keep users bank information and called it treasury.<br />
After users entered their card_number or IBAN, we are sending this information to the Jibit service,<br />
and then the Jibit Service returns the first name and last name of the real owner.<br />
Now we can check this returned information to users' profile information to find out everything is ok.<br />
It is worth mentioning that the steps of getting information from the Jibit and checking it with the profile are done in the background.
```mermaid
sequenceDiagram
Title: bank information (treasury)
note over User,Dalan: Users enter their bank information
note over User,Dalan: `data` is card-number or iban value, `kind` is 'card' or 'iban'
User->>Dalan:data, kind, title
note over Dalan,Jibit: Dalan send request to Jibbit service (as worker)
Dalan->>Jibit:GET: iban value or card value (data)
Jibit->>Dalan:Response: first-name and last-name of real owner
Dalan->>Dalan: checking returned information with users profile data
Dalan->>User: add a confirmed label if the names matched, otherwise rejected label was created.
```

View File

@@ -0,0 +1,38 @@
# KYC: Personal info
###### Sprint: 3
### Outcome:
Users add the below information to their profile
### Implementation description:
#### Endpoints:
POST {$domain}/api/v2/barong/resource/profiles
#### File destination:
{$Dalan_Path}/app/api/v2/resource/profiles.rb
#### Commits:
9f1cde76
2422f5d1
#### What did we implement:
In the Opendax, users can create their profiles by personal info and Address info in one step, also in this step there is no way to upload identity card
So In Zagros, we separate the step of adding personal info from adding address info step, and also we add upload identity card features
```mermaid
sequenceDiagram
Title: KYC - Profile Step
note over User,Ranj:**upload** is a picture of front identity card
User->>Ranj:first_name, last_name, dob, national_code, upload
Ranj->>Dalan:Post: after client side checking
Dalan->>Ranj:4xx if any required params are empty
Dalan->>Ranj:4xx if Profile model validity fails
Dalan->>Ranj:4xx if Document model validity fails
Dalan->>Ranj:2xx the profile create successfully
Ranj->>User:notify user that profile created
```