@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.mjs
CHANGED
|
@@ -1083,7 +1083,9 @@ function HubtelBridge({
|
|
|
1083
1083
|
publicKey,
|
|
1084
1084
|
merchantAccount,
|
|
1085
1085
|
amount,
|
|
1086
|
+
currency,
|
|
1086
1087
|
reference,
|
|
1088
|
+
email,
|
|
1087
1089
|
phone,
|
|
1088
1090
|
description = "Payment",
|
|
1089
1091
|
callbackUrl,
|
|
@@ -1098,7 +1100,6 @@ function HubtelBridge({
|
|
|
1098
1100
|
autoStart = true
|
|
1099
1101
|
}) {
|
|
1100
1102
|
const initialized = useRef(false);
|
|
1101
|
-
const checkoutRef = useRef(null);
|
|
1102
1103
|
const [authValue, setAuthValue] = useState("");
|
|
1103
1104
|
const [isLoading, setIsLoading] = useState(false);
|
|
1104
1105
|
const [resolvedMerchantAccount, setResolvedMerchantAccount] = useState(merchantAccount);
|
|
@@ -1112,19 +1113,17 @@ function HubtelBridge({
|
|
|
1112
1113
|
try {
|
|
1113
1114
|
const client = createReevitClient({ publicKey, baseUrl: apiBaseUrl });
|
|
1114
1115
|
const { data, error } = await client.createHubtelSession(paymentId, clientSecret);
|
|
1115
|
-
if (error) {
|
|
1116
|
+
if (error || !data?.basicAuth) {
|
|
1116
1117
|
onError({
|
|
1117
1118
|
code: "SESSION_ERROR",
|
|
1118
|
-
message: error
|
|
1119
|
+
message: error?.message || "Failed to create Hubtel session",
|
|
1119
1120
|
recoverable: true
|
|
1120
1121
|
});
|
|
1121
1122
|
return;
|
|
1122
1123
|
}
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
setResolvedMerchantAccount(data.merchantAccount);
|
|
1127
|
-
}
|
|
1124
|
+
setAuthValue(data.basicAuth);
|
|
1125
|
+
if (data.merchantAccount) {
|
|
1126
|
+
setResolvedMerchantAccount(data.merchantAccount);
|
|
1128
1127
|
}
|
|
1129
1128
|
} catch (err) {
|
|
1130
1129
|
onError({
|
|
@@ -1148,13 +1147,13 @@ function HubtelBridge({
|
|
|
1148
1147
|
}
|
|
1149
1148
|
try {
|
|
1150
1149
|
const checkout = new CheckoutSdk();
|
|
1151
|
-
checkoutRef.current = checkout;
|
|
1152
1150
|
const methodPreference = preferredMethod === "mobile_money" ? "momo" : preferredMethod === "card" ? "card" : void 0;
|
|
1153
1151
|
const purchaseInfo = {
|
|
1154
1152
|
amount: amount / 100,
|
|
1155
1153
|
// Convert from minor to major units
|
|
1156
1154
|
purchaseDescription: description,
|
|
1157
1155
|
customerPhoneNumber: phone || "",
|
|
1156
|
+
...email ? { customerEmail: email } : {},
|
|
1158
1157
|
clientReference: reference || `hubtel_${Date.now()}`,
|
|
1159
1158
|
...methodPreference ? { paymentMethod: methodPreference } : {}
|
|
1160
1159
|
};
|
|
@@ -1162,8 +1161,6 @@ function HubtelBridge({
|
|
|
1162
1161
|
branding: "enabled",
|
|
1163
1162
|
callbackUrl: callbackUrl || window.location.href,
|
|
1164
1163
|
merchantAccount: typeof resolvedMerchantAccount === "string" ? parseInt(resolvedMerchantAccount, 10) : resolvedMerchantAccount,
|
|
1165
|
-
// Use session token or basicAuth for authentication
|
|
1166
|
-
// Session tokens are base64-encoded credentials fetched securely from the server
|
|
1167
1164
|
basicAuth: authValue || "",
|
|
1168
1165
|
...methodPreference ? { paymentMethod: methodPreference } : {}
|
|
1169
1166
|
};
|
|
@@ -1177,8 +1174,8 @@ function HubtelBridge({
|
|
|
1177
1174
|
paymentId: data.transactionId || reference || "",
|
|
1178
1175
|
reference: data.clientReference || reference || "",
|
|
1179
1176
|
amount,
|
|
1180
|
-
currency: "GHS",
|
|
1181
|
-
paymentMethod: "mobile_money",
|
|
1177
|
+
currency: currency || "GHS",
|
|
1178
|
+
paymentMethod: preferredMethod || "mobile_money",
|
|
1182
1179
|
psp: "hubtel",
|
|
1183
1180
|
pspReference: data.transactionId || "",
|
|
1184
1181
|
status: "success"
|
|
@@ -1209,7 +1206,21 @@ function HubtelBridge({
|
|
|
1209
1206
|
};
|
|
1210
1207
|
onError(error);
|
|
1211
1208
|
}
|
|
1212
|
-
}, [
|
|
1209
|
+
}, [
|
|
1210
|
+
amount,
|
|
1211
|
+
reference,
|
|
1212
|
+
phone,
|
|
1213
|
+
description,
|
|
1214
|
+
callbackUrl,
|
|
1215
|
+
authValue,
|
|
1216
|
+
isLoading,
|
|
1217
|
+
preferredMethod,
|
|
1218
|
+
onSuccess,
|
|
1219
|
+
onError,
|
|
1220
|
+
onClose,
|
|
1221
|
+
resolvedMerchantAccount,
|
|
1222
|
+
currency
|
|
1223
|
+
]);
|
|
1213
1224
|
useEffect(() => {
|
|
1214
1225
|
if (autoStart && !initialized.current && !isLoading && authValue) {
|
|
1215
1226
|
initialized.current = true;
|
|
@@ -2243,7 +2254,7 @@ function ReevitCheckout({
|
|
|
2243
2254
|
{
|
|
2244
2255
|
paymentId: paymentIntent?.id || "",
|
|
2245
2256
|
publicKey,
|
|
2246
|
-
merchantAccount:
|
|
2257
|
+
merchantAccount: paymentIntent?.pspCredentials?.merchantAccount || "",
|
|
2247
2258
|
amount: paymentIntent?.amount ?? amount,
|
|
2248
2259
|
currency: paymentIntent?.currency ?? currency,
|
|
2249
2260
|
reference: paymentIntent?.reference || reference,
|