@jazadev/react-native 0.1.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.
- package/README.md +241 -0
- package/dist/index.cjs +1988 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +271 -0
- package/dist/index.d.ts +271 -0
- package/dist/index.js +1987 -0
- package/dist/index.js.map +1 -0
- package/package.json +77 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { ViewStyle } from 'react-native';
|
|
4
|
+
|
|
5
|
+
type Bundle = {
|
|
6
|
+
id: string;
|
|
7
|
+
appId: string;
|
|
8
|
+
label: string | null;
|
|
9
|
+
priceUsd: string;
|
|
10
|
+
credits: number;
|
|
11
|
+
isActive: boolean;
|
|
12
|
+
sortOrder: number;
|
|
13
|
+
createdAt: string;
|
|
14
|
+
updatedAt: string;
|
|
15
|
+
};
|
|
16
|
+
type CatalogCurrency = {
|
|
17
|
+
id: string;
|
|
18
|
+
code: string;
|
|
19
|
+
name: string;
|
|
20
|
+
decimals: number;
|
|
21
|
+
isActive: boolean;
|
|
22
|
+
};
|
|
23
|
+
type CatalogCountry = {
|
|
24
|
+
id: string;
|
|
25
|
+
name: string;
|
|
26
|
+
iso2: string;
|
|
27
|
+
iso3: string;
|
|
28
|
+
isActive: boolean;
|
|
29
|
+
currencies?: Array<{
|
|
30
|
+
currency: CatalogCurrency;
|
|
31
|
+
}>;
|
|
32
|
+
paymentGateways?: unknown[];
|
|
33
|
+
};
|
|
34
|
+
type PredictProviderResponse = {
|
|
35
|
+
provider: {
|
|
36
|
+
code: string;
|
|
37
|
+
displayName: string;
|
|
38
|
+
};
|
|
39
|
+
countryIso3: string | null;
|
|
40
|
+
currencies: Array<{
|
|
41
|
+
code: string;
|
|
42
|
+
decimals: number;
|
|
43
|
+
}>;
|
|
44
|
+
defaultCurrencyCode: string;
|
|
45
|
+
};
|
|
46
|
+
type QuotePaymentResponse = {
|
|
47
|
+
bundleId: string;
|
|
48
|
+
credits: number;
|
|
49
|
+
currencyCode: string;
|
|
50
|
+
paymentGatewayCode: string;
|
|
51
|
+
amountUsd: string;
|
|
52
|
+
amountLocal: string;
|
|
53
|
+
feeUsd: string;
|
|
54
|
+
feeLocal: string;
|
|
55
|
+
totalUsd: string;
|
|
56
|
+
totalLocal: string;
|
|
57
|
+
};
|
|
58
|
+
type DepositStatus = 'PENDING' | 'COMPLETED' | 'FAILED' | 'EXPIRED' | 'CANCELLED';
|
|
59
|
+
type PublicDeposit = {
|
|
60
|
+
id: string;
|
|
61
|
+
status: DepositStatus;
|
|
62
|
+
credits: number;
|
|
63
|
+
currencyCode: string | null;
|
|
64
|
+
paymentGatewayCode: string | null;
|
|
65
|
+
amountUsd: string;
|
|
66
|
+
amountLocal: string;
|
|
67
|
+
feeUsd: string;
|
|
68
|
+
feeLocal: string;
|
|
69
|
+
totalUsd: string;
|
|
70
|
+
totalLocal: string;
|
|
71
|
+
bundleId: string | null;
|
|
72
|
+
phoneNumber: string | null;
|
|
73
|
+
providerRef: string | null;
|
|
74
|
+
failureReason: string | null;
|
|
75
|
+
expiresAt: string;
|
|
76
|
+
createdAt: string;
|
|
77
|
+
updatedAt: string;
|
|
78
|
+
};
|
|
79
|
+
type TopUpCompleteResult = {
|
|
80
|
+
depositId: string;
|
|
81
|
+
credits: number;
|
|
82
|
+
status: DepositStatus;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
type ThemeMode = 'light' | 'dark';
|
|
86
|
+
type JazaTheme = {
|
|
87
|
+
mode: ThemeMode;
|
|
88
|
+
colors: {
|
|
89
|
+
background: string;
|
|
90
|
+
surface: string;
|
|
91
|
+
surfaceContainer: string;
|
|
92
|
+
surfaceContainerLow: string;
|
|
93
|
+
surfaceContainerHigh: string;
|
|
94
|
+
surfaceContainerHighest: string;
|
|
95
|
+
surfaceVariant: string;
|
|
96
|
+
onSurface: string;
|
|
97
|
+
onSurfaceVariant: string;
|
|
98
|
+
primary: string;
|
|
99
|
+
onPrimary: string;
|
|
100
|
+
primaryContainer: string;
|
|
101
|
+
onPrimaryContainer: string;
|
|
102
|
+
secondaryContainer: string;
|
|
103
|
+
onSecondaryContainer: string;
|
|
104
|
+
outline: string;
|
|
105
|
+
outlineVariant: string;
|
|
106
|
+
error: string;
|
|
107
|
+
success: string;
|
|
108
|
+
overlay: string;
|
|
109
|
+
bundleBorder: string;
|
|
110
|
+
bundleBorderSelected: string;
|
|
111
|
+
bundleBg: string;
|
|
112
|
+
};
|
|
113
|
+
spacing: {
|
|
114
|
+
xs: number;
|
|
115
|
+
sm: number;
|
|
116
|
+
md: number;
|
|
117
|
+
lg: number;
|
|
118
|
+
xl: number;
|
|
119
|
+
gutter: number;
|
|
120
|
+
};
|
|
121
|
+
radius: {
|
|
122
|
+
md: number;
|
|
123
|
+
lg: number;
|
|
124
|
+
xl: number;
|
|
125
|
+
full: number;
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
declare const darkTheme: JazaTheme;
|
|
129
|
+
/** Checkout UI uses dark palette in both light and dark preference. */
|
|
130
|
+
declare const lightTheme: JazaTheme;
|
|
131
|
+
type ThemePreference = 'light' | 'dark' | 'system';
|
|
132
|
+
|
|
133
|
+
type JazaProviderProps = {
|
|
134
|
+
publishableKey: string;
|
|
135
|
+
apiBaseUrl?: string;
|
|
136
|
+
getBalance: () => Promise<number>;
|
|
137
|
+
onTopUpComplete?: (result: TopUpCompleteResult) => void;
|
|
138
|
+
theme?: ThemePreference;
|
|
139
|
+
children: ReactNode;
|
|
140
|
+
};
|
|
141
|
+
declare function JazaProvider({ publishableKey, apiBaseUrl, getBalance, onTopUpComplete, theme: themePreference, children, }: JazaProviderProps): react.JSX.Element;
|
|
142
|
+
|
|
143
|
+
type PublicClientConfig = {
|
|
144
|
+
apiBaseUrl?: string;
|
|
145
|
+
publishableKey: string;
|
|
146
|
+
};
|
|
147
|
+
declare class PublicClient {
|
|
148
|
+
private readonly apiBaseUrl;
|
|
149
|
+
private readonly publishableKey;
|
|
150
|
+
private topUpToken;
|
|
151
|
+
constructor(config: PublicClientConfig);
|
|
152
|
+
setTopUpToken(token: string | null): void;
|
|
153
|
+
listCountries(): Promise<CatalogCountry[]>;
|
|
154
|
+
listBundles(): Promise<Bundle[]>;
|
|
155
|
+
predictProvider(phoneNumber: string): Promise<PredictProviderResponse>;
|
|
156
|
+
quotePayment(body: {
|
|
157
|
+
bundleId: string;
|
|
158
|
+
currencyCode: string;
|
|
159
|
+
paymentGatewayCode: string;
|
|
160
|
+
}): Promise<QuotePaymentResponse>;
|
|
161
|
+
createDeposit(body: {
|
|
162
|
+
bundleId: string;
|
|
163
|
+
currencyCode: string;
|
|
164
|
+
paymentGatewayCode: string;
|
|
165
|
+
phoneNumber: string;
|
|
166
|
+
idempotencyKey?: string;
|
|
167
|
+
}): Promise<PublicDeposit>;
|
|
168
|
+
getDeposit(paymentRequestId: string): Promise<PublicDeposit>;
|
|
169
|
+
private authedRequest;
|
|
170
|
+
private request;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
type EnrichedCountry = {
|
|
174
|
+
id: string;
|
|
175
|
+
name: string;
|
|
176
|
+
iso2: string;
|
|
177
|
+
iso3: string;
|
|
178
|
+
dialCode: string;
|
|
179
|
+
flag: string;
|
|
180
|
+
currencies: Array<{
|
|
181
|
+
code: string;
|
|
182
|
+
decimals: number;
|
|
183
|
+
name: string;
|
|
184
|
+
}>;
|
|
185
|
+
};
|
|
186
|
+
declare function enrichCountries(countries: CatalogCountry[]): EnrichedCountry[];
|
|
187
|
+
declare function buildE164(dialCode: string, nationalNumber: string): string;
|
|
188
|
+
/** Prefer local (non-USD) when multiple currencies are supported. */
|
|
189
|
+
declare function pickDefaultCurrencyCode(codes: string[]): string;
|
|
190
|
+
declare function isDepositTerminal(status: string): status is 'COMPLETED' | 'FAILED' | 'EXPIRED' | 'CANCELLED';
|
|
191
|
+
declare function formatCredits(n: number): string;
|
|
192
|
+
declare function formatUsd(priceUsd: string): string;
|
|
193
|
+
declare function formatCurrencyAmount(amount: string | number, currencyCode: string, _decimals?: number): string;
|
|
194
|
+
/** @deprecated Use formatCurrencyAmount */
|
|
195
|
+
declare function formatLocalAmount(amount: string, currencyCode: string, decimals?: number): string;
|
|
196
|
+
|
|
197
|
+
type TopUpStep = 'offer' | 'payment' | 'processing';
|
|
198
|
+
type ResultPhase = 'loading' | 'success' | 'failure';
|
|
199
|
+
type JazaContextValue = {
|
|
200
|
+
theme: JazaTheme;
|
|
201
|
+
themePreference: ThemePreference;
|
|
202
|
+
publishableKey: string;
|
|
203
|
+
client: PublicClient;
|
|
204
|
+
balance: number | null;
|
|
205
|
+
balanceLoading: boolean;
|
|
206
|
+
balanceError: string | null;
|
|
207
|
+
refreshBalance: () => Promise<void>;
|
|
208
|
+
sheetOpen: boolean;
|
|
209
|
+
step: TopUpStep;
|
|
210
|
+
resultPhase: ResultPhase;
|
|
211
|
+
topUpToken: string | null;
|
|
212
|
+
bundles: Bundle[];
|
|
213
|
+
bundlesLoading: boolean;
|
|
214
|
+
bundlesError: string | null;
|
|
215
|
+
selectedBundle: Bundle | null;
|
|
216
|
+
setSelectedBundle: (b: Bundle | null) => void;
|
|
217
|
+
countries: EnrichedCountry[];
|
|
218
|
+
selectedCountry: EnrichedCountry | null;
|
|
219
|
+
setSelectedCountry: (c: EnrichedCountry | null) => void;
|
|
220
|
+
selectedCurrencyCode: string | null;
|
|
221
|
+
setSelectedCurrencyCode: (code: string | null) => void;
|
|
222
|
+
phoneNational: string;
|
|
223
|
+
setPhoneNational: (v: string) => void;
|
|
224
|
+
predict: PredictProviderResponse | null;
|
|
225
|
+
predictLoading: boolean;
|
|
226
|
+
predictError: string | null;
|
|
227
|
+
quote: QuotePaymentResponse | null;
|
|
228
|
+
quoteLoading: boolean;
|
|
229
|
+
quoteError: string | null;
|
|
230
|
+
deposit: PublicDeposit | null;
|
|
231
|
+
depositError: string | null;
|
|
232
|
+
failureReason: string | null;
|
|
233
|
+
openTopUp: (token: string) => Promise<void>;
|
|
234
|
+
closeTopUp: () => void;
|
|
235
|
+
goToOffer: () => void;
|
|
236
|
+
goToPayment: () => void;
|
|
237
|
+
submitDeposit: () => Promise<void>;
|
|
238
|
+
retryPayment: () => void;
|
|
239
|
+
onTopUpComplete?: (result: TopUpCompleteResult) => void;
|
|
240
|
+
};
|
|
241
|
+
declare function useJaza(): JazaContextValue;
|
|
242
|
+
|
|
243
|
+
type JazaBalanceWidgetProps = {
|
|
244
|
+
style?: ViewStyle;
|
|
245
|
+
};
|
|
246
|
+
declare function JazaBalanceWidget({ style }: JazaBalanceWidgetProps): react.JSX.Element;
|
|
247
|
+
|
|
248
|
+
type JazaTopUpButtonProps = {
|
|
249
|
+
onRequestToken: () => Promise<string>;
|
|
250
|
+
label?: string;
|
|
251
|
+
style?: ViewStyle;
|
|
252
|
+
};
|
|
253
|
+
declare function JazaTopUpButton({ onRequestToken, label, style, }: JazaTopUpButtonProps): react.JSX.Element;
|
|
254
|
+
|
|
255
|
+
declare class JazaSdkError extends Error {
|
|
256
|
+
readonly statusCode: number;
|
|
257
|
+
readonly code: string;
|
|
258
|
+
readonly raw: unknown;
|
|
259
|
+
constructor(statusCode: number, message: string, raw?: unknown);
|
|
260
|
+
static fromResponse(status: number, body: unknown): JazaSdkError;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
declare const VERSION = "0.1.0";
|
|
264
|
+
declare const DEFAULT_API_BASE_URL = "https://api.jaza.dev";
|
|
265
|
+
|
|
266
|
+
/** ISO 3166-1 alpha-2 → international dial code (Jaza MoMo ecosystem). */
|
|
267
|
+
declare const DIAL_CODES: Record<string, string>;
|
|
268
|
+
declare function iso2ToFlag(iso2: string): string;
|
|
269
|
+
declare function getDialCode(iso2: string): string | undefined;
|
|
270
|
+
|
|
271
|
+
export { type Bundle, type CatalogCountry, DEFAULT_API_BASE_URL, DIAL_CODES, type DepositStatus, type EnrichedCountry, JazaBalanceWidget, type JazaBalanceWidgetProps, type JazaContextValue, JazaProvider, type JazaProviderProps, JazaSdkError, type JazaTheme, JazaTopUpButton, type JazaTopUpButtonProps, type PredictProviderResponse, PublicClient, type PublicClientConfig, type PublicDeposit, type QuotePaymentResponse, type ResultPhase, type ThemePreference, type TopUpCompleteResult, type TopUpStep, VERSION, buildE164, darkTheme, enrichCountries, formatCredits, formatCurrencyAmount, formatLocalAmount, formatUsd, getDialCode, isDepositTerminal, iso2ToFlag, lightTheme, pickDefaultCurrencyCode, useJaza };
|