Skip to content

Commit c089ab1

Browse files
OlegDOvackca
andauthored
feat: ms payment payout (#38)
* fix: fixed webhook payment according to gateway changes * feat: add card funding type and is instant payout available * feat: is customer payout enabled flow * feat: update card required for payout data * feat: cleanup * feat: add balance interface * feat: add currency interface * feat: get balance endpoint * feat: compose balance helper * feat: update methods * feat: add instant payout validation * feat(http-requests): add examples * feat(permission): update stripe webhook allowed role * feat: add get payout method data helper * feat: ms payment workflow (#40) * refactor: method naming * feat: payment method webhook events handle * feat: store stripe connected account type * feat: get charging card query * feat: add account type for customer params * feat: update jsdocs * feat: cleanup * feat: compose balance tests * feat: cleanup * feat: customer crud tests * feat: transaction tests * feat: update permissions * feat: update conditions * feat: update models * feat: update restrictions (#42) --------- Co-authored-by: nackca <[email protected]>
1 parent 590fe5e commit c089ab1

File tree

24 files changed

+993
-140
lines changed

24 files changed

+993
-140
lines changed

http-requests/payment-stripe/requests.http

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
### Full account setup flow
2+
### Webhook token: webhookktokenoooooooooooooooooon
23
### Step 1. Create sender customer
34
POST http://127.0.0.1:8001/ms/payment-stripe
45
Accept: application/json
@@ -193,7 +194,7 @@ Content-Type: application/json
193194

194195
{
195196
"id": "1",
196-
"method": "stripe.connect-account",
197+
"method": "stripe.connect-account-link",
197198
"params": {
198199
"userId": "admif8f1-17f8-4501-9de2-a6e775ea39f3",
199200
"refreshUrl": "https://example.com",
@@ -215,3 +216,30 @@ Content-Type: application/json
215216
"applicationPaymentPercent": 3
216217
}
217218
}
219+
220+
### Get user stripe connect account balance
221+
POST http://127.0.0.1:8001/ms/payment-stripe
222+
Accept: application/json
223+
Content-Type: application/json
224+
225+
{
226+
"id": "1",
227+
"method": "stripe.balance",
228+
"params": {
229+
"userId": "admif8f1-17f8-4501-9de2-a6e775ea39f3"
230+
}
231+
}
232+
233+
### Create instant payout
234+
POST http://127.0.0.1:8001/ms/payment-stripe
235+
Accept: application/json
236+
Content-Type: application/json
237+
238+
{
239+
"id": "1",
240+
"method": "stripe.instant-payout",
241+
"params": {
242+
"userId": "admif8f1-17f8-4501-9de2-a6e775ea39f3",
243+
"amount": 100
244+
}
245+
}

microservices/authorization/migrations/permissions/list/conditions.json

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,5 +139,58 @@
139139
]
140140
},
141141
"createdAt": "2023-03-31T09:41:44.183Z"
142+
},
143+
{
144+
"title": "Payment-stripe: if exist in customers and myself",
145+
"conditions": {
146+
"or": [
147+
{
148+
"template": "<%= _.includes(roles, 'admin') %>"
149+
},
150+
{
151+
"requests": {
152+
"customer": {
153+
"method": "payment-stripe.customer.view",
154+
"params": {
155+
"query": {
156+
"where": {
157+
"userId": "<%= _.get(payload, 'authentication.userId') %>"
158+
}
159+
}
160+
}
161+
}
162+
},
163+
"template": "<%= !_.isEmpty(_.get(customer, 'entity')) && _.get(reqParams, 'userId') === _.get(payload, 'authentication.userId') %>"
164+
}
165+
]
166+
},
167+
"createdAt": "2022-06-20T09:41:44.183Z"
168+
},
169+
{
170+
"title": "Payment-stripe: refund",
171+
"conditions": {
172+
"or": [
173+
{
174+
"template": "<%= _.includes(roles, 'admin') %>"
175+
},
176+
{
177+
"requests": {
178+
"transaction": {
179+
"method": "payment-stripe.transaction.view",
180+
"params": {
181+
"query": {
182+
"where": {
183+
"transactionId": "<%= _.get(reqParams, 'transactionId') %>",
184+
"type": "debit"
185+
}
186+
}
187+
}
188+
}
189+
},
190+
"template": "<%= _.get(transaction, 'entity.userId') === _.get(payload, 'authentication.userId') && _.get(transaction, 'entity.status') === 'success' %>"
191+
}
192+
]
193+
},
194+
"createdAt": "2022-06-20T09:41:44.183Z"
142195
}
143196
]

microservices/authorization/migrations/permissions/list/methods/payment-stripe.json

