@spritz-finance/service-client 0.14.0 → 0.16.0
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export * as PayableAccountsClient from "./payableAccountsServiceClient";
|
|
2
|
-
import { ExternalBillInput, PayableAccount, PayableAccountInstitution, SimpleCardTransaction, UpsertVirtualCardInput } from "./types";
|
|
2
|
+
import { BankAccountPayoutRail, BankAccountUnpayableCode, ExternalBillInput, PayableAccount, PayableAccountInstitution, SimpleCardTransaction, UpsertVirtualCardInput } from "./types";
|
|
3
3
|
export declare function getAccount(accountId: string): Promise<(Omit<import("../lib/graphClient/generated").Bill, "type" | "institution"> & {
|
|
4
4
|
__t: import("../lib/graphClient/generated").PayableAccountType;
|
|
5
5
|
externalId?: string | null;
|
|
@@ -16,6 +16,11 @@ export declare function getAccount(accountId: string): Promise<(Omit<import("../
|
|
|
16
16
|
payable: boolean;
|
|
17
17
|
testPaymentAvailable: boolean;
|
|
18
18
|
provider: import("../lib/graphClient/generated").AccountProvider;
|
|
19
|
+
} & {
|
|
20
|
+
disabledPayoutRails?: import("./types").DisabledPayoutRail[] | null;
|
|
21
|
+
unpayableCode?: BankAccountUnpayableCode | null;
|
|
22
|
+
unpayableReason?: string | null;
|
|
23
|
+
unpayableAt?: string | null;
|
|
19
24
|
}) | (Omit<import("../lib/graphClient/generated").VirtualCard, "type" | "institution"> & {
|
|
20
25
|
__t: import("../lib/graphClient/generated").PayableAccountType;
|
|
21
26
|
externalId?: string | null;
|
|
@@ -59,6 +64,11 @@ export declare function getAccountByExternalId(externalId: string): Promise<(Omi
|
|
|
59
64
|
payable: boolean;
|
|
60
65
|
testPaymentAvailable: boolean;
|
|
61
66
|
provider: import("../lib/graphClient/generated").AccountProvider;
|
|
67
|
+
} & {
|
|
68
|
+
disabledPayoutRails?: import("./types").DisabledPayoutRail[] | null;
|
|
69
|
+
unpayableCode?: BankAccountUnpayableCode | null;
|
|
70
|
+
unpayableReason?: string | null;
|
|
71
|
+
unpayableAt?: string | null;
|
|
62
72
|
}) | (Omit<import("../lib/graphClient/generated").VirtualCard, "type" | "institution"> & {
|
|
63
73
|
__t: import("../lib/graphClient/generated").PayableAccountType;
|
|
64
74
|
externalId?: string | null;
|
|
@@ -102,3 +112,44 @@ export declare function getAccountById(accountId: string): Promise<import("../ty
|
|
|
102
112
|
export declare function createUSVirtualCardNoKyc(userId: string): Promise<import("../types").ApiFailure | import("../types").ApiSuccess<PayableAccount>>;
|
|
103
113
|
export declare function upsertVirtualCard(input: UpsertVirtualCardInput): Promise<import("../types").ApiFailure | import("../types").ApiSuccess<PayableAccount>>;
|
|
104
114
|
export declare function getRecentCardSpendTransactions(userId: string): Promise<import("../types").ApiFailure | import("../types").ApiSuccess<SimpleCardTransaction[]>>;
|
|
115
|
+
/**
|
|
116
|
+
* Permanently disable a payout rail for a bank account. Used when the account is
|
|
117
|
+
* fine but cannot use one rail (e.g. "Transaction type not supported or
|
|
118
|
+
* authorized on the receiving account"). Idempotent per rail.
|
|
119
|
+
*
|
|
120
|
+
* For a bank rejecting the ACCOUNT itself, use `markUnpayable` instead — leaving
|
|
121
|
+
* the other rails enabled lets a reissue downgrade onto a doomed rail.
|
|
122
|
+
*/
|
|
123
|
+
export declare function disablePayoutRail(accountId: string, rail: BankAccountPayoutRail, reason: string): Promise<import("../types").ApiFailure | import("../types").ApiSuccess<Omit<import("../lib/graphClient/generated").BankAccount, "type" | "institution"> & {
|
|
124
|
+
__t: import("../lib/graphClient/generated").PayableAccountType;
|
|
125
|
+
externalId?: string | null;
|
|
126
|
+
institutionId?: string | null;
|
|
127
|
+
nickname?: string | null;
|
|
128
|
+
payable: boolean;
|
|
129
|
+
testPaymentAvailable: boolean;
|
|
130
|
+
provider: import("../lib/graphClient/generated").AccountProvider;
|
|
131
|
+
} & {
|
|
132
|
+
disabledPayoutRails?: import("./types").DisabledPayoutRail[] | null;
|
|
133
|
+
unpayableCode?: BankAccountUnpayableCode | null;
|
|
134
|
+
unpayableReason?: string | null;
|
|
135
|
+
unpayableAt?: string | null;
|
|
136
|
+
}>>;
|
|
137
|
+
/**
|
|
138
|
+
* Permanently mark a bank account unpayable on every rail. Used when the
|
|
139
|
+
* receiving bank rejects the ACCOUNT — RTP "Creditor account Is Invalid" (AC03),
|
|
140
|
+
* ACH R02/R03/R04 — so no retry, reissue or downgrade can reach it. Idempotent.
|
|
141
|
+
*/
|
|
142
|
+
export declare function markUnpayable(accountId: string, code: BankAccountUnpayableCode, reason: string): Promise<import("../types").ApiFailure | import("../types").ApiSuccess<Omit<import("../lib/graphClient/generated").BankAccount, "type" | "institution"> & {
|
|
143
|
+
__t: import("../lib/graphClient/generated").PayableAccountType;
|
|
144
|
+
externalId?: string | null;
|
|
145
|
+
institutionId?: string | null;
|
|
146
|
+
nickname?: string | null;
|
|
147
|
+
payable: boolean;
|
|
148
|
+
testPaymentAvailable: boolean;
|
|
149
|
+
provider: import("../lib/graphClient/generated").AccountProvider;
|
|
150
|
+
} & {
|
|
151
|
+
disabledPayoutRails?: import("./types").DisabledPayoutRail[] | null;
|
|
152
|
+
unpayableCode?: BankAccountUnpayableCode | null;
|
|
153
|
+
unpayableReason?: string | null;
|
|
154
|
+
unpayableAt?: string | null;
|
|
155
|
+
}>>;
|
|
@@ -44,9 +44,14 @@ exports.getAccountById = getAccountById;
|
|
|
44
44
|
exports.createUSVirtualCardNoKyc = createUSVirtualCardNoKyc;
|
|
45
45
|
exports.upsertVirtualCard = upsertVirtualCard;
|
|
46
46
|
exports.getRecentCardSpendTransactions = getRecentCardSpendTransactions;
|
|
47
|
+
exports.disablePayoutRail = disablePayoutRail;
|
|
48
|
+
exports.markUnpayable = markUnpayable;
|
|
47
49
|
exports.PayableAccountsClient = __importStar(require("./payableAccountsServiceClient"));
|
|
48
50
|
const serviceClient_1 = require("../serviceClient");
|
|
49
51
|
const PAYABLE_ACCOUNTS_ENDPOINT = "/payable-accounts";
|
|
52
|
+
// The Hono ServiceApi (`/api/{proxy+}`) is mapped on the shared gateway domain
|
|
53
|
+
// under the `payable-accounts-v2` key (serverless.yaml HTTPAPIMapping).
|
|
54
|
+
const PAYABLE_ACCOUNTS_ROUTER_ENDPOINT = "/payable-accounts-v2/api";
|
|
50
55
|
async function getAccount(accountId) {
|
|
51
56
|
return serviceClient_1.baseClient
|
|
52
57
|
.get(`${PAYABLE_ACCOUNTS_ENDPOINT}/payable-account/id/${accountId}`)
|
|
@@ -97,3 +102,26 @@ async function getRecentCardSpendTransactions(userId) {
|
|
|
97
102
|
.get(`${PAYABLE_ACCOUNTS_ENDPOINT}/virtual-card/recent-transactions/user/${userId}`)
|
|
98
103
|
.then((res) => res.data);
|
|
99
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* Permanently disable a payout rail for a bank account. Used when the account is
|
|
107
|
+
* fine but cannot use one rail (e.g. "Transaction type not supported or
|
|
108
|
+
* authorized on the receiving account"). Idempotent per rail.
|
|
109
|
+
*
|
|
110
|
+
* For a bank rejecting the ACCOUNT itself, use `markUnpayable` instead — leaving
|
|
111
|
+
* the other rails enabled lets a reissue downgrade onto a doomed rail.
|
|
112
|
+
*/
|
|
113
|
+
async function disablePayoutRail(accountId, rail, reason) {
|
|
114
|
+
return serviceClient_1.baseClient
|
|
115
|
+
.post(`${PAYABLE_ACCOUNTS_ROUTER_ENDPOINT}/bank-accounts/${accountId}/payout-rails/disable`, { rail, reason })
|
|
116
|
+
.then((res) => res.data);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Permanently mark a bank account unpayable on every rail. Used when the
|
|
120
|
+
* receiving bank rejects the ACCOUNT — RTP "Creditor account Is Invalid" (AC03),
|
|
121
|
+
* ACH R02/R03/R04 — so no retry, reissue or downgrade can reach it. Idempotent.
|
|
122
|
+
*/
|
|
123
|
+
async function markUnpayable(accountId, code, reason) {
|
|
124
|
+
return serviceClient_1.baseClient
|
|
125
|
+
.post(`${PAYABLE_ACCOUNTS_ROUTER_ENDPOINT}/bank-accounts/${accountId}/unpayable`, { code, reason })
|
|
126
|
+
.then((res) => res.data);
|
|
127
|
+
}
|
|
@@ -71,7 +71,32 @@ type PayableAccountModelExtension = {
|
|
|
71
71
|
provider: AccountProvider;
|
|
72
72
|
};
|
|
73
73
|
type BillModel = Omit<Bill, "type" | "institution"> & PayableAccountModelExtension;
|
|
74
|
-
type
|
|
74
|
+
export type BankAccountPayoutRail = "ach_standard" | "ach_same_day" | "wire" | "rtp" | "eft" | "sepa" | "faster_payments";
|
|
75
|
+
export type DisabledPayoutRail = {
|
|
76
|
+
rail: BankAccountPayoutRail;
|
|
77
|
+
disabledAt: string;
|
|
78
|
+
reason: string;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Why the receiving bank rejected the account outright. Coarse by design — it
|
|
82
|
+
* drives user-facing copy ("add a different account"), not a mirror of every ISO
|
|
83
|
+
* 20022 / NACHA code. Verbatim provider text stays in `unpayableReason`.
|
|
84
|
+
*/
|
|
85
|
+
export type BankAccountUnpayableCode = "account_invalid" | "account_closed" | "account_blocked";
|
|
86
|
+
type BankAcountModel = Omit<BankAccount, "type" | "institution"> & PayableAccountModelExtension & {
|
|
87
|
+
/** Rails the payment network rejected for this specific account (e.g.
|
|
88
|
+
* "Transaction type not supported on the receiving account"). Sticky:
|
|
89
|
+
* serialized `bankAccountFeatures` are already effective capabilities
|
|
90
|
+
* (detected rails minus these). */
|
|
91
|
+
disabledPayoutRails?: DisabledPayoutRail[] | null;
|
|
92
|
+
/** Why the receiving bank rejected the account outright (RTP AC03, ACH
|
|
93
|
+
* R02/R03/R04). Set together with `payable: false`, and the account stays
|
|
94
|
+
* listed so clients can show the user why it can't be paid rather than
|
|
95
|
+
* having it silently disappear. */
|
|
96
|
+
unpayableCode?: BankAccountUnpayableCode | null;
|
|
97
|
+
unpayableReason?: string | null;
|
|
98
|
+
unpayableAt?: string | null;
|
|
99
|
+
};
|
|
75
100
|
type VirtualCardModel = Omit<VirtualCard, "type" | "institution"> & PayableAccountModelExtension;
|
|
76
101
|
type DebitCardModel = Omit<DebitCard, "type" | "institution"> & PayableAccountModelExtension & {
|
|
77
102
|
providerRegistrations?: ProviderRegistration[];
|