@paypal/checkout-components 5.0.257 → 5.0.258

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paypal/checkout-components",
3
- "version": "5.0.257",
3
+ "version": "5.0.258",
4
4
  "description": "PayPal Checkout components, for integrating checkout products.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -55,6 +55,7 @@ export const BUTTON_FLOW = {
55
55
  PURCHASE: ("purchase": "purchase"),
56
56
  BILLING_SETUP: ("billing_setup": "billing_setup"),
57
57
  SUBSCRIPTION_SETUP: ("subscription_setup": "subscription_setup"),
58
+ VAULT_WITHOUT_PURCHASE: ("vault_without_purchase": "vault_without_purchase"),
58
59
  };
59
60
 
60
61
  export const MENU_PLACEMENT = {
@@ -17,6 +17,7 @@ export function getPayPalConfig(): FundingSourceConfig {
17
17
  BUTTON_FLOW.PURCHASE,
18
18
  BUTTON_FLOW.BILLING_SETUP,
19
19
  BUTTON_FLOW.SUBSCRIPTION_SETUP,
20
+ BUTTON_FLOW.VAULT_WITHOUT_PURCHASE,
20
21
  ],
21
22
 
22
23
  layouts: [BUTTON_LAYOUT.VERTICAL, BUTTON_LAYOUT.HORIZONTAL],
@@ -67,6 +67,8 @@ export type OnCompleteData = {||};
67
67
 
68
68
  export type CreateBillingAgreement = () => ZalgoPromise<string> | string;
69
69
 
70
+ export type CreateVaultSetupToken = () => ZalgoPromise<string>;
71
+
70
72
  export type CreateSubscriptionRequest = {||};
71
73
  export type SubscriptionResponse = {||} | {||};
72
74
  export type CreateSubscriptionData = {||} | {||};
@@ -515,6 +517,7 @@ export type ButtonProps = {|
515
517
  meta: {||},
516
518
  renderedButtons: $ReadOnlyArray<$Values<typeof FUNDING>>,
517
519
  experience: string,
520
+ createVaultSetupToken: CreateVaultSetupToken,
518
521
  |};
519
522
 
520
523
  // eslint-disable-next-line flowtype/require-exact-type
@@ -181,11 +181,13 @@ export const getButtonsComponent: () => ButtonsComponent = memoize(() => {
181
181
  experiment = getButtonExperiments(),
182
182
  createBillingAgreement,
183
183
  createSubscription,
184
+ createVaultSetupToken,
184
185
  } = props;
185
186
 
186
187
  const flow = determineFlow({
187
188
  createBillingAgreement,
188
189
  createSubscription,
190
+ createVaultSetupToken,
189
191
  });
190
192
  const applePaySupport = fundingEligibility?.applepay?.eligible
191
193
  ? isApplePaySupported()
@@ -264,11 +266,13 @@ export const getButtonsComponent: () => ButtonsComponent = memoize(() => {
264
266
  supportedNativeBrowser,
265
267
  createBillingAgreement,
266
268
  createSubscription,
269
+ createVaultSetupToken,
267
270
  } = props;
268
271
 
269
272
  const flow = determineFlow({
270
273
  createBillingAgreement,
271
274
  createSubscription,
275
+ createVaultSetupToken,
272
276
  });
273
277
  const { layout } = style;
274
278
 
@@ -602,8 +606,16 @@ export const getButtonsComponent: () => ButtonsComponent = memoize(() => {
602
606
  type: "string",
603
607
  queryParam: true,
604
608
  value: ({ props }) => {
605
- const { createBillingAgreement, createSubscription } = props;
606
- return determineFlow({ createBillingAgreement, createSubscription });
609
+ const {
610
+ createBillingAgreement,
611
+ createSubscription,
612
+ createVaultSetupToken,
613
+ } = props;
614
+ return determineFlow({
615
+ createBillingAgreement,
616
+ createSubscription,
617
+ createVaultSetupToken,
618
+ });
607
619
  },
608
620
  },
609
621
 
@@ -841,6 +853,10 @@ export const getButtonsComponent: () => ButtonsComponent = memoize(() => {
841
853
  required: false,
842
854
  default: () => true,
843
855
  },
856
+ createVaultSetupToken: {
857
+ type: "function",
858
+ required: false,
859
+ },
844
860
  },
845
861
  });
846
862
  });
