@paypal/merchant-onboarding-sdk 1.0.0 → 1.0.1

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 CHANGED
@@ -1,19 +1,8 @@
1
1
  # Merchant Onboarding SDK
2
2
 
3
3
  This SDK simplifies the integration of merchant onboarding workflows into any
4
- application that includes the SDK script. It provides a set of tools and
5
- utilities to manage the onboarding process, including:
6
-
7
- - **Workflow Management:** Handles complex onboarding flows with dynamic steps
8
- and redirects.
9
- - **Data Collection and Validation:** Simplifies the collection and validation
10
- of merchant data.
11
- - **Integration with Backend Services:** Provides seamless integration with
12
- backend services for data persistence and other operations.
13
- - **User Context Management:** Maintains user context throughout the onboarding
14
- journey.
15
- - **Tracking and Analytics:** Tracks onboarding progress and gathers analytics
16
- data.
4
+ application that uses the SDK package. It provides a set of tools and utilities
5
+ to manage the onboarding process, including:
17
6
 
18
7
  ## Table of Contents
19
8
 
@@ -24,150 +13,126 @@ utilities to manage the onboarding process, including:
24
13
  - [`Paypal.onboard.initialize()`](#paypalonboardinitialize)
25
14
  - [`Paypal.onboard.render()`](#paypalonboardrender)
26
15
  - [Styling Options](#styling-options)
27
- - [CDN Information](#cdn-information)
28
- - [Current CDN Locations](#current-cdn-locations)
29
- - [CDN Distribution](#cdn-distribution)
30
16
 
31
17
  ## Getting Started
32
18
 
33
19
  ### Installation
34
20
 
35
- #### Install all dependencies to run the sdk
21
+ #### Install the SDK
36
22
 
37
23
  ```bash
38
- npm install
24
+ npm install @paypal/merchant-onboarding-sdk
39
25
  ```
40
26
 
41
- #### Build to generate the distribution files under dist
42
-
43
- This will generate all the distribution files for development,staging,sandbox
44
- and production
45
-
46
- ```bash
47
- npm run build
48
- ```
49
-
50
- #### Build to generate the distribution file for a specific test environment
51
-
52
- This will generate a distribution file for a specific test environment
53
-
54
- ```bash
55
- npm run build:staging:te -- te=<<te-name>>
56
- ```
57
-
58
- Ex: npm run build:staging:te -- te=te-rio-hybrid
59
-
60
- #### Run and test locally
27
+ ## Usage
61
28
 
62
- 1. generate sdk for development ` npm run build:dev`
63
- 2. copy dist/v1/js/development.partner.js into partner application
64
- 3. on partner application add script referencing the file you just copy
29
+ ### 1. Add sdk package to your UI element
65
30
 
66
- ```
67
- <script src="./script/development.partner.js"></script>
68
- <div id="root"></div>
31
+ ```aiexclude
32
+ import { onboard } from "@paypal/merchant-onboarding-sdk/onboarding";
69
33
  ```
70
34
 
71
- 4. on partner application initialize and render the sdk using `Paypal` object:
35
+ OR
72
36
 
73
37
  ```aiexclude
74
- window.Paypal.onboard
75
- .initialize({
76
- env: 'production', // required for node_module integrations only
77
- accessToken: 'A21_A.AAdU_t4bpoqBrSPWCvZWX7px-4feNn6Ap1Ixon9zgB46GNnibPWM_GrYcwTUBou-8LUM1WSOP5-XUecATSod2E1x-eoYPA',
78
- actionUrl: 'https://te-hybrid-path-sdk.qa.paypal.com/bizsignup/partner/entry?referralToken=ZjRmMTdiNjItMDhlNi00ZjJiLTk3ODAtNTQ0NzE3YjI5MTRkQ3pncW5vYlZpaEZOUnpmc082bTRVekphRENVcy9iWjJmWUt1b3l3TWNidz12Mg==',
79
- cancelUrl: 'http://localhost:3002/index3.html' // add partner's app url
80
- style: {
81
- color: {
82
- background: {
83
- highContrast: '#48484a', // font color
84
- },
85
- primary: {
86
- main: '#1b75bc', //header & button
87
- mainHover: '#1871b6',
88
- mainActive: '#204d74', // button color after you click
89
- },
90
- },
91
- },
92
- onError: function (error,errorInfo) {
93
- alert("There is an error\nError: " + error +"\nError Description: \n"+ errorInfo)
94
- window.location.reload()
95
- },
96
- onSDKError: function (error,errorInfo) {
97
- alert("There is an error\nError: " + error +"\nError Description: \n"+ errorInfo.componentStack)
98
- window.location.reload()
99
- },
100
- onProgress: function (progress) {},
101
- onComplete: function () { alert("Onboard completed!!")},
102
- onAccessTokenExpiry: function () {},
103
- onReferralTokenExpiry: function () {},
104
- onCancel: function () {alert("User cancelled the onboarding")},
105
- onContactUs: function () {}
106
- onLoginRequested: async function (spokePayerId) {} // STANDALONE_HYBRID partners only
107
- })
108
- .render('root')
109
- }
38
+ import { servicing } from "@paypal/merchant-onboarding-sdk/servicing";
110
39
  ```
111
40
 
112
- 5. start partner app
113
- 6. Launch sample partner html and test
114
-
115
- ## Usage
41
+ Do not add both packages to the DOM at the same time as they should not be used
42
+ concurrently.
116
43
 
117
- 1- Add sdk and create container to the partner app (external to paypal)
44
+ #### Usage NOTE
118
45
 
119
- ```aiexclude
120
- <script src="https://www.paypalobjects.com/sdk/v1/js/partner.js"></script>
121
- <div id="container"></div>
122
- ```
46
+ If you use SSR, import the script only in the UI as it relies on client-side
47
+ global objects like `window`
123
48
 
124
- 2- initialize sdk in the partner app
49
+ Example:
125
50
 
126
51
  ```aiexclude
127
- window.Paypal.onboard
128
- .initialize({
129
- env: '<<desired_env>>',
130
- accessToken: '<<partner_access_Token>>',
131
- actionUrl: '<<action_url_with_referral_token>>',
132
- style: <<customized_styling_object>>,
133
- onError: <<callback_OnError_function>>
134
- onSDKError: <<callback_onSDKError_function>>,
135
- onProgress: <<callback_onProgress_function>>,
136
- onComplete: <<callback_onComplete_function>>,
137
- onAccessTokenExpiry: <<callback_onAccessTokenExpiry_function>>,
138
- onReferralTokenExpiry: <<callback_onReferralTokenExpiry_function>>,
139
- onCancel: <<callback_onCancel_function>>,
140
- onContactUs: <<callback_onContactUs_function>>
141
- onLoginRequested: <<callback_onLoginRequested_function>>
142
- })
52
+ import {
53
+ Onboard,
54
+ OnboardOptions,
55
+ } from "@paypal/merchant-onboarding-sdk/onboarding";
56
+
57
+ const [onboard, setOnboard] = useState<Onboard>(null as unknown as Onboard);
58
+
59
+ useEffect(() => {
60
+ const initSdk = async () => {
61
+ const onbPackage = await import(
62
+ "@paypal/merchant-onboarding-sdk/onboarding"
63
+ );
64
+ setOnboard(onbPackage.default as unknown as Onboard);
65
+ };
66
+ initSdk();
67
+ }, []);
68
+
69
+ useEffect(() => {
70
+ if (onboard) {
71
+ onboard.initialize({ // props }).render("elementId")
72
+ }
73
+ }, [onboard])
143
74
  ```
144
75
 
145
- 3- render onboarding flow in the partner app
76
+ ### 2. initialize sdk in your app and render
146
77
 
147
78
  ```aiexclude
148
- window.Paypal.onboard.render('container')
79
+ onboard
80
+ .initialize({
81
+ env: 'production', // required for node_module integrations only
82
+ accessToken: 'A21_A.AAdU_t4bpoqBrSPWCvZWX7px-4feNn6Ap1Ixon9zgB46GNnibPWM_GrYcwTUBou-8LUM1WSOP5-XUecATSod2E1x-eoYPA',
83
+ actionUrl: 'https://www.paypal.com/bizsignup/partner/entry?referralToken=ZjRmMTdiNjItMDhlNi00ZjJiLTk3ODAtNTQ0NzE3YjI5MTRkQ3pncW5vYlZpaEZOUnpmc082bTRVekphRENVcy9iWjJmWUt1b3l3TWNidz12Mg==',
84
+ cancelUrl: 'http://www.partner.com/cancelUrl' // add partner's app url
85
+ style: {
86
+ color: {
87
+ background: {
88
+ highContrast: '#48484a', // font color
89
+ },
90
+ primary: {
91
+ main: '#1b75bc', //header & button
92
+ mainHover: '#1871b6',
93
+ mainActive: '#204d74', // button color after you click
94
+ },
95
+ },
96
+ },
97
+ onError: async function (error,errorInfo) {
98
+ alert("There is an error\nError: " + error +"\nError Description: \n"+ errorInfo)
99
+ window.location.reload()
100
+ },
101
+ onSDKError: async function (error,errorInfo) {
102
+ alert("There is an error\nError: " + error +"\nError Description: \n"+ errorInfo.componentStack)
103
+ window.location.reload()
104
+ },
105
+ onProgress: async function (progress) {},
106
+ onComplete: async function () { alert("Onboard completed!!")},
107
+ onAccessTokenExpiry: async function () {},
108
+ onReferralTokenExpiry: async function () {},
109
+ onCancel: async function () {alert("User cancelled the onboarding")},
110
+ onContactUs: async function () {}
111
+ onLoginRequested: async function (spokePayerId) { return await getToken()} // STANDALONE_HYBRID partners only
112
+ })
113
+ .render('root')
149
114
  ```
150
115
 
151
116
  ## SDK Reference
152
117
 
153
118
  ### `Paypal.onboard.initialize(props)`
154
119
 
155
- | Parameter | Type | Description | Required |
156
- | ----------------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------- |
157
- | `accessToken` | `string` | The access token for authentication. | Yes |
158
- | `env` | `string` | The env that should be used. Possible values are 'sandbox' or 'production' | No (defaults to 'production' for npm integrations) |
159
- | `actionUrl` | `string` | The URL containing the `referralToken`. | Yes |
160
- | `cancelUrl` | `string` | The URL to return from onboarding on cancel. | No |
161
- | `style` | `object` | Styling options (see below). | No |
162
- | `onProgress` | `function` | Callback function that receives a `progress` object (structure TBD). | No |
163
- | `onComplete` | `function` | Callback function invoked when onboarding completes successfully. | No |
164
- | `onAccessTokenExpiry` | `function` | Callback function invoked when the access token expires. The partner should refresh the token and provide a new `actionUrl`. | No |
165
- | `onReferralTokenExpiry` | `function` | Callback function invoked when the referral token expires. The partner should refresh the token and provide a new `actionUrl`. | No |
166
- | `onCancel` | `function` | Callback function invoked when the user cancels onboarding. | No |
167
- | `onError` | `function` | Callback function invoked when an error occurs during onboarding. Receives `error` and `errorInfo` objects. | No |
168
- | `onSDKError` | `function` | Callback function invoked for SDK-specific errors. Receives `error` and `errorInfo` objects. | No |
169
- | `onContactUs` | `function` | Callback function to display contact information when appropriate. | No |
170
- | `onLoginRequested` | `function` | Callback function to fetch access token for spoke-only merchant. | Yes (only for spoke-only partners) |
120
+ | Parameter | Type | Description | Required |
121
+ | ----------------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------- |
122
+ | `accessToken` | `string` | The access token for authentication. | Yes |
123
+ | `env` | `string` | The env that should be used. Possible values are 'sandbox' or 'production' | No (defaults to 'production' for npm integrations) |
124
+ | `actionUrl` | `string` | The URL containing the `referralToken`. | Yes |
125
+ | `cancelUrl` | `string` | The URL to return from onboarding on cancel. | No |
126
+ | `style` | `object` | Styling options (see below). | No |
127
+ | `onProgress` | `function` | Async Callback function that receives a `progress` object (structure TBD). | No |
128
+ | `onComplete` | `function` | Async Callback function invoked when onboarding completes successfully. | No |
129
+ | `onAccessTokenExpiry` | `function` | Async Callback function invoked when the access token expires. The partner should refresh the token and provide a new `actionUrl`. | No |
130
+ | `onReferralTokenExpiry` | `function` | Async Callback function invoked when the referral token expires. The partner should refresh the token and provide a new `actionUrl`. | No |
131
+ | `onCancel` | `function` | Async Callback function invoked when the user cancels onboarding. | No |
132
+ | `onError` | `function` | Async Callback function invoked when an error occurs during onboarding. Receives `error` and `errorInfo` objects. | No |
133
+ | `onSDKError` | `function` | Async Callback function invoked for SDK-specific errors. Receives `error` and `errorInfo` objects. | No |
134
+ | `onContactUs` | `function` | Async Callback function to display contact information when appropriate. | No |
135
+ | `onLoginRequested` | `function` | Async Callback function to fetch access token for STANDALONE_HYBRID merchant. | Yes (only for spoke-only partners) |
171
136
 
172
137
  ### `Paypal.onboard.render(containerId)`
173
138
 
@@ -180,33 +145,9 @@ maintain a design system, such as spacing, color, size, space, motion, etc.
180
145
  Styles can be passed using these tokens and Paypal will override its Theme with
181
146
  the tokens passed using vanilla-extract.
182
147
 
183
- You can check the Paypal theme token and values in
184
- https://github.paypal.com/PayPal-UI-R/pp-react/blob/f3dd9e2cd9b8478f0d9a07411290314ca127de52/packages/theme/src/theme.css.ts#L6C14-L6C27
185
- To override with specific styles just add in <<customized_styling_object>> the
186
- desire tokens following the PayPal Theme token format(see example in
187
- [Installation](#installation))
188
-
189
- ## CDN Information
190
-
191
- ### Current CDN locations
192
-
193
- | Environment | sdk to use |
194
- | ----------- | ----------------------------------------------------------------------------------------------------------------- |
195
- | Production | https://www.paypalobjects.com/sdk/v1/js/partner.js https://www.paypalobjects.com/sdk/v1/js/partner.js.LICENSE.txt |
196
- | Sandbox | https://www.paypalobjects.com/sdk/v1/js/sandbox.partner.js |
197
- | Staging | https://www.paypalobjects.com/sdk/v1/js/staging.partner.js |
198
- | Development | https://www.paypalobjects.com/sdk/v1/js/development.partner.js |
199
-
200
- ## CDN distribution:
201
-
202
- Once distribution files are generated and tested locally using demo pages, you
203
- can deploy them by
148
+ To override with specific styles just add the `style` object to the props in
149
+ onboard.initialize({}) as shown in
150
+ [Initialize and Render](#2-initialize-sdk-in-your-app-and-render)
204
151
 
205
- 1. go to https://go/cdnxui
206
- 2. the namespace is 'sdk'. If you don't see the namespace under "Your
207
- Namespaces" list, please contact @besierra or @augreer
208
- 3. click on Files
209
- 4. Start a new upload
210
- 5. Test using staging url
211
- 6. Send for approval
212
- 7. You can deploy once approved
152
+ The Style object takes the format of a vanilla-extract Theme:
153
+ https://vanilla-extract.style/documentation/theming/
package/dist/index.d.ts CHANGED
@@ -10,6 +10,7 @@ export interface OnboardOptions {
10
10
  onError?: (error: any, errorInfo?: any) => void;
11
11
  onSDKError?: (error: any, errorInfo?: any) => void;
12
12
  onContactUs?: () => void;
13
+ onLoginRequested?: (payerId: string) => Promise<string>;
13
14
  [key: string]: any;
14
15
  }
15
16
 
@@ -18,12 +19,13 @@ export interface Onboard {
18
19
  initialize(props: OnboardOptions): this;
19
20
  onProgress(progress: any): void;
20
21
  onComplete(): void;
21
- onAccessTokenExpiry(): any;
22
+ onAccessTokenExpiry(): Promise<string>;
22
23
  onReferralTokenExpiry(): void;
23
24
  onCancel(): void;
24
25
  onError(error: any, errorInfo?: any): void;
25
26
  onSDKError(error: any, errorInfo?: any): void;
26
27
  onContactUs(): void;
28
+ onLoginRequested(payerId: string): Promise<string>;
27
29
  render(elementId: string): this;
28
30
  _getClientToken(): Promise<string>;
29
31
  }