@moonpay/platform-sdk-react-native 1.26.1 → 1.27.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 +2 -0
- package/dist/index.cjs +19 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +20 -2
- package/dist/index.d.ts +20 -2
- package/dist/index.js +20 -7
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -374,6 +374,8 @@ import { MoonPayChallenge } from '@moonpay/platform-sdk-react-native';
|
|
|
374
374
|
)}
|
|
375
375
|
```
|
|
376
376
|
|
|
377
|
+
To finish an Apple Pay or Google Pay buy on your own buy button instead of inside the challenge frame, pass `resume`. Once the buy challenges are resolved, the frame sends `resolved` instead of `complete`: unmount `<MoonPayChallenge>` and show your buy button again so the customer taps it to pay. If the frame can't hand the token over, it still finishes with `complete`.
|
|
378
|
+
|
|
377
379
|
## Error handling
|
|
378
380
|
|
|
379
381
|
Methods never throw — they return `Result<T, E>`:
|
package/dist/index.cjs
CHANGED
|
@@ -472,9 +472,12 @@ var challengeSpec = {
|
|
|
472
472
|
buildUrl: (ctx, props, channelId) => {
|
|
473
473
|
const url = new URL(props.url);
|
|
474
474
|
url.searchParams.set("channelId", channelId);
|
|
475
|
-
return (0, import_platform_sdk_core.
|
|
476
|
-
(0, import_platform_sdk_core.
|
|
477
|
-
|
|
475
|
+
return (0, import_platform_sdk_core.applyResumeParam)(
|
|
476
|
+
(0, import_platform_sdk_core.applyClientTokenParam)(
|
|
477
|
+
(0, import_platform_sdk_core.applyPresentationParam)(url.toString(), props.presentation),
|
|
478
|
+
ctx.core.context.clientToken
|
|
479
|
+
),
|
|
480
|
+
props.resume
|
|
478
481
|
);
|
|
479
482
|
},
|
|
480
483
|
mapMessage: (msg) => {
|
|
@@ -485,6 +488,8 @@ var challengeSpec = {
|
|
|
485
488
|
return { kind: "buttonPressed" };
|
|
486
489
|
case "complete":
|
|
487
490
|
return { kind: "complete", payload: msg.payload };
|
|
491
|
+
case "resolved":
|
|
492
|
+
return { kind: "resolved", payload: msg.payload };
|
|
488
493
|
case "cancelled":
|
|
489
494
|
return { kind: "cancelled", payload: msg.payload };
|
|
490
495
|
case "error":
|
|
@@ -876,7 +881,8 @@ async function setupChallenge(deps, opts) {
|
|
|
876
881
|
try {
|
|
877
882
|
const { handle, dispose } = await deps.mountSession(challengeSpec, {
|
|
878
883
|
url: opts.url,
|
|
879
|
-
presentation: opts.presentation
|
|
884
|
+
presentation: opts.presentation,
|
|
885
|
+
resume: opts.resume
|
|
880
886
|
});
|
|
881
887
|
handle.onEvent((event) => opts.onEvent?.(event));
|
|
882
888
|
return (0, import_result6.ok)({ dispose });
|
|
@@ -1100,6 +1106,11 @@ var import_react2 = require("react");
|
|
|
1100
1106
|
var import_react_native2 = require("react-native");
|
|
1101
1107
|
|
|
1102
1108
|
// src/sheet-presentation.ts
|
|
1109
|
+
function presentationSignalFor(kind) {
|
|
1110
|
+
if (kind === "ready") return "ready";
|
|
1111
|
+
if (kind === "complete" || kind === "error" || kind === "resolved") return "terminal";
|
|
1112
|
+
return null;
|
|
1113
|
+
}
|
|
1103
1114
|
var NOOP = {
|
|
1104
1115
|
present: false,
|
|
1105
1116
|
liftSpinner: false,
|
|
@@ -1214,8 +1225,8 @@ function VisibleFrameSlotSheet({
|
|
|
1214
1225
|
}, [dispatch]);
|
|
1215
1226
|
(0, import_react2.useEffect)(() => {
|
|
1216
1227
|
const unsubscribe = slot.transport.onMessage((msg) => {
|
|
1217
|
-
|
|
1218
|
-
|
|
1228
|
+
const signal = presentationSignalFor(msg.kind);
|
|
1229
|
+
if (signal) dispatch(signal);
|
|
1219
1230
|
});
|
|
1220
1231
|
return unsubscribe;
|
|
1221
1232
|
}, [slot.transport, dispatch]);
|
|
@@ -1624,6 +1635,7 @@ function MoonPayBuyFrame({
|
|
|
1624
1635
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1625
1636
|
function MoonPayChallenge({
|
|
1626
1637
|
url,
|
|
1638
|
+
resume,
|
|
1627
1639
|
onEvent,
|
|
1628
1640
|
style,
|
|
1629
1641
|
webViewProps
|
|
@@ -1632,7 +1644,7 @@ function MoonPayChallenge({
|
|
|
1632
1644
|
MoonPayFrameView,
|
|
1633
1645
|
{
|
|
1634
1646
|
spec: challengeSpec,
|
|
1635
|
-
props: { url },
|
|
1647
|
+
props: { url, resume },
|
|
1636
1648
|
style,
|
|
1637
1649
|
defaultStyle: { flex: 1 },
|
|
1638
1650
|
onEvent,
|