-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFXNext Version 2.7 - Payee conversion with RECEIVE amount.puml
509 lines (446 loc) · 15.2 KB
/
FXNext Version 2.7 - Payee conversion with RECEIVE amount.puml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
@startuml
title Transferring with Currency Conversion\nPayee DFSP requests conversion\nSender pays fees
actor "Upile\nChisala" as A1
participant "NBS\nBank" as D1
participant "FDH FX" as FXP
participant "Switch" as S1
participant "Zoona" as D2
actor "Mulenga\Kapwepwe" as A2
participant ALS
autonumber
A1->D1:I'd like to pay Mulenga Kapwepwe\n100 ZMW for her latest book, please
== Discovery Phase ==
activate D1
D1->S1:I want to send to MSISDN 260795390415\n**GET /parties/MSISDN/260795390415**
activate S1
S1-->D1:202 I'll get back to you
deactivate D1
S1->ALS:Who owns MSISDN 260795390415?
activate ALS
ALS-->S1:It's Zoona
deactivate ALS
S1->D2:Do you own MSISDN 260795390415?
activate D2
D2-->S1:202 I'll get back to you
deactivate S1
D2->S1:Yes, it's Mulenga Kapwepwe. She can receive in ZMW\n**PUT /parties/MSISDN/260795390415**
note over D2
PUT /parties
"party": {
"partyIdInfo": {
"partyIdType": "MSISDN",
"partyIdentifier": "260795390415"
},
"name": "Mulenga Kapwepwe",
"supportedCurrencies":[
"ZMW"
]
}
end note
activate S1
S1-->D2:200 Gotcha
deactivate D2
S1->D1:Yes, it's Mulenga Kapwepwe. She can receive in ZMW\n**PUT /parties/MSISDN/260795390415**
activate D1
D1-->S1:200 Gotcha
deactivate S1
== Agreement Phase ==
D1->D1:I'll leave Mulenga's DFSP\nto do the currency conversion
D1->S1:Please quote for a payment of 100 ZMW.\n**POST /quotes**
note over D1
POST /quotes
{
"quoteId": "382987a8-75ce-4037-b500-c475e08c1727"
,"transactionId": "d9ce59d4-3598-4396-8630-581bb0551451"
, "payee": {
"partyIdInfo": {
"partyIdType": "MSISDN"
, "partyIdentifier": "260795390415"
}
}
, "payer": {
"partyIdInfo": {
"partyIdType": "MSISDN"
, "partyIdentifier": "265314118010"
, "supportedCurrencies": ["MWK"]
}
},
"amountType": "RECEIVE"
, "amount": {
"currency": "ZMW"
, "amount": "100"
},
"converter": "PAYEE"
, "transactionType": {
"scenario": "TRANSFER"
, "initiator": "PAYER"
, "initiatorType": "CONSUMER"
}
}
end note
activate S1
S1-->D1:202 I'll get back to you
deactivate D1
S1->D2:Please quote for a transfer which sends 100 ZMW.\n**POST /quotes**
activate D2
D2-->S1:202 I'll get back to you
deactivate S1
== Currency conversion ==
D2->D2:Hmmm. I'll need to get some currency conversion
D2->S1:What FXPs do you know about?\n**GET /services/FXP**
activate S1
S1-->D2:202 I'll get back to you
deactivate D2
S1->ALS:What FXPs do you know about?
activate ALS
ALS-->S1:FDH FX
deactivate ALS
S1->D2:Here are the available FXPs:FDH FX
note over S1
PUT /services/FXP
"fxpProviders": [
"FDH_FX"
]
end note
activate D2
D2-->S1:200 Gotcha
deactivate S1
D2->D2:I'll ask FDH FX to perform my conversion
D2->D2:I propose to charge 2 ZMW for executing this payment,\nand this is a RECEIVE amount,\nso I need to add it to the currency conversion request
D2->S1:Here is the initial version of the transfer.\nPlease quote me for the currency conversion.
note over D2
**post /fxQuotes**
{
"conversionRequestId": "828cc75f-1654-415e-8fcd-df76cc9329b9"
, "conversion": {
"conversionId": "581f68ef-b54f-416f-9161-ac34e889a84b",
, "counterPartyFsp": "FDH_FX"
, "amountType": "RECEIVE"
, "sourceAmount": {
"currency": "MWK"
}
, "targetAmount": {
"currency": "ZMW"
, "amount": "102"
}
, "validity": "2021-08-25T14:17:09.663+01:00"
}
}
end note
activate S1
S1-->D2:202 I'll get back to you
deactivate D2
S1->FXP:Here is the initial version of the transfer.\nPlease quote me for the currency conversion.\n**POST /fxQuote**
activate FXP
FXP-->S1:202 I'll get back to you
deactivate S1
FXP->FXP:OK, so I need to figure this out...
note over FXP
I will add a 150 MWK fee for undertaking the conversion.
Now I'll set an expiry time, sign the quotation object,
create an ILP packet and return it in the intermediary object.
** PUT /fxQuotes/828cc75f-1654-415e-8fcd-df76cc9329b9**
{
"condition": "bdbcf517cfc7e474392935781cc14043602e53dc2e8e8452826c5241dfd5e7ab"
, "conversionTerms": {
"conversionId": "581f68ef-b54f-416f-9161-ac34e889a84b"
, "initiatingFsp": "NBS_Bank"
"sourceAmount": {
"currency": "MWK",
"amount": "5250"
}
, "targetAmount": {
"currency": "ZMW",
"amount": "102"
}
, "validity": "2021-08-25T14:17:09.663+01:00"
, "charges": [
{
"chargeType": "Conversion fee"
, "sourceAmount": {
"currency": "MWK"
, "amount": "150"
}
, "targetAmount": {
"currency": "ZMW"
, "amount": "3"
}
}
]
}
}
end note
FXP->S1:Here's the signed conversion object
activate S1
S1-->FXP:200 Gotcha
deactivate FXP
S1->D2:Here's the signed conversion object\n**PUT /fxQuotes/828cc75f-1654-415e-8fcd-df76cc9329b9**
activate D2
D2-->S1:Gotcha
deactivate S1
D2->D2:OK, so I will add 2 ZMW on top of the conversion fee.\nNow I sign the transaction object\nand return it to the Debtor DFSP
D2->S1:Here's the signed quote
note over D2
**put /quotes/382987a8-75ce-4037-b500-c475e08c1727**
{
"transferAmount": {
"currency": "MWK"
, "amount": "5250"
}
, "payeeReceiveAmount": {
"currency": "ZMW"
, "amount": "100"
},
"payeeFspFee": {
"currency": "MWK"
, "amount": "250"
}
, "expiration": "2021-08-25T14:17:09.663+01:00
, transaction: {
"transactionId": "d9ce59d4-3598-4396-8630-581bb0551451"
"quoteId": "382987a8-75ce-4037-b500-c475e08c1727"
, "payee": {
"partyIdInfo": {
"partyIdType": "MSISDN"
, "partyIdentifier": "260795390415"
}
}
, "payer": {
"partyIdInfo": {
"partyIdType": "MSISDN"
, "partyIdentifier": "265314118010"
}
},
, "amount": {
"currency": "MWK"
, "amount": "5250"
}
, "payeeReceiveAmount": {
"currency": "ZMW"
, "amount": "100"
},
, "transactionType": {
"scenario": "TRANSFER"
, "initiator": "PAYER"
, "initiatorType": "CONSUMER"
}
}
, "condition": "BfNFPRgfKF8Ke9kpoNAagmcI4/Hya5o/rq9/fq97ZiA="
}
end note
activate S1
S1-->D2:200 Gotcha
deactivate D2
S1->D1:Here's the signed quote\n**PUT /quotes/382987a8-75ce-4037-b500-c475e08c1727**
activate D1
D1-->S1:200 Gotcha
deactivate S1
D1->D1:OK, I can see that there are going to be 250 MWK in charges.
D1->A1:Hi, Upile: I can do the transfer.\nIt'll cost you 250 MWK in fees\nand Mulenga Kapwepwe will receive\n100 ZMW.\nLet me know if you want to go ahead
A1-->D1:Great! Yes please, go ahead
== Transfer Phase ==
D1->S1:Please do the transfer
note over D1
POST /transfers
{
"transferId": "c720ae14-fc72-4acd-9113-8b601b34ba4d"
, "payeeFsp": "Zoona"
, "payerFsp": "NBS_Bank"
, "amount": {
"currency": "MWK"
, "amount": "5250"
}
, transaction: {
"transactionId": "d9ce59d4-3598-4396-8630-581bb0551451"
"quoteId": "382987a8-75ce-4037-b500-c475e08c1727"
, "payee": {
"partyIdInfo": {
"partyIdType": "MSISDN"
, "partyIdentifier": "260795390415"
}
}
, "payer": {
"partyIdInfo": {
"partyIdType": "MSISDN"
, "partyIdentifier": "265314118010"
}
},
, "amount": {
"currency": "MWK"
, "amount": "5250"
}
, "payeeReceiveAmount": {
"currency": "ZMW"
, "amount": "100"
},
, "transactionType": {
"scenario": "TRANSFER"
, "initiator": "PAYER"
, "initiatorType": "CONSUMER"
}
}
}
end note
activate S1
S1-->D1:202 I'll get back to you
deactivate D1
S1->S1:Does the debtor hold an account in MWK? Yes.
S1->S1:Make the reservation against the debtor account.
note over S1
Reservations:
NBS has a reservation of 5250 MWK
end note
S1->D2:Please do the transfer\n**POST /transfers**
activate D2
D2-->S1:202 I'll get back to you
deactivate S1
D2->D2:Do I need to activate currency conversion?\nYes, I do
D2->S1:Please confirm your part of the transfer
note over D2
**POST /fxTransfers**
{
"commitRequestId": "77c9d78d-c26a-4474-8b3c-99b96a814bfc"
, "determiningTransactionId": "d9ce59d4-3598-4396-8630-581bb0551451"
, "requestingFsp": "Zoona"
, "respondingFxp": "FDH_FX"
, "sourceAmount": {
"currency": "MWK",
"amount": "5250"
}
, "targetAmount": {
"currency": "ZMW",
"amount": "102"
}
, "condition": "bdbcf517cfc7e474392935781cc14043602e53dc2e8e8452826c5241dfd5e7ab"
}
end note
activate S1
S1-->D2:202 I'll get back to you
deactivate D2
S1->S1:OK, so this is an FX confirmation.
S1->S1: Does the requesting FSP have an account in the source currency?\nNo, it doesn't.
S1->S1: Find the transfer on which this conversion depends.
S1->S1: Liquidity check and reserve on debtor account for this transfer
note over S1
Reservations:
NBS_Bank has a reservation of 5250 MWK
FDH_FX has a reservation of 102 ZMW
end note
S1->FXP:Please confirm the currency conversion part of the transfer\n** POST /fxTransfers**
activate FXP
FXP-->S1:202 I'll get back to you
deactivate S1
FXP->FXP:Is all this OK?\nIf so, send the fulfilment back
FXP->S1:Confirmed. Here's the fulfilment
note over FXP
**PUT /fxTransfers/77c9d78d-c26a-4474-8b3c-99b96a814bfc**
{
"fulfilment": "188909ceb6cd5c35d5c6b394f0a9e5a0571199c332fbd013dc1e6b8a2d5fff42"
, "completedTimeStamp": "2021-08-25T14:17:08.175+01:00"
, "conversionState": "RESERVED"
}
end note
activate S1
S1-->FXP:200 Gotcha
deactivate FXP
S1->S1:Check fulfilment matches and cancel if not.
alt Conversion failed
S1->FXP:Sorry. Conversion failed
note over S1
**PATCH /fxTransfers/77c9d78d-c26a-4474-8b3c-99b96a814bfc**
{
"fulfilment": "188909ceb6cd5c35d5c6b394f0a9e5a0571199c332fbd013dc1e6b8a2d5fff42"
, "completedTimeStamp": "2021-08-25T14:17:08.175+01:00"
, "conversionState": "ABORTED"
}
end note
activate FXP
D2-->S1:200 Gotcha
FXP->FXP:Cancel any internal reservations
deactivate FXP
S1->S1:Cancel reservation for this conversion.
S1->D2:Sorry. Conversion failed.
note over S1
**PUT /fxTransfers/77c9d78d-c26a-4474-8b3c-99b96a814bfc/error**
{
"errorCode": "9999"
, "errorDescription": "Whatever the error was"
}
end note
activate D2
D2-->S1:200 Gotcha
deactivate S1
D2->S1:Cancel transfer
note over D2
**PUT /transfers/c720ae14-fc72-4acd-9113-8b601b34ba4d/error**
{
"errorCode": "9999"
, "errorDescription": "Whatever the error was"
}
end note
activate S1
S1-->D2:200 Gotcha
deactivate D2
S1->S1:Cancel reservation for this transfer.
S1->D1:Sorry. Conversion failed.
activate D1
D1-->S1:200 Gotcha
D1->A1:Sorry, your payment did not succeed.\nYou have not been charged for this payment.
deactivate D1
else Conversion succeeded
S1->D2:Conversion succeeded subject to transfer success\n**PUT /fxTransfers/77c9d78d-c26a-4474-8b3c-99b96a814bfc**
activate D2
D2-->S1:200 Gotcha
deactivate S1
D2->D2:Let me check that the terms of the transfer\nare the same as the ones I agreed to
D2->D2:Yes, they do. I approve the transfer
D2->A1:You have received a payment\nof 100 ZMW.\nYour new balance is 584 ZMW
A1-->D2:That's nice
D2->S1:Transfer is confirmed, here's the fulfilment
note over D2
**PUT /transfers/c720ae14-fc72-4acd-9113-8b601b34ba4d**
{
"fulfilment": "mhPUT9ZAwd-BXLfeSd7-YPh46rBWRNBiTCSWjpku90s"
, "completedTimestamp": "2021-08-25T14:17:08.227+01:00"
, "transferState": "COMMITTED"
}
end note
activate S1
S1-->D2:200 Gotcha
deactivate D2
S1->S1:
S1->S1:Is there a dependent transfer?\nYes, there is.
S1->S1:Is this dependency against the debtor party to the transfer?\nNo, it isn't.
S1->S1:Create an obligation from\nthe party named in the dependency (the FXP)\nto the creditor party
S1->S1:Is the transfer denominated in the currency of the amount?\nYes, it is.
S1->S1:Create an obligation from\nthe debtor party to\nthe party named in the dependency (the FXP)
S1->FXP:The transfer succeeded.\nYou can clear it in your ledgers
note over S1
**PATCH /fxTransfers/77c9d78d-c26a-4474-8b3c-99b96a814bfc**
{
"fulfilment": "2e6870fb4eda9c2a29ecf376ceb5b05c"
, "completedTimeStamp": "2021-08-25T14:17:08.175+01:00"
, "conversionState": "COMMITTED"
}
end note
activate FXP
FXP->FXP:Let's just check: does this match the stuff I sent?
FXP->FXP:It does. Great. I'll clear the conversion
FXP->S1:200 Gotcha
deactivate FXP
note over S1
Ledger positions:
NBS_Bank has a debit of 5250 MWK
FDH_FX has a credit of 5250 MWK
FDH_FX has a debit of 102 ZMW
Zoona has a credit of 102 ZMW
end note
S1->D1:Transfer is complete\n**PUT /transfers/c720ae14-fc72-4acd-9113-8b601b34ba4d**
activate D1
D1-->S1:200 Gotcha
deactivate S1
D1->D1:Commit the funds in my ledgers
D1->A1:Transfer was completed successfully
deactivate D1
end
@enduml