Lines changed: 96 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"method": "stripe.webhook",
5151
"description": "Get stripe webhooks handler",
5252
"allowGroup": [
53-
"admin"
53+
"webhook"
5454
],
5555
"denyGroup": [],
5656
"createdAt": "2023-05-26T15:12:57.976Z",
@@ -89,13 +89,20 @@
8989
"method": "bank-account.list",
9090
"description": "Returns list of BankAccount by given condition",
9191
"allowGroup": [
92-
"admin"
92+
"user"
9393
],
9494
"denyGroup": [],
9595
"createdAt": "2023-05-26T15:12:57.976Z",
9696
"modelIn": "ListRequestParams",
9797
"modelOut": "payment-stripe.ListOutputParams.8f41f4d656756a40d24eaed65ae77f97",
98-
"methodFilters": []
98+
"methodFilters": [
99+
{
100+
"filterTitle": "By userId",
101+
"operator": "and",
102+
"roleAlias": "guest",
103+
"createdAt": "2022-03-15T06:17:23.698Z"
104+
}
105+
]
99106
},
100107
{
101108
"microservice": "payment-stripe",
@@ -218,13 +225,20 @@
218225
"method": "bank-account.view",
219226
"description": "Returns BankAccount by given condition",
220227
"allowGroup": [
221-
"admin"
228+
"user"
222229
],
223230
"denyGroup": [],
224231
"createdAt": "2023-05-26T15:12:57.976Z",
225232
"modelIn": "ViewRequestParams",
226233
"modelOut": "payment-stripe.ViewOutputParams.6acc04786eedd28356976dfd5cad3ec3",
227-
"methodFilters": []
234+
"methodFilters": [
235+
{
236+
"filterTitle": "By userId",
237+
"operator": "and",
238+
"roleAlias": "guest",
239+
"createdAt": "2022-03-15T06:17:23.698Z"
240+
}
241+
]
228242
},
229243
{
230244
"microservice": "payment-stripe",
@@ -244,13 +258,20 @@
244258
"method": "transaction.list",
245259
"description": "Returns list of Transaction by given condition",
246260
"allowGroup": [
247-
"admin"
261+
"user"
248262
],
249263
"denyGroup": [],
250264
"createdAt": "2023-05-26T15:12:57.976Z",
251265
"modelIn": "ListRequestParams",
252266
"modelOut": "payment-stripe.ListOutputParams.ab8bbade2b229df1cce267b8a3de985f",
253-
"methodFilters": []
267+
"methodFilters": [
268+
{
269+
"filterTitle": "By userId",
270+
"operator": "and",
271+
"roleAlias": "guest",
272+
"createdAt": "2022-03-15T06:17:23.698Z"
273+
}
274+
]
254275
},
255276
{
256277
"microservice": "payment-stripe",
@@ -270,13 +291,20 @@
270291
"method": "card.list",
271292
"description": "Returns list of Card by given condition",
272293
"allowGroup": [
273-
"admin"
294+
"user"
274295
],
275296
"denyGroup": [],
276297
"createdAt": "2023-05-26T15:12:57.976Z",
277298
"modelIn": "ListRequestParams",
278299
"modelOut": "payment-stripe.ListOutputParams.bb3225128bd0a5c1d6c51e6f2668d280",
279-
"methodFilters": []
300+
"methodFilters": [
301+
{
302+
"filterTitle": "By userId",
303+
"operator": "and",
304+
"roleAlias": "guest",
305+
"createdAt": "2022-03-15T06:17:23.698Z"
306+
}
307+
]
280308
},
281309
{
282310
"microservice": "payment-stripe",
@@ -289,20 +317,28 @@
289317
"createdAt": "2023-05-26T15:12:57.976Z",
290318
"modelIn": "payment-stripe.SetupIntentInput",
291319
"modelOut": "payment-stripe.SetupIntentOutput",
320+
"conditions": "Payment-stripe: if exist in customers and myself",
292321
"methodFilters": []
293322
},
294323
{
295324
"microservice": "payment-stripe",
296325
"method": "bank-account.count",
297326
"description": "Returns count of BankAccount by given condition",
298327
"allowGroup": [
299-
"admin"
328+
"user"
300329
],
301330
"denyGroup": [],
302331
"createdAt": "2023-05-26T15:12:57.976Z",
303332
"modelIn": "CountRequestParams",
304333
"modelOut": "CountOutputParams",
305-
"methodFilters": []
334+
"methodFilters": [
335+
{
336+
"filterTitle": "By userId",
337+
"operator": "and",
338+
"roleAlias": "guest",
339+
"createdAt": "2022-03-15T06:17:23.698Z"
340+
}
341+
]
306342
},
307343
{
308344
"microservice": "payment-stripe",
@@ -381,20 +417,27 @@
381417
"method": "transaction.count",
382418
"description": "Returns count of Transaction by given condition",
383419
"allowGroup": [
384-
"admin"
420+
"user"
385421
],
386422
"denyGroup": [],
387423
"createdAt": "2023-05-26T15:12:57.976Z",
388424
"modelIn": "CountRequestParams",
389425
"modelOut": "CountOutputParams",
390-
"methodFilters": []
426+
"methodFilters": [
427+
{
428+
"filterTitle": "By userId",
429+
"operator": "and",
430+
"roleAlias": "guest",
431+
"createdAt": "2022-03-15T06:17:23.698Z"
432+
}
433+
]
391434
},
392435
{
393436
"microservice": "payment-stripe",
394437
"method": "stripe.payment-intent-fees",
395438
"description": "Returns calculated fees for payment intent",
396439
"allowGroup": [
397-
"admin"
440+
"guest"
398441
],
399442
"denyGroup": [],
400443
"createdAt": "2023-05-26T15:12:57.976Z",
@@ -497,26 +540,34 @@
497540
"method": "stripe.refund",
498541
"description": "Create transaction refund",
499542
"allowGroup": [
500-
"admin"
543+
"user"
501544
],
502545
"denyGroup": [],
503546
"createdAt": "2023-05-26T15:12:57.976Z",
504547
"modelIn": "payment-stripe.RefundInput",
505548
"modelOut": "payment-stripe.RefundOutput",
549+
"condition": "Payment-stripe: refund",
506550
"methodFilters": []
507551
},
508552
{
509553
"microservice": "payment-stripe",
510554
"method": "card.view",
511555
"description": "Returns Card by given condition",
512556
"allowGroup": [
513-
"admin"
557+
"user"
514558
],
515559
"denyGroup": [],
516560
"createdAt": "2023-05-26T15:12:57.976Z",
517561
"modelIn": "ViewRequestParams",
518562
"modelOut": "payment-stripe.ViewOutputParams.42c9fcbd79b41712464c2f718e4b31d1",
519-
"methodFilters": []
563+
"methodFilters": [
564+
{
565+
"filterTitle": "By userId",
566+
"operator": "and",
567+
"roleAlias": "guest",
568+
"createdAt": "2022-03-15T06:17:23.698Z"
569+
}
570+
]
520571
},
521572
{
522573
"microservice": "payment-stripe",
@@ -568,45 +619,67 @@
568619
"createdAt": "2023-05-26T15:12:57.976Z",
569620
"modelIn": "payment-stripe.ConnectAccountLinkInput",
570621
"modelOut": "payment-stripe.ConnectAccountLinkOutput",
571-
"methodFilters": []
622+
"methodFilters": [
623+
{
624+
"filterTitle": "By userId",
625+
"operator": "and",
626+
"roleAlias": "guest",
627+
"createdAt": "2022-03-15T06:17:23.698Z"
628+
}
629+
]
572630
},
573631
{
574632
"microservice": "payment-stripe",
575633
"method": "transaction.view",
576634
"description": "Returns Transaction by given condition",
577635
"allowGroup": [
578-
"admin"
636+
"user"
579637
],
580638
"denyGroup": [],
581639
"createdAt": "2023-05-26T15:12:57.976Z",
582640
"modelIn": "ViewRequestParams",
583641
"modelOut": "payment-stripe.ViewOutputParams.6dee9dddb2a4fce8a6c8ac5fc7881f25",
584-
"methodFilters": []
642+
"methodFilters": [
643+
{
644+
"filterTitle": "By userId",
645+
"operator": "and",
646+
"roleAlias": "guest",
647+
"createdAt": "2022-03-15T06:17:23.698Z"
648+
}
649+
]
585650
},
586651
{
587652
"microservice": "payment-stripe",
588653
"method": "card.count",
589654
"description": "Returns count of Card by given condition",
590655
"allowGroup": [
591-
"admin"
656+
"user"
592657
],
593658
"denyGroup": [],
594659
"createdAt": "2023-05-26T15:12:57.976Z",
595660
"modelIn": "CountRequestParams",
596661
"modelOut": "CountOutputParams",
597-
"methodFilters": []
662+
"methodFilters": [
663+
{
664+
"filterTitle": "By userId",
665+
"operator": "and",
666+
"roleAlias": "guest",
667+
"createdAt": "2022-03-15T06:17:23.698Z"
668+
}
669+
]
598670
},
599671
{
600672
"microservice": "payment-stripe",
601673
"method": "stripe.connect-account",
602674
"description": "Create new connected account with link",
603675
"allowGroup": [
604-
"admin"
676+
"user"
605677
],
606678
"denyGroup": [],
607679
"createdAt": "2023-05-26T15:12:57.976Z",
608680
"modelIn": "payment-stripe.ConnectAccountInput",
609681
"modelOut": "payment-stripe.ConnectAccountOutput",
682+
"condition": "Payment-stripe: if exist in customers and myself",
610683
"methodFilters": []
611684
},
612685
{

0 commit comments

Comments
 (0)