Skip to content

Commit a1c7246

Browse files
EvanReinsteinhamzanasirkand
authored
Feat: React PayPal JS V6 (#695)
* Feat: Upgrade Typescript to v5 in react-paypal-js (#685) * initial package.json and rollup updates, changes tsconfig to bundler and adds v6 specific tsconfig * upgrade react-paypal-js typescript package to v5.3.3 * update tsconfig for v6 namespace * chore: add changeset * align rollup version and update playwright yml * change playwright.yml download deps command * update actions checkout and setup-node to v4 * update .nvmrc * try different method for installing dependencies * fix package dependency issues related to rollup and terser * revert change to download deps step * update package-lock * test fix for rollup option deps bug * update build script * test adding cache to setup node action, update install command, and remove rollup force install in github workflows * re-add force rollup install in github workflows * run npm install to update package-lock with new package versions from typescript upgrade * revert changes to download deps and setup node steps in github workflows * install with update to package.json * leverage fresh package-lock and remove all artifactory package resolution paths * fix check annotations warnings * add new line at the end of gitignore * Feat: V6 Context Provider (#688) * Feat: Upgrade Typescript to v5 in react-paypal-js (#685) * initial package.json and rollup updates, changes tsconfig to bundler and adds v6 specific tsconfig * upgrade react-paypal-js typescript package to v5.3.3 * update tsconfig for v6 namespace * chore: add changeset * align rollup version and update playwright yml * change playwright.yml download deps command * update actions checkout and setup-node to v4 * update .nvmrc * try different method for installing dependencies * fix package dependency issues related to rollup and terser * revert change to download deps step * update package-lock * test fix for rollup option deps bug * update build script * test adding cache to setup node action, update install command, and remove rollup force install in github workflows * re-add force rollup install in github workflows * run npm install to update package-lock with new package versions from typescript upgrade * revert changes to download deps and setup node steps in github workflows * install with update to package.json * leverage fresh package-lock and remove all artifactory package resolution paths * fix check annotations warnings * add new line at the end of gitignore * add ssr checks to load core sdk script func and add initial instance provider * add a basic set of hooks * update exports * mark usePayPalInstance hook as exportable * add isServer util and apply where appropriate * clean up usePayPalInstance file * update exports * create v6 specific utils file * add reducer to manage various state, fix missed isServer condition in paypal-js * update paypal sdk instance provider name * remove json.stringify operation from memoizedOptions * clean up useMemo * clean up useMemo import * update provider to account for useEffect during ssr * add tests for client-side and server-side instance provider * add instance provider context test * add context test and clean up other provider tests * update initial to pending state useEffect with empty dependency array * configure provider to handle memoization of create instance and script options * memoize context to prevent rerenders * remove duplicate isServer * swap deep equality check packages * update isServer to a function that also checks whether the document is present * fix tests and missed isServer uses * remove isServer from eligibility useEffect * add changeset * add ref for initial hydration * remove abort controller * flatten create instance options props object * update naming convention * update tests to reflect name and prop passing changes * remove dead code isServer check * update jsdoc * update imports to correct values * add console warning to loadCoreSdkScript * remove create instance and script options from reducer state * remove sdkInstance check in loading useEffect * Feat: Add check for existing core script (#701) * update loadCoreSdkScript with a condition to check if a core script already exists * enhance window.paypal check to include version * chore: add changeset * feat: Implement use venmo one time payment session hook * moved `useProxyProps` to this branch * rename to types file * CreateOrderPromise * export CreateOrder* types * chore: Breakout enums from type file * add pay later hook * fix venmo test file * rename test file * fix types * fix tests and types * add typecheck to lint command for CI * include all files for tsconfig and fix type errors * Feat: usePayPalOneTimePaymentSession hook (#699) * add inital paypal otp payment session hook * add tests * address review comments * update hook after boilerplate agreement * remove hook jsdoc comment * address review comments * review pr comments * Refactor tests to mock useProxyProps * add pay later hook * refactor after convo * some notes * remove unused code * wip * rename types file * use correct types * useProxyProps * fix error message * remove comment * tests placeholder * add test watch command * test stubs * wip * wip * tests wip * use optional chaining * proxy callback test * some docs * test wip * test wip * fixed * cleanup * rename * some cleanup * fix venmo test file * add tests * update tests * remove callback proxying tests --------- Co-authored-by: Hamza Nasir <[email protected]> Co-authored-by: Muhammad Hamza Nasir <[email protected]> Co-authored-by: Andrew Kos <[email protected]> * Feat: usePayPalSavePaymentSession hook (#708) * add paypal save payment session hook * fix typo * fix another typo * Refactor PayPalProvider (#714) * initial provider refactoring and deep compare updates * fix infinite loop and refactor create sdk instance useEffect * remove ts doc comment for the provider * refactor provider tests * remove dequal from react-paypal-js dependencies * remove initial from instance loading state enum * add jsdoc for isEqualComponentsArray helper * fix test * revert paypal-js changes * remove shared test utils file (#723) * remove shared test utils file * update load core sdk script tests * add a changeset * Revert "update load core sdk script tests" This reverts commit 8e8e712. * re-apply test fix * Feat: Add dataNamespace to the PayPal Provider (#720) * add datanamespace option to the provider * update exported session hooks * Fix/refactor types (#725) * refactor pay later types * refactor paypal otp types * remove provider type declaration file * remove venmo type declaration file * remove save payment declaration file and add base payment session return interface * apple base payment session return type * fix build errors * v6 React error handling (#721) * error handling * update state type, remove dispatch * update package-lock * fix types * fix some warnings * remove sdk instance from expect rejected state * remove unused code * skip eligibility error for now * fix error * fix changes from merge conflicts --------- Co-authored-by: Hamza Nasir <[email protected]> Co-authored-by: Andrew Kos <[email protected]> Co-authored-by: Muhammad Hamza Nasir <[email protected]>
1 parent 6539e8e commit a1c7246

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+19140
-9182
lines changed

.changeset/calm-dodos-win.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@paypal/react-paypal-js": minor
3+
"@paypal/paypal-js": minor
4+
---
5+
6+
Upgrade react-paypal-js Typescript version to v5.3.3 and update build configuration.

.changeset/dirty-seas-clean.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@paypal/react-paypal-js": minor
3+
"@paypal/paypal-js": minor
4+
---
5+
6+
Add V6 instance provider and context hook

.changeset/heavy-badgers-care.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@paypal/react-paypal-js": patch
3+
---
4+
5+
Adds an early resolve to loadCoreSdkScript if a v6 core script already exists.

.changeset/quick-lizards-help.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@paypal/react-paypal-js": patch
3+
"@paypal/paypal-js": patch
4+
---
5+
6+
Refactor paypal provider test utils.

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- name: ⬇️ Checkout repo
12-
uses: actions/checkout@v3
12+
uses: actions/checkout@v4
1313
with:
1414
ref: ${{github.event.pull_request.head.sha}}
1515
fetch-depth: 0
@@ -18,7 +18,7 @@ jobs:
1818
run: echo NVMRC=`cat .nvmrc` >> $GITHUB_ENV
1919

2020
- name: ⎔ Setup node
21-
uses: actions/setup-node@v3
21+
uses: actions/setup-node@v4
2222
with:
2323
node-version: ${{ env.NVMRC }}
2424

.github/workflows/playwright.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ jobs:
1515
access_token: ${{ secrets.GITHUB_TOKEN }}
1616

1717
- name: ⬇️ Checkout repo
18-
uses: actions/checkout@v3
18+
uses: actions/checkout@v4
1919
with:
2020
fetch-depth: 0
2121

2222
- name: 🤝 Set Node version from .nvmrc
2323
run: echo NVMRC=`cat .nvmrc` >> $GITHUB_ENV
2424

2525
- name: ⎔ Setup node
26-
uses: actions/setup-node@v3
26+
uses: actions/setup-node@v4
2727
with:
2828
node-version: ${{ env.NVMRC }}
2929

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ node_modules
1010
/playwright-report/
1111
/playwright/.cache/
1212
.idea
13+
.rollup.cache

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
18
1+
20

docs/readmes/web-sdk-v6-reference.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const paypalCheckout = sdkInstance.createPayPalOneTimePaymentSession({
5151

5252
### Key Features
5353

54-
- **Dynamically Typed SDK Instance**: The return type of `createInstance()` changes based on which components are specified in the components array
55-
- **Type Safety**: Full TypeScript support with proper type checking for all SDK methods and callbacks
56-
- **Component-Based Types**: Different components provide access to different payment methods and functionality
57-
- **Comprehensive Callbacks**: Strongly typed callback functions for handling payment events
54+
- **Dynamically Typed SDK Instance**: The return type of `createInstance()` changes based on which components are specified in the components array
55+
- **Type Safety**: Full TypeScript support with proper type checking for all SDK methods and callbacks
56+
- **Component-Based Types**: Different components provide access to different payment methods and functionality
57+
- **Comprehensive Callbacks**: Strongly typed callback functions for handling payment events

docs/styles/paypal-fonts.css

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,9 @@ code,
6060
pre,
6161
.tsd-signature,
6262
.tsd-code-block {
63-
font-family: "SF Mono", Monaco, Menlo, Consolas, "Liberation Mono",
64-
"Courier New", monospace !important;
63+
font-family:
64+
"SF Mono", Monaco, Menlo, Consolas, "Liberation Mono", "Courier New",
65+
monospace !important;
6566
}
6667

6768
footer {

0 commit comments

Comments
 (0)