@@ -35,6 +35,7 @@ import type {
35
35
  CreateBillingAgreement,
36
36
  CreateSubscription,
37
37
  ButtonProps,
38
+ CreateVaultSetupToken,
38
39
  } from "../../ui/buttons/props";
39
40
  import { determineEligibleFunding } from "../../funding";
40
41
  import { BUTTON_SIZE_STYLE } from "../../ui/buttons/config";
@@ -42,6 +43,7 @@ import { BUTTON_SIZE_STYLE } from "../../ui/buttons/config";
42
43
  type DetermineFlowOptions = {|
43
44
  createBillingAgreement: CreateBillingAgreement,
44
45
  createSubscription: CreateSubscription,
46
+ createVaultSetupToken: CreateVaultSetupToken,
45
47
  |};
46
48
 
47
49
  /**
@@ -77,7 +79,9 @@ const logNativeScreenInformation = once((key = "screenInformation") => {
77
79
  export function determineFlow(
78
80
  props: DetermineFlowOptions
79
81
  ): $Values<typeof BUTTON_FLOW> {
80
- if (props.createBillingAgreement) {
82
+ if (props.createVaultSetupToken) {
83
+ return BUTTON_FLOW.VAULT_WITHOUT_PURCHASE;
84
+ } else if (props.createBillingAgreement) {
81
85
  return BUTTON_FLOW.BILLING_SETUP;
82
86
  } else if (props.createSubscription) {
83
87
  return BUTTON_FLOW.SUBSCRIPTION_SETUP;
@@ -203,9 +207,14 @@ export function getRenderedButtons(
203
207
  supportedNativeBrowser = isSupportedNativeBrowser(),
204
208
  createBillingAgreement,
205
209
  createSubscription,
210
+ createVaultSetupToken,
206
211
  } = props;
207
212
 
208
- const flow = determineFlow({ createBillingAgreement, createSubscription });
213
+ const flow = determineFlow({
214
+ createBillingAgreement,
215
+ createSubscription,
216
+ createVaultSetupToken,
217
+ });
209
218
  const { layout } = style;
210
219
  const remembered = [];
211
220
  const platform = getPlatform();
@@ -1,45 +0,0 @@
1
- /* @flow */
2
-
3
- import { ZalgoPromise } from "@krakenjs/zalgo-promise/src";
4
-
5
- import { ValidationError } from "../../lib";
6
-
7
- type SaveActionConfig = {|
8
- createVaultSetupToken: () => ZalgoPromise<string>,
9
- onApprove: ({| vaultSetupToken: string |}) => void,
10
- |};
11
-
12
- export type CreateSaveAction = (config: SaveActionConfig) => {|
13
- type: "SAVE",
14
- ...SaveActionConfig,
15
- |};
16
-
17
- /**
18
- * These are the input configurations required from the merchant.
19
- */
20
- const REQUIRED_INPUTS = {
21
- onApprove: "function",
22
- createVaultSetupToken: "function",
23
- };
24
-
25
- const validateSaveConfig = (config: SaveActionConfig): void => {
26
- for (const [inputProp, inputType] of Object.entries(REQUIRED_INPUTS)) {
27
- if (!config[inputProp] || typeof config[inputProp] !== inputType) {
28
- throw new ValidationError(
29
- `Save action is missing the required '${inputProp}' callback`
30
- );
31
- }
32
- }
33
- };
34
-
35
- /**
36
- * Creating a Save action allows us to validate initial inputs from the merchant, and then return the resulting object.
37
- */
38
- export const createSaveAction: CreateSaveAction = (config) => {
39
- validateSaveConfig(config);
40
-
41
- return {
42
- type: "SAVE",
43
- ...config,
44
- };
45
- };
@@ -1,14 +0,0 @@
1
- /* @flow */
2
-
3
- import type { LazyProtectedExport } from "../types";
4
- import { createSaveAction, type CreateSaveAction } from "../actions/save";
5
- import { protectedExport } from "../lib";
6
-
7
- export const actions: LazyProtectedExport<{|
8
- Save: CreateSaveAction,
9
- |}> = {
10
- __get__: () =>
11
- protectedExport({
12
- Save: createSaveAction,
13
- }),
14
- };