@outerjoyn/react-native 1.7.2 → 1.8.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
CHANGED
|
@@ -133,7 +133,7 @@ zero-point checkout.
|
|
|
133
133
|
|-----------|-------------|
|
|
134
134
|
| `<LoyaltyBanner>` | Home/product page banner. Brand logos + balance. |
|
|
135
135
|
| `<BalanceSummary>` | Balance display: `compact`, `card`, or `inline` layout. |
|
|
136
|
-
| `<CheckoutPointsApply>` | Per-program sliders at checkout. Brand-colored tracks. |
|
|
136
|
+
| `<CheckoutPointsApply>` | Per-program sliders at checkout. Brand-colored tracks. Pass your order number as `merchantOrderId`, and the same number to `POST /api/sdk/earn/submit` when the order completes. |
|
|
137
137
|
| `<LoyaltyProfileSection>` | Profile card with linked programs + unlink. |
|
|
138
138
|
| `<PostCheckoutSavePrompt>` | Post-checkout phone OTP to save programs. |
|
|
139
139
|
|
package/package.json
CHANGED
|
@@ -84,6 +84,13 @@ export interface CheckoutPointsApplyHandle {
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
export interface CheckoutPointsApplyProps {
|
|
87
|
+
/**
|
|
88
|
+
* The store's own order number (required). Every program the shopper applies
|
|
89
|
+
* is held under it, so the purchase you record afterwards (POST
|
|
90
|
+
* /api/sdk/earn/submit with the same merchantOrderId) knows what points paid
|
|
91
|
+
* and earns only on the rest.
|
|
92
|
+
*/
|
|
93
|
+
merchantOrderId: string;
|
|
87
94
|
/** Order total in integer MINOR UNITS of the order currency (required) —
|
|
88
95
|
* cents for USD ($50.00 = 5000), whole yen for JPY (¥1,850 = 1850). */
|
|
89
96
|
orderTotalCents: number;
|
|
@@ -132,6 +139,7 @@ export const CheckoutPointsApply = forwardRef<CheckoutPointsApplyHandle, Checkou
|
|
|
132
139
|
onPointsChanged,
|
|
133
140
|
onLinkAnother,
|
|
134
141
|
style,
|
|
142
|
+
merchantOrderId,
|
|
135
143
|
}: CheckoutPointsApplyProps, ref) {
|
|
136
144
|
const ctx = useOuterJoyn();
|
|
137
145
|
const { isReady, isLinked, linkedPrograms, loading, demoMode, apiClient, redemptionRules, t } = ctx;
|
|
@@ -260,7 +268,7 @@ export const CheckoutPointsApply = forwardRef<CheckoutPointsApplyHandle, Checkou
|
|
|
260
268
|
valueAmount?: number;
|
|
261
269
|
}>;
|
|
262
270
|
}>('/api/sdk/pay/checkout', {
|
|
263
|
-
merchantOrderId
|
|
271
|
+
merchantOrderId,
|
|
264
272
|
orderTotalCents: validOrderTotal,
|
|
265
273
|
currencyCode: orderCurrency,
|
|
266
274
|
...breakdown,
|
|
@@ -303,7 +311,7 @@ export const CheckoutPointsApply = forwardRef<CheckoutPointsApplyHandle, Checkou
|
|
|
303
311
|
setApiLoading((prev) => ({ ...prev, [progId]: false }));
|
|
304
312
|
}
|
|
305
313
|
},
|
|
306
|
-
[programs, sliderValues, demoMode, apiClient, orderTotalCents, merchandiseSubtotalCents, taxCents, shippingCents, currencyCode, buildPayload, onPointsChanged, redemptionTokens, redemptionRules],
|
|
314
|
+
[programs, sliderValues, demoMode, apiClient, orderTotalCents, merchandiseSubtotalCents, taxCents, shippingCents, currencyCode, merchantOrderId, buildPayload, onPointsChanged, redemptionTokens, redemptionRules],
|
|
307
315
|
);
|
|
308
316
|
|
|
309
317
|
const handleRemove = useCallback(
|
package/src/core/version.ts
CHANGED
|
@@ -43,7 +43,7 @@ import {
|
|
|
43
43
|
} from 'react-native';
|
|
44
44
|
import * as WebBrowser from 'expo-web-browser';
|
|
45
45
|
import { OuterJoynContext } from '../OuterJoynProvider';
|
|
46
|
-
import { APIClient } from '../core/api-client';
|
|
46
|
+
import { APIClient, SDKError } from '../core/api-client';
|
|
47
47
|
import { createPortabilityHandoff, getPortabilityHandoffAvailable, getPortabilityHandoffStatus } from '../core/portabilityHandoff';
|
|
48
48
|
|
|
49
49
|
const OJ_LOGO_URL = 'https://app.outerjoyn.com/outerjoyn-logo.png';
|
|
@@ -97,7 +97,9 @@ export interface ConnectScreenProps {
|
|
|
97
97
|
sessionToken?: string;
|
|
98
98
|
/** Override API base URL (reads from context if omitted) */
|
|
99
99
|
apiBaseUrl?: string;
|
|
100
|
-
/**
|
|
100
|
+
/** Open straight on this partner program's consent step (the web SDK's
|
|
101
|
+
* `preselectedBrandId`). A program this store can't link is an error
|
|
102
|
+
* (onError code `partner_not_linkable`), never the list. */
|
|
101
103
|
preselectedInstitutionId?: string;
|
|
102
104
|
}
|
|
103
105
|
|
|
@@ -341,13 +343,24 @@ export const ConnectScreen: React.FC<ConnectScreenProps> = ({
|
|
|
341
343
|
|
|
342
344
|
setStep('search');
|
|
343
345
|
|
|
344
|
-
const activeList = list;
|
|
345
346
|
if (preselectedInstitutionId) {
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
347
|
+
// Asked of the server, which says whether this store can link it: the
|
|
348
|
+
// full list is capped, so a missing row there proves nothing.
|
|
349
|
+
const only = await client.get<{ institutions: Institution[] }>(
|
|
350
|
+
`/api/sdk/institutions?program=${encodeURIComponent(preselectedInstitutionId)}`,
|
|
351
|
+
);
|
|
352
|
+
const match = (only?.institutions || []).find(
|
|
353
|
+
(i) => i.institution_id === preselectedInstitutionId && i.is_active !== false,
|
|
354
|
+
);
|
|
355
|
+
if (!match) {
|
|
356
|
+
const message = 'This program can\u2019t be linked from this store.';
|
|
357
|
+
setErrorMessage(message);
|
|
358
|
+
setStep('error');
|
|
359
|
+
onError?.(new SDKError('partner_not_linkable', message, { param: 'preselectedInstitutionId' }));
|
|
360
|
+
return;
|
|
350
361
|
}
|
|
362
|
+
setSelectedInstitution(match);
|
|
363
|
+
setStep('consent');
|
|
351
364
|
}
|
|
352
365
|
} catch (err: any) {
|
|
353
366
|
console.warn('[OuterJoyn] ConnectScreen loadData failed:', err.message);
|