@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 +95 -154
- package/dist/index.d.ts +3 -1
- package/dist/onboarding.js +198 -145
- package/dist/servicing.js +99 -51
- package/dist/v1/js/development.partner.js +198 -145
- package/dist/v1/js/development.servicing.js +99 -51
- package/dist/v1/js/partner.js +1 -1
- package/dist/v1/js/sandbox.partner.js +198 -145
- package/dist/v1/js/sandbox.servicing.js +99 -51
- package/dist/v1/js/servicing.js +1 -1
- package/dist/v1/js/staging.partner.js +198 -145
- package/dist/v1/js/staging.servicing.js +99 -51
- package/dist/v1/js/te-e2e-embedded-path-testing.partner.js +198 -145
- package/dist/v1/js/te-e2e-embedded-path-testing.servicing.js +99 -51
- package/dist/v1/js/te-eop-release.partner.js +198 -145
- package/dist/v1/js/te-eop-release.servicing.js +99 -51
- package/dist/v1/js/te-hybrid-path-integration.partner.js +198 -145
- package/dist/v1/js/te-hybrid-path-integration.servicing.js +99 -51
- package/package.json +2 -38
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
|
|
5
|
-
|
|
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
|
|
21
|
+
#### Install the SDK
|
|
36
22
|
|
|
37
23
|
```bash
|
|
38
|
-
npm install
|
|
24
|
+
npm install @paypal/merchant-onboarding-sdk
|
|
39
25
|
```
|
|
40
26
|
|
|
41
|
-
|
|
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.
|
|
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
|
-
|
|
68
|
-
<div id="root"></div>
|
|
31
|
+
```aiexclude
|
|
32
|
+
import { onboard } from "@paypal/merchant-onboarding-sdk/onboarding";
|
|
69
33
|
```
|
|
70
34
|
|
|
71
|
-
|
|
35
|
+
OR
|
|
72
36
|
|
|
73
37
|
```aiexclude
|
|
74
|
-
|
|
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
|
-
|
|
113
|
-
|
|
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
|
-
|
|
44
|
+
#### Usage NOTE
|
|
118
45
|
|
|
119
|
-
|
|
120
|
-
|
|
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
|
-
|
|
49
|
+
Example:
|
|
125
50
|
|
|
126
51
|
```aiexclude
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
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
|
-
|
|
76
|
+
### 2. initialize sdk in your app and render
|
|
146
77
|
|
|
147
78
|
```aiexclude
|
|
148
|
-
|
|
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
|
|
156
|
-
| ----------------------- | ---------- |
|
|
157
|
-
| `accessToken` | `string` | The access token for authentication.
|
|
158
|
-
| `env` | `string` | The env that should be used. Possible values are 'sandbox' or 'production'
|
|
159
|
-
| `actionUrl` | `string` | The URL containing the `referralToken`.
|
|
160
|
-
| `cancelUrl` | `string` | The URL to return from onboarding on cancel.
|
|
161
|
-
| `style` | `object` | Styling options (see below).
|
|
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
|
|
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
|
-
|
|
184
|
-
|
|
185
|
-
|
|
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
|
-
|
|
206
|
-
|
|
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():
|
|
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
|
}
|