@reevit/react 0.4.5 → 0.4.6
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.d.mts +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.js +26 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -15
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -308,9 +308,9 @@ interface HubtelBridgeProps {
|
|
|
308
308
|
callbackUrl?: string;
|
|
309
309
|
apiBaseUrl?: string;
|
|
310
310
|
clientSecret?: string;
|
|
311
|
-
/** Session token from server (
|
|
311
|
+
/** Session token from server (triggers session fetch) */
|
|
312
312
|
hubtelSessionToken?: string;
|
|
313
|
-
/**
|
|
313
|
+
/** Base64 basic auth credential (legacy - credentials exposed) */
|
|
314
314
|
basicAuth?: string;
|
|
315
315
|
preferredMethod?: PaymentMethod;
|
|
316
316
|
onSuccess: (result: PaymentResult) => void;
|
|
@@ -318,7 +318,7 @@ interface HubtelBridgeProps {
|
|
|
318
318
|
onClose: () => void;
|
|
319
319
|
autoStart?: boolean;
|
|
320
320
|
}
|
|
321
|
-
declare function HubtelBridge({ paymentId, publicKey, merchantAccount, amount, reference, phone, description, callbackUrl, apiBaseUrl, clientSecret, hubtelSessionToken, basicAuth, preferredMethod, onSuccess, onError, onClose, autoStart, }: HubtelBridgeProps): react_jsx_runtime.JSX.Element;
|
|
321
|
+
declare function HubtelBridge({ paymentId, publicKey, merchantAccount, amount, currency, reference, email, phone, description, callbackUrl, apiBaseUrl, clientSecret, hubtelSessionToken, basicAuth, preferredMethod, onSuccess, onError, onClose, autoStart, }: HubtelBridgeProps): react_jsx_runtime.JSX.Element;
|
|
322
322
|
/**
|
|
323
323
|
* Opens Hubtel checkout modal directly
|
|
324
324
|
* Uses the @hubteljs/checkout npm package
|
|
@@ -616,6 +616,8 @@ interface HubtelSessionResponse {
|
|
|
616
616
|
token: string;
|
|
617
617
|
/** Hubtel merchant account number */
|
|
618
618
|
merchantAccount: string;
|
|
619
|
+
/** Base64 basic auth for Hubtel checkout (exposes credentials) */
|
|
620
|
+
basicAuth?: string;
|
|
619
621
|
/** Token expiry time in seconds */
|
|
620
622
|
expiresInSeconds: number;
|
|
621
623
|
/** Unix timestamp when the token expires */
|
package/dist/index.d.ts
CHANGED
|
@@ -308,9 +308,9 @@ interface HubtelBridgeProps {
|
|
|
308
308
|
callbackUrl?: string;
|
|
309
309
|
apiBaseUrl?: string;
|
|
310
310
|
clientSecret?: string;
|
|
311
|
-
/** Session token from server (
|
|
311
|
+
/** Session token from server (triggers session fetch) */
|
|
312
312
|
hubtelSessionToken?: string;
|
|
313
|
-
/**
|
|
313
|
+
/** Base64 basic auth credential (legacy - credentials exposed) */
|
|
314
314
|
basicAuth?: string;
|
|
315
315
|
preferredMethod?: PaymentMethod;
|
|
316
316
|
onSuccess: (result: PaymentResult) => void;
|
|
@@ -318,7 +318,7 @@ interface HubtelBridgeProps {
|
|
|
318
318
|
onClose: () => void;
|
|
319
319
|
autoStart?: boolean;
|
|
320
320
|
}
|
|
321
|
-
declare function HubtelBridge({ paymentId, publicKey, merchantAccount, amount, reference, phone, description, callbackUrl, apiBaseUrl, clientSecret, hubtelSessionToken, basicAuth, preferredMethod, onSuccess, onError, onClose, autoStart, }: HubtelBridgeProps): react_jsx_runtime.JSX.Element;
|
|
321
|
+
declare function HubtelBridge({ paymentId, publicKey, merchantAccount, amount, currency, reference, email, phone, description, callbackUrl, apiBaseUrl, clientSecret, hubtelSessionToken, basicAuth, preferredMethod, onSuccess, onError, onClose, autoStart, }: HubtelBridgeProps): react_jsx_runtime.JSX.Element;
|
|
322
322
|
/**
|
|
323
323
|
* Opens Hubtel checkout modal directly
|
|
324
324
|
* Uses the @hubteljs/checkout npm package
|
|
@@ -616,6 +616,8 @@ interface HubtelSessionResponse {
|
|
|
616
616
|
token: string;
|
|
617
617
|
/** Hubtel merchant account number */
|
|
618
618
|
merchantAccount: string;
|
|
619
|
+
/** Base64 basic auth for Hubtel checkout (exposes credentials) */
|
|
620
|
+
basicAuth?: string;
|
|
619
621
|
/** Token expiry time in seconds */
|
|
620
622
|
expiresInSeconds: number;
|
|
621
623
|
/** Unix timestamp when the token expires */
|
package/dist/index.js
CHANGED
|
@@ -1089,7 +1089,9 @@ function HubtelBridge({
|
|
|
1089
1089
|
publicKey,
|
|
1090
1090
|
merchantAccount,
|
|
1091
1091
|
amount,
|
|
1092
|
+
currency,
|
|
1092
1093
|
reference,
|
|
1094
|
+
email,
|
|
1093
1095
|
phone,
|
|
1094
1096
|
description = "Payment",
|
|
1095
1097
|
callbackUrl,
|
|
@@ -1104,7 +1106,6 @@ function HubtelBridge({
|
|
|
1104
1106
|
autoStart = true
|
|
1105
1107
|
}) {
|
|
1106
1108
|
const initialized = react.useRef(false);
|
|
1107
|
-
const checkoutRef = react.useRef(null);
|
|
1108
1109
|
const [authValue, setAuthValue] = react.useState("");
|
|
1109
1110
|
const [isLoading, setIsLoading] = react.useState(false);
|
|
1110
1111
|
const [resolvedMerchantAccount, setResolvedMerchantAccount] = react.useState(merchantAccount);
|
|
@@ -1118,19 +1119,17 @@ function HubtelBridge({
|
|
|
1118
1119
|
try {
|
|
1119
1120
|
const client = createReevitClient({ publicKey, baseUrl: apiBaseUrl });
|
|
1120
1121
|
const { data, error } = await client.createHubtelSession(paymentId, clientSecret);
|
|
1121
|
-
if (error) {
|
|
1122
|
+
if (error || !data?.basicAuth) {
|
|
1122
1123
|
onError({
|
|
1123
1124
|
code: "SESSION_ERROR",
|
|
1124
|
-
message: error
|
|
1125
|
+
message: error?.message || "Failed to create Hubtel session",
|
|
1125
1126
|
recoverable: true
|
|
1126
1127
|
});
|
|
1127
1128
|
return;
|
|
1128
1129
|
}
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
setResolvedMerchantAccount(data.merchantAccount);
|
|
1133
|
-
}
|
|
1130
|
+
setAuthValue(data.basicAuth);
|
|
1131
|
+
if (data.merchantAccount) {
|
|
1132
|
+
setResolvedMerchantAccount(data.merchantAccount);
|
|
1134
1133
|
}
|
|
1135
1134
|
} catch (err) {
|
|
1136
1135
|
onError({
|
|
@@ -1154,13 +1153,13 @@ function HubtelBridge({
|
|
|
1154
1153
|
}
|
|
1155
1154
|
try {
|
|
1156
1155
|
const checkout = new CheckoutSdk__default.default();
|
|
1157
|
-
checkoutRef.current = checkout;
|
|
1158
1156
|
const methodPreference = preferredMethod === "mobile_money" ? "momo" : preferredMethod === "card" ? "card" : void 0;
|
|
1159
1157
|
const purchaseInfo = {
|
|
1160
1158
|
amount: amount / 100,
|
|
1161
1159
|
// Convert from minor to major units
|
|
1162
1160
|
purchaseDescription: description,
|
|
1163
1161
|
customerPhoneNumber: phone || "",
|
|
1162
|
+
...email ? { customerEmail: email } : {},
|
|
1164
1163
|
clientReference: reference || `hubtel_${Date.now()}`,
|
|
1165
1164
|
...methodPreference ? { paymentMethod: methodPreference } : {}
|
|
1166
1165
|
};
|
|
@@ -1168,8 +1167,6 @@ function HubtelBridge({
|
|
|
1168
1167
|
branding: "enabled",
|
|
1169
1168
|
callbackUrl: callbackUrl || window.location.href,
|
|
1170
1169
|
merchantAccount: typeof resolvedMerchantAccount === "string" ? parseInt(resolvedMerchantAccount, 10) : resolvedMerchantAccount,
|
|
1171
|
-
// Use session token or basicAuth for authentication
|
|
1172
|
-
// Session tokens are base64-encoded credentials fetched securely from the server
|
|
1173
1170
|
basicAuth: authValue || "",
|
|
1174
1171
|
...methodPreference ? { paymentMethod: methodPreference } : {}
|
|
1175
1172
|
};
|
|
@@ -1183,8 +1180,8 @@ function HubtelBridge({
|
|
|
1183
1180
|
paymentId: data.transactionId || reference || "",
|
|
1184
1181
|
reference: data.clientReference || reference || "",
|
|
1185
1182
|
amount,
|
|
1186
|
-
currency: "GHS",
|
|
1187
|
-
paymentMethod: "mobile_money",
|
|
1183
|
+
currency: currency || "GHS",
|
|
1184
|
+
paymentMethod: preferredMethod || "mobile_money",
|
|
1188
1185
|
psp: "hubtel",
|
|
1189
1186
|
pspReference: data.transactionId || "",
|
|
1190
1187
|
status: "success"
|
|
@@ -1215,7 +1212,21 @@ function HubtelBridge({
|
|
|
1215
1212
|
};
|
|
1216
1213
|
onError(error);
|
|
1217
1214
|
}
|
|
1218
|
-
}, [
|
|
1215
|
+
}, [
|
|
1216
|
+
amount,
|
|
1217
|
+
reference,
|
|
1218
|
+
phone,
|
|
1219
|
+
description,
|
|
1220
|
+
callbackUrl,
|
|
1221
|
+
authValue,
|
|
1222
|
+
isLoading,
|
|
1223
|
+
preferredMethod,
|
|
1224
|
+
onSuccess,
|
|
1225
|
+
onError,
|
|
1226
|
+
onClose,
|
|
1227
|
+
resolvedMerchantAccount,
|
|
1228
|
+
currency
|
|
1229
|
+
]);
|
|
1219
1230
|
react.useEffect(() => {
|
|
1220
1231
|
if (autoStart && !initialized.current && !isLoading && authValue) {
|
|
1221
1232
|
initialized.current = true;
|
|
@@ -2249,7 +2260,7 @@ function ReevitCheckout({
|
|
|
2249
2260
|
{
|
|
2250
2261
|
paymentId: paymentIntent?.id || "",
|
|
2251
2262
|
publicKey,
|
|
2252
|
-
merchantAccount:
|
|
2263
|
+
merchantAccount: paymentIntent?.pspCredentials?.merchantAccount || "",
|
|
2253
2264
|
amount: paymentIntent?.amount ?? amount,
|
|
2254
2265
|
currency: paymentIntent?.currency ?? currency,
|
|
2255
2266
|
reference: paymentIntent?.reference || reference,
|