@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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@t-0/provider-starter-ts",
3
- "version": "0.4.18",
3
+ "version": "0.4.20",
4
4
  "description": "CLI tool to scaffold a Node.js t-0 Network integration service",
5
5
  "main": "dist/create.js",
6
6
  "bin": {
@@ -9,7 +9,7 @@
9
9
  "version": "1.0.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
- "@t-0/provider-sdk": "^1.0.54",
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.54",
126
- "resolved": "https://registry.npmjs.org/@t-0/provider-sdk/-/provider-sdk-1.0.54.tgz",
127
- "integrity": "sha512-qxkDdBYTYN2uWmwq5IN0o23phECwSkiDq8HdukJ3pDTkXSjeu3Bu4X07wlgEr9UKg3owEfEhDm32QAPZxJDI9Q==",
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",
@@ -12,7 +12,7 @@
12
12
  "author": "",
13
13
  "license": "MIT",
14
14
  "dependencies": {
15
- "@t-0/provider-sdk": "^1.0.54",
15
+ "@t-0/provider-sdk": "^1.0.55",
16
16
  "dotenv": "^16.3.1",
17
17
  "tiny-invariant": "^1.3.3"
18
18
  },
@@ -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 eurgbp = await networkClient.getQuote({
5
+ const usdgbp = await networkClient.getQuote({
6
6
  payOutCurrency: "GBP",
7
- payOutMethod: PaymentMethodType.SWIFT,
7
+ payOutMethod: PaymentMethodType.SEPA,
8
8
  quoteType: QuoteType.REALTIME,
9
9
  amount: {
10
10
  amount: {
11
11
  case: 'payOutAmount',
12
- value: toProtoDecimal(10, 0)
12
+ value: toProtoDecimal(50, 0)
13
13
  },
14
14
  }
15
15
  })
16
16
 
17
- switch (eurgbp.result.case) {
17
+ switch (usdgbp.result.case) {
18
18
  case 'success':
19
- console.log(`USD/GBP: ${fromProtoDecimal(eurgbp.result.value.rate!)}`)
19
+ console.log(`USD/GBP: ${fromProtoDecimal(usdgbp.result.value.rate!)}`)
20
20
  break;
21
21
  case 'failure':
22
- console.error(eurgbp.result.value.reason)
22
+ console.error(usdgbp.result.value.reason)
23
23
  break;
24
24
  default:
25
25
  console.error("unexpected result type")
@@ -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: confirmPayout should be called when you system notifies that payout has been made successfully
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: {