@temboplus/afloat 0.2.1-beta.2 → 0.2.1-beta.3
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/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/modules/beneficiary/beneficiary-info.model.d.ts +20 -12
- package/dist/modules/beneficiary/beneficiary.dtos.d.ts +4 -4
- package/dist/modules/beneficiary/beneficiary.model.d.ts +1 -1
- package/dist/modules/payout/payout-channel-handler.d.ts +119 -53
- package/dist/modules/payout/payout.api-contract.d.ts +3 -3
- package/dist/modules/payout/payout.dtos.d.ts +18 -10
- package/dist/modules/payout/payout.query.d.ts +1 -1
- package/dist/modules/payout/payout.repository.d.ts +7 -6
- package/package.json +1 -1
|
@@ -5,40 +5,40 @@ import { Bank, PhoneNumber } from "@temboplus/frontend-core";
|
|
|
5
5
|
import type { BankSwiftCode, ISO2CountryCode, MobileMoneyProvider, MobileMoneyProviderId } from "@temboplus/frontend-core";
|
|
6
6
|
import { z } from "zod";
|
|
7
7
|
export declare const MobileBeneficiaryJSONSchema: z.ZodObject<{
|
|
8
|
-
type: z.ZodLiteral<BeneficiaryType.
|
|
8
|
+
type: z.ZodLiteral<BeneficiaryType.MOBILE>;
|
|
9
9
|
name: z.ZodString;
|
|
10
10
|
phoneNumber: z.ZodString;
|
|
11
11
|
mnoId: z.ZodUnion<[z.ZodEnum<["VODACOM", "AIRTEL", "TIGO", "HALOTEL"]>, z.ZodEnum<["SAFARICOM"]>]>;
|
|
12
12
|
_version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
13
13
|
}, "strip", z.ZodTypeAny, {
|
|
14
|
-
type: BeneficiaryType.
|
|
14
|
+
type: BeneficiaryType.MOBILE;
|
|
15
15
|
name: string;
|
|
16
16
|
_version: string;
|
|
17
17
|
phoneNumber: string;
|
|
18
18
|
mnoId: "VODACOM" | "AIRTEL" | "TIGO" | "HALOTEL" | "SAFARICOM";
|
|
19
19
|
}, {
|
|
20
|
-
type: BeneficiaryType.
|
|
20
|
+
type: BeneficiaryType.MOBILE;
|
|
21
21
|
name: string;
|
|
22
22
|
phoneNumber: string;
|
|
23
23
|
mnoId: "VODACOM" | "AIRTEL" | "TIGO" | "HALOTEL" | "SAFARICOM";
|
|
24
24
|
_version?: string | undefined;
|
|
25
25
|
}>;
|
|
26
26
|
export declare const BankBeneficiaryJSONSchema: z.ZodObject<{
|
|
27
|
-
type: z.ZodLiteral<BeneficiaryType.
|
|
27
|
+
type: z.ZodLiteral<BeneficiaryType.BANK>;
|
|
28
28
|
accName: z.ZodString;
|
|
29
29
|
swiftCode: z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodString, string, string>]>;
|
|
30
30
|
countryCode: z.ZodEffects<z.ZodString, string, string>;
|
|
31
31
|
accNo: z.ZodString;
|
|
32
32
|
_version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
33
33
|
}, "strip", z.ZodTypeAny, {
|
|
34
|
-
type: BeneficiaryType.
|
|
34
|
+
type: BeneficiaryType.BANK;
|
|
35
35
|
_version: string;
|
|
36
36
|
countryCode: string;
|
|
37
37
|
accName: string;
|
|
38
38
|
swiftCode: string;
|
|
39
39
|
accNo: string;
|
|
40
40
|
}, {
|
|
41
|
-
type: BeneficiaryType.
|
|
41
|
+
type: BeneficiaryType.BANK;
|
|
42
42
|
countryCode: string;
|
|
43
43
|
accName: string;
|
|
44
44
|
swiftCode: string;
|
|
@@ -46,39 +46,39 @@ export declare const BankBeneficiaryJSONSchema: z.ZodObject<{
|
|
|
46
46
|
_version?: string | undefined;
|
|
47
47
|
}>;
|
|
48
48
|
export declare const BeneficiaryJSONSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
49
|
-
type: z.ZodLiteral<BeneficiaryType.
|
|
49
|
+
type: z.ZodLiteral<BeneficiaryType.MOBILE>;
|
|
50
50
|
name: z.ZodString;
|
|
51
51
|
phoneNumber: z.ZodString;
|
|
52
52
|
mnoId: z.ZodUnion<[z.ZodEnum<["VODACOM", "AIRTEL", "TIGO", "HALOTEL"]>, z.ZodEnum<["SAFARICOM"]>]>;
|
|
53
53
|
_version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
54
54
|
}, "strip", z.ZodTypeAny, {
|
|
55
|
-
type: BeneficiaryType.
|
|
55
|
+
type: BeneficiaryType.MOBILE;
|
|
56
56
|
name: string;
|
|
57
57
|
_version: string;
|
|
58
58
|
phoneNumber: string;
|
|
59
59
|
mnoId: "VODACOM" | "AIRTEL" | "TIGO" | "HALOTEL" | "SAFARICOM";
|
|
60
60
|
}, {
|
|
61
|
-
type: BeneficiaryType.
|
|
61
|
+
type: BeneficiaryType.MOBILE;
|
|
62
62
|
name: string;
|
|
63
63
|
phoneNumber: string;
|
|
64
64
|
mnoId: "VODACOM" | "AIRTEL" | "TIGO" | "HALOTEL" | "SAFARICOM";
|
|
65
65
|
_version?: string | undefined;
|
|
66
66
|
}>, z.ZodObject<{
|
|
67
|
-
type: z.ZodLiteral<BeneficiaryType.
|
|
67
|
+
type: z.ZodLiteral<BeneficiaryType.BANK>;
|
|
68
68
|
accName: z.ZodString;
|
|
69
69
|
swiftCode: z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodString, string, string>]>;
|
|
70
70
|
countryCode: z.ZodEffects<z.ZodString, string, string>;
|
|
71
71
|
accNo: z.ZodString;
|
|
72
72
|
_version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
73
73
|
}, "strip", z.ZodTypeAny, {
|
|
74
|
-
type: BeneficiaryType.
|
|
74
|
+
type: BeneficiaryType.BANK;
|
|
75
75
|
_version: string;
|
|
76
76
|
countryCode: string;
|
|
77
77
|
accName: string;
|
|
78
78
|
swiftCode: string;
|
|
79
79
|
accNo: string;
|
|
80
80
|
}, {
|
|
81
|
-
type: BeneficiaryType.
|
|
81
|
+
type: BeneficiaryType.BANK;
|
|
82
82
|
countryCode: string;
|
|
83
83
|
accName: string;
|
|
84
84
|
swiftCode: string;
|
|
@@ -145,6 +145,14 @@ export declare class MobileBeneficiaryInfo extends BaseBeneficiary {
|
|
|
145
145
|
private static checkInputs;
|
|
146
146
|
/** Picks an MNO from a DTO `channel` field, or auto-detects when supported. */
|
|
147
147
|
private static pickMnoIdFromDTO;
|
|
148
|
+
/**
|
|
149
|
+
* Extracts a mobile provider id from an upstream payout channel code.
|
|
150
|
+
*
|
|
151
|
+
* @param countryCode - Beneficiary phone country code.
|
|
152
|
+
* @param channel - Candidate channel value from a beneficiary or payout DTO.
|
|
153
|
+
* @returns The provider id encoded in a mobile B2C channel, or `undefined` when the value is not a mobile channel.
|
|
154
|
+
*/
|
|
155
|
+
private static pickMnoIdFromPayoutChannel;
|
|
148
156
|
static from(data: {
|
|
149
157
|
name: string;
|
|
150
158
|
phoneNumber: PhoneNumber;
|
|
@@ -4,14 +4,14 @@ import { z } from "zod";
|
|
|
4
4
|
*
|
|
5
5
|
* @remarks
|
|
6
6
|
* Currently supports two channel types:
|
|
7
|
-
* - "Bank": For traditional banking
|
|
8
|
-
* - "Mobile": For mobile money
|
|
7
|
+
* - "Bank": For traditional banking beneficiaries
|
|
8
|
+
* - "Mobile": For mobile money beneficiaries
|
|
9
9
|
*
|
|
10
10
|
* @see {@link BeneficiaryType} for the inferred type
|
|
11
11
|
*/
|
|
12
12
|
export declare enum BeneficiaryType {
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
BANK = "Bank",
|
|
14
|
+
MOBILE = "Mobile"
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
* Type representing user-provided beneficiary information.
|
|
@@ -1,83 +1,149 @@
|
|
|
1
1
|
import { Wallet } from "@/modules/wallet/wallet.model.js";
|
|
2
|
-
import { Amount, PhoneNumber } from "@temboplus/frontend-core";
|
|
2
|
+
import { Amount, ChannelType, PhoneNumber } from "@temboplus/frontend-core";
|
|
3
3
|
import type { ISO2CountryCode, MobileMoneyProviderId } from "@temboplus/frontend-core";
|
|
4
4
|
import { PayoutChannel, PayoutInputDTO } from "./payout.dtos.js";
|
|
5
5
|
import { BankBeneficiaryInfo, BeneficiaryInfo } from "../beneficiary/beneficiary-info.model.js";
|
|
6
|
+
export type PayoutChannelCode = PayoutChannel;
|
|
6
7
|
/**
|
|
7
|
-
*
|
|
8
|
+
* Resolves the upstream payout channel owned by the library.
|
|
8
9
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* - `${countryCode}-${telecom}-B2C`: Pattern for mobile money transfers where the telecom company is the provider code
|
|
12
|
-
*
|
|
13
|
-
* @see {@link PayoutChannelCodeFactory} for functions to generate valid codes
|
|
14
|
-
*/
|
|
15
|
-
export type PayoutChannelCode = `${ISO2CountryCode}-${string}-B2C`;
|
|
16
|
-
/**
|
|
17
|
-
* Factory for creating standardized payout channel codes
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* ```ts
|
|
21
|
-
* // Create bank channel code
|
|
22
|
-
* const bankCode = PayoutChannelCodeFactory.forBank(bankContactInfo, wallet); // Returns "TZ-BANK-B2C"
|
|
23
|
-
*
|
|
24
|
-
* // Create mobile channel code
|
|
25
|
-
* const mobileCode = PayoutChannelCodeFactory.forMobile(phoneNumber, mnoId, wallet); // Returns "TZ-VODACOM-B2C" for Vodacom number
|
|
26
|
-
* ```
|
|
10
|
+
* Consumers provide wallet, beneficiary, and amount details only. This resolver
|
|
11
|
+
* applies Tembo routing rules and returns the concrete upstream B2C channel.
|
|
27
12
|
*/
|
|
28
|
-
declare class
|
|
13
|
+
export declare class PayoutChannelResolver {
|
|
14
|
+
/**
|
|
15
|
+
* Resolves the upstream payout channel for a payout.
|
|
16
|
+
*
|
|
17
|
+
* @param args - Payout routing inputs.
|
|
18
|
+
* @param args.wallet - Wallet paying out; its country and currency define the corridor.
|
|
19
|
+
* @param args.receiver - Beneficiary receiving the payout.
|
|
20
|
+
* @param args.amount - Amount being paid out; its currency must match the wallet/country.
|
|
21
|
+
* @returns The concrete upstream channel code to send to the payout API.
|
|
22
|
+
* @throws Error when wallet, receiver, amount, or supported-country details are incompatible.
|
|
23
|
+
*/
|
|
24
|
+
static resolve(args: {
|
|
25
|
+
wallet: Wallet;
|
|
26
|
+
receiver: BeneficiaryInfo;
|
|
27
|
+
amount: Amount;
|
|
28
|
+
}): PayoutChannel;
|
|
29
|
+
/**
|
|
30
|
+
* Resolves a bank beneficiary to the upstream bank payout channel.
|
|
31
|
+
*
|
|
32
|
+
* @param receiver - Valid bank beneficiary details containing bank and account information.
|
|
33
|
+
* @param wallet - Wallet paying out; its country must match the beneficiary country.
|
|
34
|
+
* @returns `TZ-BANK-B2C` or `KE-BANK-B2C`.
|
|
35
|
+
* @throws Error when the beneficiary is invalid, unsupported, or in a different country from the wallet.
|
|
36
|
+
*/
|
|
37
|
+
static forBank(receiver: BankBeneficiaryInfo, wallet: Wallet): PayoutChannel;
|
|
38
|
+
/**
|
|
39
|
+
* Resolves a mobile money beneficiary to the upstream mobile payout channel.
|
|
40
|
+
*
|
|
41
|
+
* Routing rules:
|
|
42
|
+
* - All Kenya mobile money payouts route through `KE-SAFARICOM-B2C`.
|
|
43
|
+
* - Tanzania Vodacom mobile numbers route through `TZ-TIGO-B2C`.
|
|
44
|
+
* - Tanzania Tigo, Airtel, and Halotel route through their matching upstream channels.
|
|
45
|
+
*
|
|
46
|
+
* @param phoneNumber - Parsed mobile beneficiary phone number.
|
|
47
|
+
* @param mnoId - Beneficiary mobile money provider id.
|
|
48
|
+
* @param wallet - Wallet paying out; its country must match the phone number country.
|
|
49
|
+
* @returns The concrete upstream mobile money payout channel.
|
|
50
|
+
* @throws Error when the phone, provider, country, or wallet corridor is invalid or unsupported.
|
|
51
|
+
*/
|
|
52
|
+
static forMobile(phoneNumber: PhoneNumber, mnoId: MobileMoneyProviderId, wallet: Wallet): PayoutChannel;
|
|
53
|
+
/**
|
|
54
|
+
* Converts a concrete payout channel into the generic coverage channel type.
|
|
55
|
+
*
|
|
56
|
+
* @param channel - Concrete upstream payout channel.
|
|
57
|
+
* @returns `ChannelType.BANK` for bank channels; otherwise `ChannelType.MOBILE_MONEY`.
|
|
58
|
+
*/
|
|
59
|
+
static getChannelType(channel: PayoutChannel): ChannelType;
|
|
60
|
+
/**
|
|
61
|
+
* Extracts the country code prefix from a payout channel.
|
|
62
|
+
*
|
|
63
|
+
* @param channel - Concrete upstream payout channel.
|
|
64
|
+
* @returns ISO-2 country code embedded in the channel.
|
|
65
|
+
*/
|
|
66
|
+
static getCountryCode(channel: PayoutChannel): ISO2CountryCode;
|
|
67
|
+
/**
|
|
68
|
+
* Extracts the mobile provider segment from a mobile payout channel.
|
|
69
|
+
*
|
|
70
|
+
* @param channel - Concrete upstream payout channel.
|
|
71
|
+
* @returns Provider id for mobile money channels; `undefined` for bank channels.
|
|
72
|
+
*/
|
|
73
|
+
static getProviderId(channel: PayoutChannel): MobileMoneyProviderId | undefined;
|
|
74
|
+
/**
|
|
75
|
+
* Checks whether a concrete payout channel is a bank channel.
|
|
76
|
+
*
|
|
77
|
+
* @param channel - Concrete upstream payout channel.
|
|
78
|
+
* @returns `true` for `*-BANK-B2C` channels; otherwise `false`.
|
|
79
|
+
*/
|
|
80
|
+
static isBankChannel(channel: PayoutChannel): boolean;
|
|
29
81
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* @
|
|
82
|
+
* Checks whether a concrete payout channel is a mobile money channel.
|
|
83
|
+
*
|
|
84
|
+
* @param channel - Concrete upstream payout channel.
|
|
85
|
+
* @returns `true` for mobile money channels; otherwise `false`.
|
|
33
86
|
*/
|
|
34
|
-
static
|
|
87
|
+
static isMobileMoneyChannel(channel: PayoutChannel): boolean;
|
|
35
88
|
/**
|
|
36
|
-
*
|
|
37
|
-
* @param phoneNumber - Phone number object containing telecom information
|
|
38
|
-
* @returns {PayoutChannelCode} Channel code in format "TZ-{TELECOM}-B2C"
|
|
39
|
-
* @throws {Error} If phone number is invalid or country is not supported
|
|
89
|
+
* Ensures the payout is internally consistent before resolving a channel.
|
|
40
90
|
*
|
|
41
|
-
* @
|
|
91
|
+
* @param wallet - Wallet paying out.
|
|
92
|
+
* @param receiver - Beneficiary receiving the payout.
|
|
93
|
+
* @param amount - Amount being paid out.
|
|
94
|
+
* @returns Nothing when validation passes.
|
|
95
|
+
* @throws Error when wallet country, receiver country, wallet currency, or amount currency do not align.
|
|
42
96
|
*/
|
|
43
|
-
static
|
|
97
|
+
private static assertCompatibleWalletReceiverAndAmount;
|
|
44
98
|
}
|
|
45
99
|
/**
|
|
46
|
-
*
|
|
100
|
+
* Builds the upstream payout API body from domain models.
|
|
47
101
|
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* const factory = new PayoutInputFactory();
|
|
51
|
-
* const payoutInput = factory.getPayoutInput({
|
|
52
|
-
* channel: PayoutChannel.MOBILE,
|
|
53
|
-
* receiver: mobileContactInfo,
|
|
54
|
-
* amount: new Amount(1000),
|
|
55
|
-
* notes: "Payment for services"
|
|
56
|
-
* }, wallet);
|
|
57
|
-
* ```
|
|
102
|
+
* The factory owns channel resolution; callers provide only wallet, receiver,
|
|
103
|
+
* amount, and optional notes.
|
|
58
104
|
*/
|
|
59
105
|
export declare class PayoutInputFactory {
|
|
60
|
-
private readonly handlers;
|
|
61
106
|
/**
|
|
62
|
-
* Creates
|
|
107
|
+
* Creates the DTO expected by the upstream payout API.
|
|
63
108
|
*
|
|
64
|
-
* @param args -
|
|
65
|
-
* @
|
|
66
|
-
* @
|
|
109
|
+
* @param args - Payout input fields controlled by the consumer.
|
|
110
|
+
* @param args.receiver - Beneficiary receiving the payout.
|
|
111
|
+
* @param args.amount - Amount to pay out.
|
|
112
|
+
* @param args.notes - Optional note used as narration when present.
|
|
113
|
+
* @param wallet - Wallet paying out.
|
|
114
|
+
* @returns Complete payout API input including the library-resolved channel.
|
|
115
|
+
* @throws Error when the receiver cannot be routed or validation fails.
|
|
67
116
|
*/
|
|
68
117
|
getPayoutInput(args: {
|
|
69
|
-
channel: PayoutChannel;
|
|
70
118
|
receiver: BeneficiaryInfo;
|
|
71
119
|
amount: Amount;
|
|
72
120
|
notes?: string;
|
|
73
121
|
}, wallet: Wallet): PayoutInputDTO;
|
|
122
|
+
/**
|
|
123
|
+
* Builds the upstream payout DTO for a mobile money beneficiary.
|
|
124
|
+
*
|
|
125
|
+
* @param receiver - Valid mobile beneficiary.
|
|
126
|
+
* @param amount - Amount to pay out.
|
|
127
|
+
* @param channel - Resolved upstream mobile money payout channel.
|
|
128
|
+
* @param notes - Optional note used as narration when present.
|
|
129
|
+
* @returns Complete mobile money payout API input.
|
|
130
|
+
*/
|
|
131
|
+
private createMobileInput;
|
|
132
|
+
/**
|
|
133
|
+
* Builds the upstream payout DTO for a bank beneficiary.
|
|
134
|
+
*
|
|
135
|
+
* @param receiver - Valid bank beneficiary.
|
|
136
|
+
* @param amount - Amount to pay out.
|
|
137
|
+
* @param channel - Resolved upstream bank payout channel.
|
|
138
|
+
* @param notes - Optional note used as narration when present.
|
|
139
|
+
* @returns Complete bank payout API input.
|
|
140
|
+
*/
|
|
141
|
+
private createBankInput;
|
|
74
142
|
}
|
|
75
143
|
/**
|
|
76
|
-
* @deprecated Use
|
|
77
|
-
* @see {@link PayoutChannelCodeFactory}
|
|
144
|
+
* @deprecated Use PayoutChannelResolver instead.
|
|
78
145
|
*/
|
|
79
146
|
export declare const createPayoutChannelCode: {
|
|
80
|
-
bank: typeof
|
|
81
|
-
mobile: typeof
|
|
147
|
+
bank: typeof PayoutChannelResolver.forBank;
|
|
148
|
+
mobile: typeof PayoutChannelResolver.forMobile;
|
|
82
149
|
};
|
|
83
|
-
export {};
|
|
@@ -402,7 +402,7 @@ export declare const contract: {
|
|
|
402
402
|
postPayout: {
|
|
403
403
|
method: "POST";
|
|
404
404
|
body: z.ZodObject<{
|
|
405
|
-
channel: z.
|
|
405
|
+
channel: z.ZodNativeEnum<typeof import("./payout.dtos.js").PayoutChannel>;
|
|
406
406
|
msisdn: z.ZodString;
|
|
407
407
|
amount: z.ZodNumber;
|
|
408
408
|
description: z.ZodString;
|
|
@@ -411,14 +411,14 @@ export declare const contract: {
|
|
|
411
411
|
payeeName: z.ZodString;
|
|
412
412
|
}, "strip", z.ZodTypeAny, {
|
|
413
413
|
description: string;
|
|
414
|
-
channel:
|
|
414
|
+
channel: import("./payout.dtos.js").PayoutChannel;
|
|
415
415
|
msisdn: string;
|
|
416
416
|
amount: number;
|
|
417
417
|
payeeName: string;
|
|
418
418
|
notes?: string | null | undefined;
|
|
419
419
|
}, {
|
|
420
420
|
description: string;
|
|
421
|
-
channel:
|
|
421
|
+
channel: import("./payout.dtos.js").PayoutChannel;
|
|
422
422
|
msisdn: string;
|
|
423
423
|
amount: number;
|
|
424
424
|
payeeName: string;
|
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
/**
|
|
3
3
|
* Represents the available channels through which payouts can be processed.
|
|
4
|
+
*
|
|
5
|
+
* These values are the upstream API channel codes, not beneficiary categories.
|
|
6
|
+
* Beneficiary categories live in `BeneficiaryType`.
|
|
7
|
+
*
|
|
4
8
|
* @enum {string}
|
|
5
9
|
* @readonly
|
|
6
10
|
*/
|
|
7
11
|
export declare enum PayoutChannel {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
TZ_TIGO_B2C = "TZ-TIGO-B2C",
|
|
13
|
+
TZ_VODACOM_B2C = "TZ-VODACOM-B2C",
|
|
14
|
+
TZ_AIRTEL_B2C = "TZ-AIRTEL-B2C",
|
|
15
|
+
TZ_HALOTEL_B2C = "TZ-HALOTEL-B2C",
|
|
16
|
+
KE_SAFARICOM_B2C = "KE-SAFARICOM-B2C",
|
|
17
|
+
TZ_BANK_B2C = "TZ-BANK-B2C",
|
|
18
|
+
KE_BANK_B2C = "KE-BANK-B2C"
|
|
12
19
|
}
|
|
13
20
|
/**
|
|
14
21
|
* Represents the current status of a payout transaction.
|
|
@@ -66,7 +73,7 @@ declare const AuthorizerSchema: z.ZodObject<{
|
|
|
66
73
|
* Extends base payout schema with payee information
|
|
67
74
|
*/
|
|
68
75
|
declare const PayoutInputDTOSchema: z.ZodObject<{
|
|
69
|
-
channel: z.
|
|
76
|
+
channel: z.ZodNativeEnum<typeof PayoutChannel>;
|
|
70
77
|
msisdn: z.ZodString;
|
|
71
78
|
amount: z.ZodNumber;
|
|
72
79
|
description: z.ZodString;
|
|
@@ -75,14 +82,14 @@ declare const PayoutInputDTOSchema: z.ZodObject<{
|
|
|
75
82
|
payeeName: z.ZodString;
|
|
76
83
|
}, "strip", z.ZodTypeAny, {
|
|
77
84
|
description: string;
|
|
78
|
-
channel:
|
|
85
|
+
channel: PayoutChannel;
|
|
79
86
|
msisdn: string;
|
|
80
87
|
amount: number;
|
|
81
88
|
payeeName: string;
|
|
82
89
|
notes?: string | null | undefined;
|
|
83
90
|
}, {
|
|
84
91
|
description: string;
|
|
85
|
-
channel:
|
|
92
|
+
channel: PayoutChannel;
|
|
86
93
|
msisdn: string;
|
|
87
94
|
amount: number;
|
|
88
95
|
payeeName: string;
|
|
@@ -509,7 +516,7 @@ export declare const PayoutDTOSchemas: {
|
|
|
509
516
|
} | null | undefined;
|
|
510
517
|
}>;
|
|
511
518
|
readonly PayoutInputDTO: z.ZodObject<{
|
|
512
|
-
channel: z.
|
|
519
|
+
channel: z.ZodNativeEnum<typeof PayoutChannel>;
|
|
513
520
|
msisdn: z.ZodString;
|
|
514
521
|
amount: z.ZodNumber;
|
|
515
522
|
description: z.ZodString;
|
|
@@ -518,14 +525,14 @@ export declare const PayoutDTOSchemas: {
|
|
|
518
525
|
payeeName: z.ZodString;
|
|
519
526
|
}, "strip", z.ZodTypeAny, {
|
|
520
527
|
description: string;
|
|
521
|
-
channel:
|
|
528
|
+
channel: PayoutChannel;
|
|
522
529
|
msisdn: string;
|
|
523
530
|
amount: number;
|
|
524
531
|
payeeName: string;
|
|
525
532
|
notes?: string | null | undefined;
|
|
526
533
|
}, {
|
|
527
534
|
description: string;
|
|
528
|
-
channel:
|
|
535
|
+
channel: PayoutChannel;
|
|
529
536
|
msisdn: string;
|
|
530
537
|
amount: number;
|
|
531
538
|
payeeName: string;
|
|
@@ -533,6 +540,7 @@ export declare const PayoutDTOSchemas: {
|
|
|
533
540
|
}>;
|
|
534
541
|
readonly PayoutStatus: z.ZodNativeEnum<typeof PayoutStatus>;
|
|
535
542
|
readonly PayoutApprovalStatus: z.ZodNativeEnum<typeof PayoutApprovalStatus>;
|
|
543
|
+
readonly PayoutChannel: z.ZodNativeEnum<typeof PayoutChannel>;
|
|
536
544
|
readonly PayoutAuthorizer: z.ZodObject<{
|
|
537
545
|
id: z.ZodString;
|
|
538
546
|
name: z.ZodString;
|
|
@@ -200,7 +200,7 @@ export declare class PayoutQuery extends QueryBuilder {
|
|
|
200
200
|
* .whereApproved()
|
|
201
201
|
* .orderByDesc("createdAt")
|
|
202
202
|
* .build();
|
|
203
|
-
* // => { "approvalStatus:eq": "
|
|
203
|
+
* // => { "approvalStatus:eq": "Approved", orderByDesc: "createdAt" }
|
|
204
204
|
* ```
|
|
205
205
|
*
|
|
206
206
|
* @returns An objection-find query object
|
|
@@ -2,20 +2,20 @@ import { BaseRepository } from "@/lib/api/index.js";
|
|
|
2
2
|
import { Payout } from "@/modules/payout/payout.model.js";
|
|
3
3
|
import { Amount } from "@temboplus/frontend-core";
|
|
4
4
|
import { PayoutAPI } from "./payout.api-contract.js";
|
|
5
|
-
import { PayoutChannel } from "./payout.dtos.js";
|
|
6
5
|
import { PayoutQuery } from "./payout.query.js";
|
|
7
6
|
import { PayoutFilters } from "./payout.dtos.js";
|
|
8
7
|
import { Paged } from "@/lib/query/index.js";
|
|
9
8
|
import { Wallet } from "../wallet/wallet.model.js";
|
|
10
9
|
import { BeneficiaryInfo } from "../beneficiary/beneficiary-info.model.js";
|
|
11
10
|
/**
|
|
12
|
-
* Input type for payout creation mutation
|
|
11
|
+
* Input type for payout creation mutation.
|
|
12
|
+
*
|
|
13
|
+
* Consumers do not provide a payout channel. The repository resolves the
|
|
14
|
+
* upstream B2C channel from wallet, beneficiary, and amount details.
|
|
13
15
|
*/
|
|
14
16
|
export interface CreatePayoutInput {
|
|
15
17
|
/** The wallet to pay from */
|
|
16
18
|
wallet: Wallet;
|
|
17
|
-
/** The payout channel to use (MOBILE or BANK) */
|
|
18
|
-
channel: PayoutChannel;
|
|
19
19
|
/** Contact information for the payout receiver */
|
|
20
20
|
receiver: BeneficiaryInfo;
|
|
21
21
|
/** The amount to pay out */
|
|
@@ -123,9 +123,11 @@ export declare class PayoutRepository extends BaseRepository<PayoutAPI> {
|
|
|
123
123
|
/**
|
|
124
124
|
* Creates a new payout with the provided input data.
|
|
125
125
|
*
|
|
126
|
+
* The upstream payout channel is resolved internally by the library before
|
|
127
|
+
* the API request is sent.
|
|
128
|
+
*
|
|
126
129
|
* @param input - The payout creation data
|
|
127
130
|
* @param input.wallet - The wallet to pay from
|
|
128
|
-
* @param input.channel - The payout channel to use
|
|
129
131
|
* @param input.receiver - Contact information for the payout receiver
|
|
130
132
|
* @param input.amount - The amount to pay out
|
|
131
133
|
* @param input.notes - Optional notes for the payout
|
|
@@ -136,7 +138,6 @@ export declare class PayoutRepository extends BaseRepository<PayoutAPI> {
|
|
|
136
138
|
* ```typescript
|
|
137
139
|
* const payout = await repo.pay({
|
|
138
140
|
* wallet: selectedWallet,
|
|
139
|
-
* channel: PayoutChannel.MOBILE,
|
|
140
141
|
* receiver: { name: "John Doe", phone: "+255123456789" },
|
|
141
142
|
* amount: Amount.from(10000, "TZS"),
|
|
142
143
|
* notes: "Payment for services"
|