Skip to content

Commit ad271b2

Browse files
Update Capital Financing Promotion params (#113)
* add capital financing html params * Update to exported FinancingPromotionLayoutType * bump connect-js dependency --------- Co-authored-by: bv-stripe <[email protected]>
1 parent 2e49e20 commit ad271b2

File tree

5 files changed

+71
-45
lines changed

5 files changed

+71
-45
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"@babel/preset-react": "7.18.6",
5050
"@rollup/plugin-json": "^6.0.0",
5151
"@rollup/plugin-replace": "^2.3.1",
52-
"@stripe/connect-js": "3.3.16-beta-1",
52+
"@stripe/connect-js": "3.3.17-beta-1",
5353
"@types/jest": "^24.0.25",
5454
"@types/react": "^16.8.0",
5555
"@types/react-dom": "^16.8.0",
@@ -84,7 +84,7 @@
8484
"zx": "^4.2.0"
8585
},
8686
"peerDependencies": {
87-
"@stripe/connect-js": ">=3.3.16-beta-1",
87+
"@stripe/connect-js": ">=3.3.17-beta-1",
8888
"react": ">=16.8.0",
8989
"react-dom": ">=16.8.0"
9090
}

src/Components.tsx

Lines changed: 53 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import {useCreateComponent} from './useCreateComponent';
22
import {useUpdateWithSetter} from './utils/useUpdateWithSetter';
3-
import {CollectionOptions, FetchEphemeralKeyFunction} from './types';
3+
import {
4+
CollectionOptions,
5+
FetchEphemeralKeyFunction,
6+
FinancingProductType,
7+
FinancingPromotionLayoutType,
8+
} from './types';
49
import {
510
LoadError,
611
LoaderStart,
@@ -446,38 +451,28 @@ export const ConnectCapitalFinancing = ({
446451
supportUrl?: string;
447452
onFinancingsLoaded?: ({total}: {total: number}) => void;
448453
} & CommonComponentProps): JSX.Element => {
449-
const {wrapper, component: capitalFinancing} =
454+
const {wrapper, component: capitalFinancing} =
450455
useCreateComponent('capital-financing');
451456

452-
useUpdateWithSetter(
453-
capitalFinancing,
454-
defaultFinancingOffer,
455-
(comp, val) => comp.setDefaultFinancingOffer(val)
457+
useUpdateWithSetter(capitalFinancing, defaultFinancingOffer, (comp, val) =>
458+
comp.setDefaultFinancingOffer(val)
456459
);
457460

458-
useUpdateWithSetter(
459-
capitalFinancing,
460-
showFinancingSelector,
461-
(comp, val) => comp.setShowFinancingSelector(val)
462-
)
461+
useUpdateWithSetter(capitalFinancing, showFinancingSelector, (comp, val) =>
462+
comp.setShowFinancingSelector(val)
463+
);
463464

464-
useUpdateWithSetter(
465-
capitalFinancing,
466-
faqUrl,
467-
(comp, val) => comp.setFaqUrl(val)
468-
)
465+
useUpdateWithSetter(capitalFinancing, faqUrl, (comp, val) =>
466+
comp.setFaqUrl(val)
467+
);
469468

470-
useUpdateWithSetter(
471-
capitalFinancing,
472-
supportUrl,
473-
(comp, val) => comp.setSupportUrl(val)
474-
)
469+
useUpdateWithSetter(capitalFinancing, supportUrl, (comp, val) =>
470+
comp.setSupportUrl(val)
471+
);
475472

476-
useUpdateWithSetter(
477-
capitalFinancing,
478-
onFinancingsLoaded,
479-
(comp, val) => comp.setOnFinancingsLoaded(val)
480-
)
473+
useUpdateWithSetter(capitalFinancing, onFinancingsLoaded, (comp, val) =>
474+
comp.setOnFinancingsLoaded(val)
475+
);
481476

482477
useUpdateWithSetter(capitalFinancing, onLoaderStart, (comp, val) => {
483478
comp.setOnLoaderStart(val);
@@ -496,18 +491,23 @@ export const ConnectCapitalFinancingApplication = ({
496491
}: {
497492
onApplicationSubmitted: () => void;
498493
} & CommonComponentProps): JSX.Element => {
499-
const {wrapper, component: capitalFinancingApplication} =
500-
useCreateComponent('capital-financing-application');
494+
const {wrapper, component: capitalFinancingApplication} = useCreateComponent(
495+
'capital-financing-application'
496+
);
501497

502498
useUpdateWithSetter(
503499
capitalFinancingApplication,
504500
onApplicationSubmitted,
505501
(comp, val) => comp.setOnApplicationSubmitted(val)
506-
)
502+
);
507503

508-
useUpdateWithSetter(capitalFinancingApplication, onLoaderStart, (comp, val) => {
509-
comp.setOnLoaderStart(val);
510-
});
504+
useUpdateWithSetter(
505+
capitalFinancingApplication,
506+
onLoaderStart,
507+
(comp, val) => {
508+
comp.setOnLoaderStart(val);
509+
}
510+
);
511511
useUpdateWithSetter(capitalFinancingApplication, onLoadError, (comp, val) => {
512512
comp.setOnLoadError(val);
513513
});
@@ -516,20 +516,35 @@ export const ConnectCapitalFinancingApplication = ({
516516
};
517517

518518
export const ConnectCapitalFinancingPromotion = ({
519+
layout,
519520
onApplicationSubmitted,
521+
onEligibleFinancingOfferLoaded,
520522
onLoadError,
521523
onLoaderStart,
522524
}: {
525+
layout?: FinancingPromotionLayoutType;
526+
onEligibleFinancingOfferLoaded?: ({
527+
productType,
528+
}: FinancingProductType) => void;
523529
onApplicationSubmitted?: () => void;
524530
} & CommonComponentProps): JSX.Element => {
525-
const {wrapper, component: capitalPromotion} =
526-
useCreateComponent('capital-financing-promotion');
527-
531+
const {wrapper, component: capitalPromotion} = useCreateComponent(
532+
'capital-financing-promotion'
533+
);
534+
535+
useUpdateWithSetter(capitalPromotion, layout, (comp, val) =>
536+
comp.setLayout(val)
537+
);
538+
539+
useUpdateWithSetter(capitalPromotion, onApplicationSubmitted, (comp, val) =>
540+
comp.setOnApplicationSubmitted(val)
541+
);
542+
528543
useUpdateWithSetter(
529544
capitalPromotion,
530-
onApplicationSubmitted,
531-
(comp, val) => comp.setOnApplicationSubmitted(val)
532-
)
545+
onEligibleFinancingOfferLoaded,
546+
(comp, val) => comp.setOnEligibleFinancingOfferLoaded(val)
547+
);
533548

534549
useUpdateWithSetter(capitalPromotion, onLoaderStart, (comp, val) => {
535550
comp.setOnLoaderStart(val);

src/types.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,9 @@ export type FetchEphemeralKeyFunction = (fetchParams: {
1111
nonce: string;
1212
ephemeralKeySecret: string;
1313
}>;
14+
15+
export type FinancingProductType = {
16+
productType: 'standard' | 'refill' | 'none';
17+
};
18+
19+
export type FinancingPromotionLayoutType = 'full' | 'banner';

src/utils/useUpdateWithSetter.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import React from 'react';
2-
import {CollectionOptions, FetchEphemeralKeyFunction} from '../types';
2+
import {
3+
CollectionOptions,
4+
FetchEphemeralKeyFunction,
5+
FinancingProductType,
6+
} from '../types';
37
import {
48
LoadError,
59
LoaderStart,
@@ -20,6 +24,7 @@ export const useUpdateWithSetter = <
2024
| ((loaderStart: LoaderStart) => void)
2125
| ((loaderError: LoadError) => void)
2226
| ((installState: InstallState) => void)
27+
| ((productType: FinancingProductType) => void)
2328
| undefined
2429
>(
2530
component: T | null,

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1454,10 +1454,10 @@
14541454
dependencies:
14551455
"@sinonjs/commons" "^3.0.0"
14561456

1457-
"@stripe/[email protected].16-beta-1":
1458-
version "3.3.16-beta-1"
1459-
resolved "https://registry.yarnpkg.com/@stripe/connect-js/-/connect-js-3.3.16-beta-1.tgz#b529366fb85694d9d972d98e23fac6e1c2036809"
1460-
integrity sha512-SI3lx7W5GRVOZQbk3Lmy7MW6gkeAFV4YmIp2T3DtmHy/uzy8S6PdYqMdEazI+/EE08hLctrGEEsWAx03R5LF3g==
1457+
"@stripe/[email protected].17-beta-1":
1458+
version "3.3.17-beta-1"
1459+
resolved "https://registry.yarnpkg.com/@stripe/connect-js/-/connect-js-3.3.17-beta-1.tgz#95e33d3c63dae4d751a89f5f2a499d32c54bfdae"
1460+
integrity sha512-cPaSbuov4wO2KlEk3q37Wv6EQIMaqZ0hKiAo6jN4NeGid2oWKkR0NNAbQRcW7Nsyjk2ZcxSRXyvhUJUoTUXWvg==
14611461

14621462
"@tootallnate/once@2":
14631463
version "2.0.0"

0 commit comments

Comments
 (0)