@paypal/checkout-components 5.0.303-alpha.0 → 5.0.303

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.303-alpha.0",
3
+ "version": "5.0.303",
4
4
  "description": "PayPal Checkout components, for integrating checkout products.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -123,7 +123,7 @@ export function getCardConfig(): FundingSourceConfig {
123
123
  BUTTON_FLOW.SUBSCRIPTION_SETUP,
124
124
  ],
125
125
 
126
- layouts: [BUTTON_LAYOUT.HORIZONTAL, BUTTON_LAYOUT.VERTICAL],
126
+ layouts: [BUTTON_LAYOUT.VERTICAL],
127
127
 
128
128
  maxCards: maxCardForCountry,
129
129
 
@@ -7,7 +7,6 @@ import {
7
7
  getClientID,
8
8
  getMerchantID as getSDKMerchantID,
9
9
  } from "@paypal/sdk-client/src";
10
- import { FUNDING } from "@paypal/sdk-constants/src";
11
10
 
12
11
  import type {
13
12
  ButtonVariables,
@@ -209,14 +208,6 @@ export const buildHostedButtonOnApprove = ({
209
208
  merchant_id: merchantId,
210
209
  context_id: data.orderID,
211
210
  }),
212
- }).then((response) => {
213
- // The "Debit or Credit Card" button does not open a popup
214
- // so we need to redirect to the thank you page for buyers who complete
215
- // a checkout via "Debit or Credit Card".
216
- if (data.paymentSource === FUNDING.CARD) {
217
- window.location = `${baseUrl}/ncp/payment/${hostedButtonId}/${data.orderID}`;
218
- }
219
- return response;
220
211
  });
221
212
  };
222
213
  };
@@ -264,28 +264,6 @@ describe("buildHostedButtonOnApprove", () => {
264
264
  );
265
265
  expect.assertions(1);
266
266
  });
267
-
268
- describe("inline guest", () => {
269
- const onApprove = buildHostedButtonOnApprove({
270
- hostedButtonId,
271
- merchantId,
272
- });
273
- // $FlowIssue
274
- request.mockImplementation(() =>
275
- // eslint-disable-next-line compat/compat
276
- Promise.resolve({
277
- body: {},
278
- })
279
- );
280
-
281
- test("redirects from the merchant's site to a thank you page", async () => {
282
- expect(window.location.href).toBe("http://localhost:3000/");
283
- await onApprove({ orderID, paymentSource: "card" });
284
- expect(window.location).toBe(
285
- "https://example.com/ncp/payment/B1234567890/EC-1234567890"
286
- );
287
- });
288
- });
289
267
  });
290
268
 
291
269
  /* eslint-enable no-restricted-globals, promise/no-native */
@@ -288,10 +288,7 @@ export function Buttons(props: ButtonsProps): ElementNode {
288
288
  />
289
289
  ))}
290
290
 
291
- {tagline &&
292
- layout === BUTTON_LAYOUT.HORIZONTAL &&
293
- !fundingSource &&
294
- !fundingSources.includes(FUNDING.CARD) ? (
291
+ {tagline && layout === BUTTON_LAYOUT.HORIZONTAL && !fundingSource ? (
295
292
  <TagLine
296
293
  fundingSource={fundingSources[0]}
297
294
  style={style}
@@ -313,7 +310,8 @@ export function Buttons(props: ButtonsProps): ElementNode {
313
310
  />
314
311
  ) : null}
315
312
 
316
- {fundingSources.includes(FUNDING.CARD) ? (
313
+ {layout === BUTTON_LAYOUT.VERTICAL &&
314
+ fundingSources.indexOf(FUNDING.CARD) !== -1 ? (
317
315
  <PoweredByPayPal locale={locale} nonce={nonce} />
318
316
  ) : null}
319
317
 
@@ -1,89 +0,0 @@
1
- /* @flow */
2
-
3
- import { describe, expect } from "vitest";
4
- import { dom } from "@krakenjs/jsx-pragmatic/src";
5
-
6
- import { CLASS } from "../../constants/class";
7
- import { ATTRIBUTE } from "../../constants/misc";
8
-
9
- import { Buttons } from "./buttons";
10
-
11
- const props = {
12
- fundingEligibility: {
13
- card: {
14
- eligible: true,
15
- },
16
- paypal: {
17
- eligible: true,
18
- },
19
- venmo: {
20
- eligible: true,
21
- },
22
- },
23
- };
24
-
25
- const selectors = {
26
- inlineGuest: `[${ATTRIBUTE.FUNDING_SOURCE}='card']`,
27
- paypal: `[${ATTRIBUTE.FUNDING_SOURCE}='paypal'`,
28
- poweredBy: `.${CLASS.POWERED_BY}`,
29
- tagline: `.${CLASS.TAGLINE}`,
30
- venmo: `[${ATTRIBUTE.FUNDING_SOURCE}='venmo'`,
31
- };
32
-
33
- const render = (buttonProps) => {
34
- const container = document.createElement("div");
35
- // $FlowIssue not all required props are needed for this test
36
- container.appendChild(Buttons(buttonProps).render(dom()));
37
- return container;
38
- };
39
-
40
- describe("Buttons", () => {
41
- describe("style.layout = 'vertical'", () => {
42
- it("renders inline guest and paypal powered by", () => {
43
- const container = render(props);
44
- expect(container.querySelector(selectors.inlineGuest)).toBeTruthy();
45
- expect(container.querySelector(selectors.poweredBy)).toBeTruthy();
46
- expect(container.querySelector(selectors.tagline)).toBeFalsy();
47
- });
48
- });
49
-
50
- describe("style.layout = 'horizontal'", () => {
51
- const style = {
52
- layout: "horizontal",
53
- };
54
- it("renders the first two funding sources with a tagline", () => {
55
- const container = render({
56
- ...props,
57
- style,
58
- });
59
- expect(container.querySelector(selectors.paypal)).toBeTruthy();
60
- expect(container.querySelector(selectors.venmo)).toBeTruthy();
61
- expect(container.querySelector(selectors.inlineGuest)).toBeFalsy();
62
- expect(container.querySelector(selectors.poweredBy)).toBeFalsy();
63
- expect(container.querySelector(selectors.tagline)).toBeTruthy();
64
- });
65
- it("renders inline guest with powered by if eligible", () => {
66
- // $FlowIssue fundingEligibility props are optional
67
- const { card, paypal } = props.fundingEligibility;
68
- const container = render({
69
- fundingEligibility: {
70
- card,
71
- paypal,
72
- },
73
- style,
74
- });
75
- expect(container.querySelector(selectors.inlineGuest)).toBeTruthy();
76
- expect(container.querySelector(selectors.poweredBy)).toBeTruthy();
77
- expect(container.querySelector(selectors.tagline)).toBeFalsy();
78
- });
79
- it("does not render inline guest or paypal powered by if layout is horizontal", () => {
80
- const container = render({
81
- ...props,
82
- style,
83
- });
84
- expect(container.querySelector(selectors.inlineGuest)).toBeFalsy();
85
- expect(container.querySelector(selectors.poweredBy)).toBeFalsy();
86
- expect(container.querySelector(selectors.tagline)).toBeTruthy();
87
- });
88
- });
89
- });