@t-0/provider-starter-ts 0.4.18 → 0.4.20
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
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.55",
|
|
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.55",
|
|
126
|
+
"resolved": "https://registry.npmjs.org/@t-0/provider-sdk/-/provider-sdk-1.0.55.tgz",
|
|
127
|
+
"integrity": "sha512-tGQANfMEkr0tOB3MGsTrWyrhcIRPcXGSXS3rSC38YBp1FNAbTZEBnMq9494YFLsIFo2w7zu7O3IXRiAMtgq5fg==",
|
|
128
128
|
"dependencies": {
|
|
129
129
|
"@bufbuild/protobuf": "^2.10.0",
|
|
130
130
|
"@connectrpc/connect": "^2.1.0",
|
package/template/package.json
CHANGED
|
@@ -2,24 +2,24 @@ import {type Client, NetworkService, PaymentMethodType, QuoteType} from "@t-0/pr
|
|
|
2
2
|
import {fromProtoDecimal, toProtoDecimal} from "./lib";
|
|
3
3
|
|
|
4
4
|
export default async function getQuote(networkClient: Client<typeof NetworkService>) {
|
|
5
|
-
const
|
|
5
|
+
const usdgbp = await networkClient.getQuote({
|
|
6
6
|
payOutCurrency: "GBP",
|
|
7
|
-
payOutMethod: PaymentMethodType.
|
|
7
|
+
payOutMethod: PaymentMethodType.SEPA,
|
|
8
8
|
quoteType: QuoteType.REALTIME,
|
|
9
9
|
amount: {
|
|
10
10
|
amount: {
|
|
11
11
|
case: 'payOutAmount',
|
|
12
|
-
value: toProtoDecimal(
|
|
12
|
+
value: toProtoDecimal(50, 0)
|
|
13
13
|
},
|
|
14
14
|
}
|
|
15
15
|
})
|
|
16
16
|
|
|
17
|
-
switch (
|
|
17
|
+
switch (usdgbp.result.case) {
|
|
18
18
|
case 'success':
|
|
19
|
-
console.log(`USD/GBP: ${fromProtoDecimal(
|
|
19
|
+
console.log(`USD/GBP: ${fromProtoDecimal(usdgbp.result.value.rate!)}`)
|
|
20
20
|
break;
|
|
21
21
|
case 'failure':
|
|
22
|
-
console.error(
|
|
22
|
+
console.error(usdgbp.result.value.reason)
|
|
23
23
|
break;
|
|
24
24
|
default:
|
|
25
25
|
console.error("unexpected result type")
|
package/template/src/service.ts
CHANGED
|
@@ -29,7 +29,7 @@ const CreateProviderService = (networkClient: Client<typeof NetworkService>) =>
|
|
|
29
29
|
// TODO: Step 2.4 implement how you do payouts (payments initiated by your counterparts)
|
|
30
30
|
console.log(`Received payout request ${req.paymentId}`)
|
|
31
31
|
|
|
32
|
-
//TODO:
|
|
32
|
+
// TODO: finalizePayout should be called when your system completes (or fails) the payout
|
|
33
33
|
setInterval(() => {
|
|
34
34
|
networkClient.finalizePayout({
|
|
35
35
|
paymentId: req.paymentId,
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import {type Client, NetworkService, PaymentMethodType} from "@t-0/provider-sdk";
|
|
2
2
|
import {toProtoDecimal} from "./lib";
|
|
3
|
+
import {randomUUID} from "node:crypto";
|
|
3
4
|
|
|
4
5
|
export default async function submitPayment(networkClient: Client<typeof NetworkService>): Promise<void> {
|
|
5
6
|
// TODO: Step 2.3 Test submitting payment to the system
|
|
6
7
|
const result = await networkClient.createPayment({
|
|
8
|
+
paymentClientId: randomUUID(),
|
|
9
|
+
// quoteId: specify quote id if you want a reliable USD/GBP rate
|
|
7
10
|
currency: 'GBP',
|
|
8
11
|
amount: {
|
|
9
12
|
amount: {
|