@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/dist/index.d.cts
CHANGED
|
@@ -6,7 +6,7 @@ export { EnterpriseQuote } from '@moonpay/platform-protocol/api/enterprise';
|
|
|
6
6
|
export { CardResponse } from '@moonpay/platform-protocol/frames/add-card';
|
|
7
7
|
import * as ApplePayFrame$1 from '@moonpay/platform-protocol/frames/apple-pay';
|
|
8
8
|
export { ApplePayButtonSettings } from '@moonpay/platform-protocol/frames/apple-pay';
|
|
9
|
-
export { Cancellation as ChallengeCancellation, CompleteResult as ChallengeCompleteResult, ErrorCode as ChallengeErrorCode } from '@moonpay/platform-protocol/frames/challenge';
|
|
9
|
+
export { Cancellation as ChallengeCancellation, CompleteResult as ChallengeCompleteResult, ErrorCode as ChallengeErrorCode, ResolvedResult as ChallengeResolvedResult } from '@moonpay/platform-protocol/frames/challenge';
|
|
10
10
|
import { Connection } from '@moonpay/platform-protocol/models/connection';
|
|
11
11
|
export { Connection, ConnectionStatus } from '@moonpay/platform-protocol/models/connection';
|
|
12
12
|
import { Result } from '@moonpay/platform-protocol/result';
|
|
@@ -157,6 +157,15 @@ interface SetupChallengeOptions {
|
|
|
157
157
|
url: string;
|
|
158
158
|
/** Frame chrome. Defaults to the frame's own default (bare) when omitted. */
|
|
159
159
|
presentation?: PresentationMode;
|
|
160
|
+
/**
|
|
161
|
+
* Finish an Apple Pay / Google Pay buy on your own buy button instead of
|
|
162
|
+
* inside the challenge frame. When the buy challenges are resolved, the
|
|
163
|
+
* frame sends `resolved` instead of `complete` and the SDK closes its sheet:
|
|
164
|
+
* show your buy button again so the customer taps it to pay. If the frame
|
|
165
|
+
* can't hand the token over, it still finishes with `complete`.
|
|
166
|
+
* Defaults to `false`.
|
|
167
|
+
*/
|
|
168
|
+
resume?: boolean;
|
|
160
169
|
/** Callback for challenge frame lifecycle events. */
|
|
161
170
|
onEvent?: (event: ChallengeSdk.Event) => void;
|
|
162
171
|
}
|
|
@@ -437,6 +446,15 @@ declare function MoonPayBuyFrame({ quote, externalTransactionId, onEvent, webVie
|
|
|
437
446
|
interface MoonPayChallengeProps {
|
|
438
447
|
/** Full challenge URL received from a frame's `challenge` event. Mount-time only. */
|
|
439
448
|
url: string;
|
|
449
|
+
/**
|
|
450
|
+
* Finish an Apple Pay / Google Pay buy on your own buy button instead of
|
|
451
|
+
* inside the challenge frame. When the buy challenges are resolved, the
|
|
452
|
+
* frame sends `resolved` instead of `complete`: unmount this component and
|
|
453
|
+
* show your buy button again so the customer taps it to pay. If the frame
|
|
454
|
+
* can't hand the token over, it still finishes with `complete`.
|
|
455
|
+
* Defaults to `false`. Mount-time only.
|
|
456
|
+
*/
|
|
457
|
+
resume?: boolean;
|
|
440
458
|
/** Callback for challenge lifecycle events. */
|
|
441
459
|
onEvent?: (event: ChallengeSdk.Event) => void;
|
|
442
460
|
/** Container style. Defaults to flex: 1. */
|
|
@@ -445,7 +463,7 @@ interface MoonPayChallengeProps {
|
|
|
445
463
|
webViewProps?: Partial<WebViewProps>;
|
|
446
464
|
}
|
|
447
465
|
/** Inline 3DS/challenge frame. Mount it when a payment frame emits a `challenge` event. */
|
|
448
|
-
declare function MoonPayChallenge({ url, onEvent, style, webViewProps, }: MoonPayChallengeProps): JSX.Element;
|
|
466
|
+
declare function MoonPayChallenge({ url, resume, onEvent, style, webViewProps, }: MoonPayChallengeProps): JSX.Element;
|
|
449
467
|
|
|
450
468
|
interface MoonPayConnectProps {
|
|
451
469
|
/** Theme for this connect frame. Overrides the provider-level `theme`. Mount-time only. */
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export { EnterpriseQuote } from '@moonpay/platform-protocol/api/enterprise';
|
|
|
6
6
|
export { CardResponse } from '@moonpay/platform-protocol/frames/add-card';
|
|
7
7
|
import * as ApplePayFrame$1 from '@moonpay/platform-protocol/frames/apple-pay';
|
|
8
8
|
export { ApplePayButtonSettings } from '@moonpay/platform-protocol/frames/apple-pay';
|
|
9
|
-
export { Cancellation as ChallengeCancellation, CompleteResult as ChallengeCompleteResult, ErrorCode as ChallengeErrorCode } from '@moonpay/platform-protocol/frames/challenge';
|
|
9
|
+
export { Cancellation as ChallengeCancellation, CompleteResult as ChallengeCompleteResult, ErrorCode as ChallengeErrorCode, ResolvedResult as ChallengeResolvedResult } from '@moonpay/platform-protocol/frames/challenge';
|
|
10
10
|
import { Connection } from '@moonpay/platform-protocol/models/connection';
|
|
11
11
|
export { Connection, ConnectionStatus } from '@moonpay/platform-protocol/models/connection';
|
|
12
12
|
import { Result } from '@moonpay/platform-protocol/result';
|
|
@@ -157,6 +157,15 @@ interface SetupChallengeOptions {
|
|
|
157
157
|
url: string;
|
|
158
158
|
/** Frame chrome. Defaults to the frame's own default (bare) when omitted. */
|
|
159
159
|
presentation?: PresentationMode;
|
|
160
|
+
/**
|
|
161
|
+
* Finish an Apple Pay / Google Pay buy on your own buy button instead of
|
|
162
|
+
* inside the challenge frame. When the buy challenges are resolved, the
|
|
163
|
+
* frame sends `resolved` instead of `complete` and the SDK closes its sheet:
|
|
164
|
+
* show your buy button again so the customer taps it to pay. If the frame
|
|
165
|
+
* can't hand the token over, it still finishes with `complete`.
|
|
166
|
+
* Defaults to `false`.
|
|
167
|
+
*/
|
|
168
|
+
resume?: boolean;
|
|
160
169
|
/** Callback for challenge frame lifecycle events. */
|
|
161
170
|
onEvent?: (event: ChallengeSdk.Event) => void;
|
|
162
171
|
}
|
|
@@ -437,6 +446,15 @@ declare function MoonPayBuyFrame({ quote, externalTransactionId, onEvent, webVie
|
|
|
437
446
|
interface MoonPayChallengeProps {
|
|
438
447
|
/** Full challenge URL received from a frame's `challenge` event. Mount-time only. */
|
|
439
448
|
url: string;
|
|
449
|
+
/**
|
|
450
|
+
* Finish an Apple Pay / Google Pay buy on your own buy button instead of
|
|
451
|
+
* inside the challenge frame. When the buy challenges are resolved, the
|
|
452
|
+
* frame sends `resolved` instead of `complete`: unmount this component and
|
|
453
|
+
* show your buy button again so the customer taps it to pay. If the frame
|
|
454
|
+
* can't hand the token over, it still finishes with `complete`.
|
|
455
|
+
* Defaults to `false`. Mount-time only.
|
|
456
|
+
*/
|
|
457
|
+
resume?: boolean;
|
|
440
458
|
/** Callback for challenge lifecycle events. */
|
|
441
459
|
onEvent?: (event: ChallengeSdk.Event) => void;
|
|
442
460
|
/** Container style. Defaults to flex: 1. */
|
|
@@ -445,7 +463,7 @@ interface MoonPayChallengeProps {
|
|
|
445
463
|
webViewProps?: Partial<WebViewProps>;
|
|
446
464
|
}
|
|
447
465
|
/** Inline 3DS/challenge frame. Mount it when a payment frame emits a `challenge` event. */
|
|
448
|
-
declare function MoonPayChallenge({ url, onEvent, style, webViewProps, }: MoonPayChallengeProps): JSX.Element;
|
|
466
|
+
declare function MoonPayChallenge({ url, resume, onEvent, style, webViewProps, }: MoonPayChallengeProps): JSX.Element;
|
|
449
467
|
|
|
450
468
|
interface MoonPayConnectProps {
|
|
451
469
|
/** Theme for this connect frame. Overrides the provider-level `theme`. Mount-time only. */
|
package/dist/index.js
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
import {
|
|
10
10
|
applyClientTokenParam,
|
|
11
11
|
applyPresentationParam,
|
|
12
|
+
applyResumeParam,
|
|
12
13
|
decryptCredentials,
|
|
13
14
|
FRAME_PATHS,
|
|
14
15
|
presentationParams,
|
|
@@ -430,9 +431,12 @@ var challengeSpec = {
|
|
|
430
431
|
buildUrl: (ctx, props, channelId) => {
|
|
431
432
|
const url = new URL(props.url);
|
|
432
433
|
url.searchParams.set("channelId", channelId);
|
|
433
|
-
return
|
|
434
|
-
|
|
435
|
-
|
|
434
|
+
return applyResumeParam(
|
|
435
|
+
applyClientTokenParam(
|
|
436
|
+
applyPresentationParam(url.toString(), props.presentation),
|
|
437
|
+
ctx.core.context.clientToken
|
|
438
|
+
),
|
|
439
|
+
props.resume
|
|
436
440
|
);
|
|
437
441
|
},
|
|
438
442
|
mapMessage: (msg) => {
|
|
@@ -443,6 +447,8 @@ var challengeSpec = {
|
|
|
443
447
|
return { kind: "buttonPressed" };
|
|
444
448
|
case "complete":
|
|
445
449
|
return { kind: "complete", payload: msg.payload };
|
|
450
|
+
case "resolved":
|
|
451
|
+
return { kind: "resolved", payload: msg.payload };
|
|
446
452
|
case "cancelled":
|
|
447
453
|
return { kind: "cancelled", payload: msg.payload };
|
|
448
454
|
case "error":
|
|
@@ -849,7 +855,8 @@ async function setupChallenge(deps, opts) {
|
|
|
849
855
|
try {
|
|
850
856
|
const { handle, dispose } = await deps.mountSession(challengeSpec, {
|
|
851
857
|
url: opts.url,
|
|
852
|
-
presentation: opts.presentation
|
|
858
|
+
presentation: opts.presentation,
|
|
859
|
+
resume: opts.resume
|
|
853
860
|
});
|
|
854
861
|
handle.onEvent((event) => opts.onEvent?.(event));
|
|
855
862
|
return ok6({ dispose });
|
|
@@ -1084,6 +1091,11 @@ import {
|
|
|
1084
1091
|
} from "react-native";
|
|
1085
1092
|
|
|
1086
1093
|
// src/sheet-presentation.ts
|
|
1094
|
+
function presentationSignalFor(kind) {
|
|
1095
|
+
if (kind === "ready") return "ready";
|
|
1096
|
+
if (kind === "complete" || kind === "error" || kind === "resolved") return "terminal";
|
|
1097
|
+
return null;
|
|
1098
|
+
}
|
|
1087
1099
|
var NOOP = {
|
|
1088
1100
|
present: false,
|
|
1089
1101
|
liftSpinner: false,
|
|
@@ -1198,8 +1210,8 @@ function VisibleFrameSlotSheet({
|
|
|
1198
1210
|
}, [dispatch]);
|
|
1199
1211
|
useEffect2(() => {
|
|
1200
1212
|
const unsubscribe = slot.transport.onMessage((msg) => {
|
|
1201
|
-
|
|
1202
|
-
|
|
1213
|
+
const signal = presentationSignalFor(msg.kind);
|
|
1214
|
+
if (signal) dispatch(signal);
|
|
1203
1215
|
});
|
|
1204
1216
|
return unsubscribe;
|
|
1205
1217
|
}, [slot.transport, dispatch]);
|
|
@@ -1608,6 +1620,7 @@ function MoonPayBuyFrame({
|
|
|
1608
1620
|
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
1609
1621
|
function MoonPayChallenge({
|
|
1610
1622
|
url,
|
|
1623
|
+
resume,
|
|
1611
1624
|
onEvent,
|
|
1612
1625
|
style,
|
|
1613
1626
|
webViewProps
|
|
@@ -1616,7 +1629,7 @@ function MoonPayChallenge({
|
|
|
1616
1629
|
MoonPayFrameView,
|
|
1617
1630
|
{
|
|
1618
1631
|
spec: challengeSpec,
|
|
1619
|
-
props: { url },
|
|
1632
|
+
props: { url, resume },
|
|
1620
1633
|
style,
|
|
1621
1634
|
defaultStyle: { flex: 1 },
|
|
1622
1635
|
onEvent,
|