@t-0/provider-starter-ts 0.4.9 → 0.4.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/template/package-lock.json +4 -4
- package/template/package.json +1 -1
- package/template/src/service.ts +57 -43
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"version": "1.0.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@t-0/provider-sdk": "1.0.
|
|
12
|
+
"@t-0/provider-sdk": "^1.0.50",
|
|
13
13
|
"dotenv": "^16.3.1",
|
|
14
14
|
"tiny-invariant": "^1.3.3"
|
|
15
15
|
},
|
|
@@ -122,9 +122,9 @@
|
|
|
122
122
|
}
|
|
123
123
|
},
|
|
124
124
|
"node_modules/@t-0/provider-sdk": {
|
|
125
|
-
"version": "1.0.
|
|
126
|
-
"resolved": "https://registry.npmjs.org/@t-0/provider-sdk/-/provider-sdk-1.0.
|
|
127
|
-
"integrity": "sha512-
|
|
125
|
+
"version": "1.0.50",
|
|
126
|
+
"resolved": "https://registry.npmjs.org/@t-0/provider-sdk/-/provider-sdk-1.0.50.tgz",
|
|
127
|
+
"integrity": "sha512-8Lb2mqGBB9aOOpocbXNql6dWBCl7iuqSU/o49E1qXtvuzUwzer3hu5QqKg6YBAegH/RU5VjbzNwQHz1Pu2svlg==",
|
|
128
128
|
"dependencies": {
|
|
129
129
|
"@bufbuild/protobuf": "^2.10.0",
|
|
130
130
|
"@connectrpc/connect": "^2.1.0",
|
package/template/package.json
CHANGED
package/template/src/service.ts
CHANGED
|
@@ -1,58 +1,72 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
AppendLedgerEntriesRequest,
|
|
3
|
+
AppendLedgerEntriesResponse,
|
|
4
|
+
ApprovePaymentQuoteRequest,
|
|
5
|
+
ApprovePaymentQuoteResponse,
|
|
6
|
+
type Client,
|
|
7
|
+
HandlerContext,
|
|
8
|
+
NetworkService,
|
|
9
|
+
PayoutRequest,
|
|
10
|
+
PayoutResponse,
|
|
11
|
+
UpdateLimitRequest,
|
|
12
|
+
UpdateLimitResponse,
|
|
13
|
+
UpdatePaymentRequest,
|
|
14
|
+
UpdatePaymentResponse,
|
|
11
15
|
} from "@t-0/provider-sdk";
|
|
12
16
|
|
|
13
17
|
/*
|
|
14
18
|
Please refer to docs, proto definition comments or source code comments to understand purpose of fields
|
|
15
19
|
*/
|
|
16
20
|
const CreateProviderService = (networkClient: Client<typeof NetworkService>) => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
return {
|
|
22
|
+
async updatePayment(req: UpdatePaymentRequest, _: HandlerContext) {
|
|
23
|
+
// TODO: Step 2.1 implement how you handle updates of payment initiated by you
|
|
24
|
+
console.log(`Received payment update for ${req.paymentId}, payment ${req.result.case}`)
|
|
25
|
+
return {} as UpdatePaymentResponse
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
async payOut(req: PayoutRequest, _: HandlerContext) {
|
|
29
|
+
// TODO: Step 2.4 implement how you do payouts (payments initiated by your counterparts)
|
|
30
|
+
console.log(`Received payout request ${req.payoutId}`)
|
|
23
31
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
32
|
+
//TODO: confirmPayout should be called when you system notifies that payout has been made successfully
|
|
33
|
+
setInterval(() => {
|
|
34
|
+
networkClient.confirmPayout({
|
|
35
|
+
paymentId: req.paymentId,
|
|
36
|
+
payoutId: req.payoutId,
|
|
37
|
+
})
|
|
38
|
+
}, 2000);
|
|
39
|
+
return {
|
|
40
|
+
result: {
|
|
41
|
+
case: "accepted",
|
|
42
|
+
value: {},
|
|
43
|
+
},
|
|
44
|
+
} as PayoutResponse
|
|
45
|
+
},
|
|
27
46
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
payoutId: req.payoutId,
|
|
33
|
-
})
|
|
34
|
-
}, 2000);
|
|
35
|
-
return {
|
|
36
|
-
result: {
|
|
37
|
-
case: "accepted",
|
|
38
|
-
value: {},
|
|
47
|
+
async updateLimit(req: UpdateLimitRequest, _: HandlerContext) {
|
|
48
|
+
// TODO: optionally implement updates on your limits and limits usage
|
|
49
|
+
console.log(`Received update of limits with provider ${req.limits[0].counterpartId}`)
|
|
50
|
+
return {} as UpdateLimitResponse
|
|
39
51
|
},
|
|
40
|
-
} as PayoutResponse
|
|
41
|
-
},
|
|
42
52
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
53
|
+
async appendLedgerEntries(req: AppendLedgerEntriesRequest, _: HandlerContext) {
|
|
54
|
+
// TODO: optionally implement handling of new ledger transactions and new ledger entries
|
|
55
|
+
console.log(`Received ledger entries for ${req.transactions} transaction(s)`)
|
|
56
|
+
return {} as AppendLedgerEntriesResponse
|
|
57
|
+
},
|
|
48
58
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
59
|
+
async approvePaymentQuote(req: ApprovePaymentQuoteRequest, _: HandlerContext) {
|
|
60
|
+
// TODO: when the payment goes through the Manual AML Check on the pay-out provider side, the provider submitted the payment will have a last look to approve final quote
|
|
61
|
+
console.log(`Received approve payment quote request for ${req.paymentId}`)
|
|
62
|
+
return {
|
|
63
|
+
result: {
|
|
64
|
+
case: "accepted",
|
|
65
|
+
value: {}
|
|
66
|
+
}
|
|
67
|
+
} as ApprovePaymentQuoteResponse
|
|
68
|
+
}
|
|
69
|
+
}
|
|
56
70
|
};
|
|
57
71
|
|
|
58
72
|
export default CreateProviderService;
|