@paydock/client-sdk 1.112.0 → 1.112.4-beta

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.
Files changed (132) hide show
  1. package/README.md +806 -22
  2. package/bundles/index.cjs +1572 -229
  3. package/bundles/index.cjs.d.ts +2505 -2056
  4. package/bundles/index.mjs +1566 -226
  5. package/bundles/index.mjs.d.ts +2505 -2056
  6. package/bundles/types/api/api-base.d.ts.map +1 -1
  7. package/bundles/types/api/api-charge-internal.d.ts +1 -0
  8. package/bundles/types/api/api-charge-internal.d.ts.map +1 -1
  9. package/bundles/types/api/api-checkout-internal.d.ts +2 -0
  10. package/bundles/types/api/api-checkout-internal.d.ts.map +1 -1
  11. package/bundles/types/checkout/checkout.d.ts.map +1 -1
  12. package/bundles/types/checkout/helpers/instruction-module.d.ts +1 -1
  13. package/bundles/types/checkout/helpers/instruction-module.d.ts.map +1 -1
  14. package/bundles/types/checkout/helpers/resource-helper.d.ts +4 -3
  15. package/bundles/types/checkout/helpers/resource-helper.d.ts.map +1 -1
  16. package/bundles/types/checkout/helpers/session-helper.d.ts +3 -0
  17. package/bundles/types/checkout/helpers/session-helper.d.ts.map +1 -1
  18. package/bundles/types/checkout/instructions/v1/instruction.afterpay_checkout_form.show.d.ts.map +1 -1
  19. package/bundles/types/checkout/instructions/v1/instruction.apple_pay_form.show.d.ts.map +1 -1
  20. package/bundles/types/checkout/instructions/v1/instruction.canvas_3ds.show.d.ts.map +1 -1
  21. package/bundles/types/checkout/instructions/v1/instruction.card_form.show.d.ts.map +1 -1
  22. package/bundles/types/checkout/instructions/v1/instruction.generic.show_message.d.ts.map +1 -1
  23. package/bundles/types/checkout/instructions/v1/instruction.google_pay_form.show.d.ts.map +1 -1
  24. package/bundles/types/checkout/instructions/v1/instruction.payment_methods.show.d.ts.map +1 -1
  25. package/bundles/types/checkout/instructions/v1/instruction.paypal_form.show.d.ts.map +1 -1
  26. package/bundles/types/checkout/instructions/v1/instruction.zip_checkout_form.show.d.ts.map +1 -1
  27. package/bundles/types/checkout/layout-widgets/additionals.d.ts +1 -1
  28. package/bundles/types/checkout/layout-widgets/additionals.d.ts.map +1 -1
  29. package/bundles/types/checkout/layout-widgets/payment-methods-template.d.ts +3 -0
  30. package/bundles/types/checkout/layout-widgets/payment-methods-template.d.ts.map +1 -1
  31. package/bundles/types/checkout/layout-widgets/payment-methods.d.ts +1 -1
  32. package/bundles/types/checkout/layout-widgets/payment-methods.d.ts.map +1 -1
  33. package/bundles/types/checkout/layout-widgets/payment-template.d.ts +1 -1
  34. package/bundles/types/components/iframe-event.d.ts +39 -27
  35. package/bundles/types/components/iframe-event.d.ts.map +1 -1
  36. package/bundles/types/components/iframe.d.ts +2 -2
  37. package/bundles/types/components/iframe.d.ts.map +1 -1
  38. package/bundles/types/components/param.d.ts +2 -0
  39. package/bundles/types/components/param.d.ts.map +1 -1
  40. package/bundles/types/configs/env/environment.paydock.d.ts.map +1 -1
  41. package/bundles/types/fraud-prevention/events.d.ts +44 -0
  42. package/bundles/types/fraud-prevention/events.d.ts.map +1 -0
  43. package/bundles/types/fraud-prevention/fraud-prevention.service.d.ts +70 -0
  44. package/bundles/types/fraud-prevention/fraud-prevention.service.d.ts.map +1 -0
  45. package/bundles/types/fraud-prevention/index.d.ts +3 -0
  46. package/bundles/types/fraud-prevention/index.d.ts.map +1 -0
  47. package/bundles/types/fraud-prevention/providers/forter/forter-device-agent.service.d.ts +78 -0
  48. package/bundles/types/fraud-prevention/providers/forter/forter-device-agent.service.d.ts.map +1 -0
  49. package/bundles/types/fraud-prevention/providers/forter/templates/forter-snippet-production.template.d.ts +2 -0
  50. package/bundles/types/fraud-prevention/providers/forter/templates/forter-snippet-production.template.d.ts.map +1 -0
  51. package/bundles/types/fraud-prevention/providers/forter/templates/forter-snippet-sandbox.template.d.ts +2 -0
  52. package/bundles/types/fraud-prevention/providers/forter/templates/forter-snippet-sandbox.template.d.ts.map +1 -0
  53. package/bundles/types/helper/browser.d.ts.map +1 -1
  54. package/bundles/types/helper/custom-error.d.ts +8 -0
  55. package/bundles/types/helper/custom-error.d.ts.map +1 -0
  56. package/bundles/types/index-cba.d.ts +6 -1
  57. package/bundles/types/index-cba.d.ts.map +1 -1
  58. package/bundles/types/index.d.ts +4 -1
  59. package/bundles/types/index.d.ts.map +1 -1
  60. package/bundles/types/paypal-data-collector/index.d.ts +23 -0
  61. package/bundles/types/paypal-data-collector/index.d.ts.map +1 -0
  62. package/bundles/types/paypal-data-collector/paypal-data-collector.d.ts +58 -0
  63. package/bundles/types/paypal-data-collector/paypal-data-collector.d.ts.map +1 -0
  64. package/bundles/types/paypal-data-collector/paypal-data-collector.interfaces.d.ts +21 -0
  65. package/bundles/types/paypal-data-collector/paypal-data-collector.interfaces.d.ts.map +1 -0
  66. package/bundles/types/paypal-data-collector/paypal-data-collector.service.d.ts +17 -0
  67. package/bundles/types/paypal-data-collector/paypal-data-collector.service.d.ts.map +1 -0
  68. package/bundles/types/paypal-save-payment-source/index.d.ts +61 -0
  69. package/bundles/types/paypal-save-payment-source/index.d.ts.map +1 -0
  70. package/bundles/types/paypal-save-payment-source/paypal-save-payment-source.d.ts +85 -0
  71. package/bundles/types/paypal-save-payment-source/paypal-save-payment-source.d.ts.map +1 -0
  72. package/bundles/types/paypal-save-payment-source/paypal-save-payment-source.interfaces.d.ts +83 -0
  73. package/bundles/types/paypal-save-payment-source/paypal-save-payment-source.interfaces.d.ts.map +1 -0
  74. package/bundles/types/paypal-save-payment-source/paypal-save-payment-source.service.d.ts +35 -0
  75. package/bundles/types/paypal-save-payment-source/paypal-save-payment-source.service.d.ts.map +1 -0
  76. package/bundles/types/secure-remote-commerce/click-to-pay-secure-remote-commerce.d.ts +1 -1
  77. package/bundles/types/secure-remote-commerce/click-to-pay-secure-remote-commerce.d.ts.map +1 -1
  78. package/bundles/types/secure-remote-commerce/index.d.ts +2 -0
  79. package/bundles/types/secure-remote-commerce/index.d.ts.map +1 -1
  80. package/bundles/types/secure-remote-commerce/interfaces.d.ts +8 -1
  81. package/bundles/types/secure-remote-commerce/interfaces.d.ts.map +1 -1
  82. package/bundles/types/shared/services/configuration-validation/configuration-validation.d.ts +12 -0
  83. package/bundles/types/shared/services/configuration-validation/configuration-validation.d.ts.map +1 -0
  84. package/bundles/types/shared/services/configuration-validation/types.d.ts +73 -0
  85. package/bundles/types/shared/services/configuration-validation/types.d.ts.map +1 -0
  86. package/bundles/types/wallet-buttons/enums.d.ts +12 -0
  87. package/bundles/types/wallet-buttons/enums.d.ts.map +1 -0
  88. package/bundles/types/wallet-buttons/index.d.ts +5 -1
  89. package/bundles/types/wallet-buttons/index.d.ts.map +1 -1
  90. package/bundles/types/wallet-buttons/wallet-buttons.d.ts +28 -15
  91. package/bundles/types/wallet-buttons/wallet-buttons.d.ts.map +1 -1
  92. package/bundles/types/wallet-buttons/wallet-services/wallet-service.d.ts +1 -1
  93. package/bundles/types/wallet-buttons/wallet-services/wallet-service.d.ts.map +1 -1
  94. package/bundles/types/wallet-buttons-express/base.wallet-button-express.d.ts +10 -10
  95. package/bundles/types/wallet-buttons-express/base.wallet-button-express.d.ts.map +1 -1
  96. package/bundles/types/wallet-buttons-express/index.d.ts +1 -0
  97. package/bundles/types/wallet-buttons-express/index.d.ts.map +1 -1
  98. package/bundles/types/wallet-buttons-express/interfaces/wallet-capture-request.interface.d.ts +1 -0
  99. package/bundles/types/wallet-buttons-express/interfaces/wallet-capture-request.interface.d.ts.map +1 -1
  100. package/bundles/types/wallet-buttons-express/services/apple-pay/apple-pay.wallet-button-express.d.ts.map +1 -1
  101. package/bundles/types/wallet-buttons-express/services/paypal/interfaces/paypal-wallet-meta.interface.d.ts +1 -0
  102. package/bundles/types/wallet-buttons-express/services/paypal/interfaces/paypal-wallet-meta.interface.d.ts.map +1 -1
  103. package/bundles/types/wallet-buttons-express/services/paypal/paypal.wallet-button-express.d.ts.map +1 -1
  104. package/bundles/types/widget/configuration.d.ts +13 -9
  105. package/bundles/types/widget/configuration.d.ts.map +1 -1
  106. package/bundles/types/widget/html-multi-widget.d.ts +1 -2
  107. package/bundles/types/widget/html-multi-widget.d.ts.map +1 -1
  108. package/bundles/types/widget/html-widget.d.ts +2 -1
  109. package/bundles/types/widget/html-widget.d.ts.map +1 -1
  110. package/bundles/types/widget/multi-widget.d.ts +5 -1
  111. package/bundles/types/widget/multi-widget.d.ts.map +1 -1
  112. package/bundles/widget.umd.js +1572 -229
  113. package/bundles/widget.umd.js.d.ts +2505 -2056
  114. package/bundles/widget.umd.js.min.d.ts +2505 -2056
  115. package/bundles/widget.umd.min.js +1 -61
  116. package/docs/api-widget.md +21 -16
  117. package/docs/click-to-pay.md +1 -0
  118. package/docs/fraud-prevention-examples.md +196 -0
  119. package/docs/fraud-prevention.md +0 -0
  120. package/docs/install/npm.example.md +1 -1
  121. package/docs/paypal-data-collector-examples.md +59 -0
  122. package/docs/paypal-data-collector.md +149 -0
  123. package/docs/paypal-save-payment-source-examples.md +63 -0
  124. package/docs/paypal-save-payment-source.md +256 -0
  125. package/docs/wallet-buttons-examples.md +1 -1
  126. package/docs/wallet-buttons-express-examples.md +1 -1
  127. package/docs/wallet-buttons-express.md +1 -0
  128. package/docs/wallet-buttons.md +3 -0
  129. package/docs/widget-examples.md +48 -3
  130. package/examples/multi-html-widget/extend.html +5 -0
  131. package/package.json +7 -7
  132. package/slate.md +247 -5
@@ -15,6 +15,14 @@
15
15
  </dd>
16
16
  </dl>
17
17
 
18
+ ## Members
19
+
20
+ <dl>
21
+ <dt><a href="#user-content-w_PURPOSE">PURPOSE</a> : <code>object</code></dt>
22
+ <dd><p>Purposes</p>
23
+ </dd>
24
+ </dl>
25
+
18
26
  ## Constants
19
27
 
20
28
  <dl>
@@ -27,9 +35,6 @@
27
35
  <dt><a href="#user-content-w_PAYMENT_TYPE">PAYMENT_TYPE</a> : <code>object</code></dt>
28
36
  <dd><p>List of available payment source types</p>
29
37
  </dd>
30
- <dt><a href="#user-content-w_PURPOSE">PURPOSE</a> : <code>object</code></dt>
31
- <dd><p>Purposes</p>
32
- </dd>
33
38
  <dt><a href="#user-content-w_FORM_FIELD">FORM_FIELD</a> : <code>object</code></dt>
34
39
  <dd><p>Current constant include available type of fields which can be included to widget</p>
35
40
  </dd>
@@ -2267,6 +2272,19 @@ Method for setting a custom language code
2267
2272
  ```javascript
2268
2273
  config.setLanguage('en');
2269
2274
  ```
2275
+ <a name="w_PURPOSE" id="w_PURPOSE" href="#user-content-w_PURPOSE">&nbsp;</a>
2276
+
2277
+ ## PURPOSE : <code>object</code>
2278
+ Purposes
2279
+
2280
+ **Kind**: global variable
2281
+
2282
+ | Param | Type | Default |
2283
+ | --- | --- | --- |
2284
+ | PAYMENT_SOURCE | <code>string</code> | <code>&quot;payment_source&quot;</code> |
2285
+ | CARD_PAYMENT_SOURCE_WITH_CVV | <code>string</code> | <code>&quot;card_payment_source_with_cvv&quot;</code> |
2286
+ | CARD_PAYMENT_SOURCE_WITHOUT_CVV | <code>string</code> | <code>&quot;card_payment_source_without_cvv&quot;</code> |
2287
+
2270
2288
  <a name="w_EVENT" id="w_EVENT" href="#user-content-w_EVENT">&nbsp;</a>
2271
2289
 
2272
2290
  ## EVENT : <code>object</code>
@@ -2316,19 +2334,6 @@ List of available payment source types
2316
2334
  | BANK_ACCOUNT | <code>string</code> | <code>&quot;bank_account&quot;</code> |
2317
2335
  | CHECKOUT | <code>string</code> | <code>&quot;checkout&quot;</code> |
2318
2336
 
2319
- <a name="w_PURPOSE" id="w_PURPOSE" href="#user-content-w_PURPOSE">&nbsp;</a>
2320
-
2321
- ## PURPOSE : <code>object</code>
2322
- Purposes
2323
-
2324
- **Kind**: global constant
2325
-
2326
- | Param | Type | Default |
2327
- | --- | --- | --- |
2328
- | PAYMENT_SOURCE | <code>string</code> | <code>&quot;payment_source&quot;</code> |
2329
- | CARD_PAYMENT_SOURCE_WITH_CVV | <code>string</code> | <code>&quot;card_payment_source_with_cvv&quot;</code> |
2330
- | CARD_PAYMENT_SOURCE_WITHOUT_CVV | <code>string</code> | <code>&quot;card_payment_source_without_cvv&quot;</code> |
2331
-
2332
2337
  <a name="w_FORM_FIELD" id="w_FORM_FIELD" href="#user-content-w_FORM_FIELD">&nbsp;</a>
2333
2338
 
2334
2339
  ## FORM\_FIELD : <code>object</code>
@@ -103,6 +103,7 @@ When the flow type is src, masked checkoutData available is also returned
103
103
  | --- | --- | --- |
104
104
  | type | <code>string</code> | type of the checkout, can be `src` or `manual`. |
105
105
  | token | <code>string</code> | one time token value. |
106
+ | token_type | <code>string</code> | one time token type value, can be `card` or `card_scheme_token`. |
106
107
  | [checkoutData] | <code>object</code> | Optional checkout data related to the checkout information. Only available on src flow. |
107
108
  | [checkoutData.card_number_bin] | <code>string</code> | The BIN of the card used for the transaction. |
108
109
  | [checkoutData.card_number_last4] | <code>string</code> | The last four digits of the card number. |
@@ -0,0 +1,196 @@
1
+ # Fraud prevention
2
+
3
+ The Fraud Prevention module allows you to add security layers to your payment workflows
4
+ by integrating with any of our underlying fraud prevention providers.
5
+
6
+ ## Real time user behavior analysis
7
+
8
+ ### Forter
9
+
10
+ One of Forter's key features is our ability to track the user's real-time behavior on
11
+ the site and use it to separate fraudsters from legitimate buyers. To take advantage
12
+ of Forter's technology, a JavaScript snippet needs to be placed on EVERY page
13
+ of your commerce site beginning with the homepage and up to and including the final
14
+ "Thank you for your purchase" page.
15
+
16
+ The integration is simple and straightforward - you only need to configure event
17
+ listeners and then instantiate a FraudPreventionService with your site configuration.
18
+
19
+ Additional setup is required in case your website uses Content Security Policies (CSP)
20
+
21
+ #### Forter: Code snippet
22
+
23
+ ```html
24
+ <!doctype html>
25
+ <html lang="en">
26
+
27
+ <head>
28
+ <meta charset="utf-8">
29
+ <title>Real time user behaviour anaylsis - Forter example</title>
30
+ <base href="/">
31
+ <meta name="viewport" content="width=device-width, initial-scale=1">
32
+ <link rel="icon" type="image/x-icon" href="favicon.ico">
33
+ <script src="../../../bundles/widget.umd.js"></script>
34
+ <style>
35
+ body {
36
+ min-width: 320px;
37
+ max-width: 1440px;
38
+ min-height: 100svh;
39
+ }
40
+
41
+ main {
42
+ padding: 2rem;
43
+ margin: 0 auto;
44
+ }
45
+
46
+ .forter-test {
47
+ padding: 1rem;
48
+ border-radius: 8px;
49
+ background: #f5f5f5;
50
+ }
51
+
52
+ .status-card {
53
+ background: white;
54
+ padding: 1rem;
55
+ border-radius: 4px;
56
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
57
+ }
58
+
59
+ .status {
60
+ display: inline-block;
61
+ padding: 0.25rem 0.5rem;
62
+ border-radius: 4px;
63
+ font-weight: 500;
64
+ }
65
+
66
+ .status.success {
67
+ background: #e6ffe6;
68
+ color: #006600;
69
+ }
70
+
71
+ .status.pending {
72
+ background: rgb(255, 249, 205);
73
+ color: rgb(255, 204, 0);
74
+ }
75
+
76
+ .status.error {
77
+ background: #ffe6e6;
78
+ color: #cc0000;
79
+ }
80
+
81
+ .error {
82
+ display: inline-block;
83
+ padding: 0.25rem 0.5rem;
84
+ border-radius: 4px;
85
+ background: #ffe6e6;
86
+ color: #cc0000;
87
+ font-weight: 500;
88
+ }
89
+
90
+ code {
91
+ background: #f0f0f0;
92
+ padding: 0.2rem 0.4rem;
93
+ border-radius: 4px;
94
+ font-family: monospace;
95
+ }
96
+ </style>
97
+ </head>
98
+
99
+ <body>
100
+ <main>
101
+ <h1>Real time user behaviour anaylsis - Forter example</h1>
102
+ <div class="forter-test">
103
+ <h2>Forter Integration Test</h2>
104
+
105
+ <div class="status-card">
106
+ <p>
107
+ <strong>Integration Status:</strong>
108
+ <span data-fraud-prevention="status-indicator" class="status pending">
109
+ Pending
110
+ </span>
111
+ </p>
112
+ <p>
113
+ <strong>Token Value:</strong>
114
+ <code data-fraud-prevention="forter-token">Not available</code>
115
+ </p>
116
+ <p data-fraud-prevention="error-container" style="display: none;">
117
+ <strong>Error Code:</strong>
118
+ <span data-fraud-prevention="error-code" class="error"></span>
119
+ </p>
120
+ </div>
121
+ </div>
122
+ </main>
123
+ <script>
124
+ const { FraudPreventionEvents, FraudPreventionService } = window.paydock
125
+
126
+ let token = '';
127
+ let errorCode = '';
128
+
129
+ const render = () => {
130
+ const statusIndicator = document.querySelector('[data-fraud-prevention="status-indicator"]');
131
+ const tokenValue = document.querySelector('[data-fraud-prevention="forter-token"]');
132
+ const errorContainer = document.querySelector('[data-fraud-prevention="error-container"]');
133
+ const errorCodeElement = document.querySelector('[data-fraud-prevention="error-code"]');
134
+
135
+ if (token) {
136
+ statusIndicator.className = 'status success';
137
+ statusIndicator.textContent = 'Active';
138
+ tokenValue.textContent = token;
139
+ } else {
140
+ statusIndicator.className = 'status pending';
141
+ statusIndicator.textContent = 'Pending';
142
+ tokenValue.textContent = 'Not available';
143
+ }
144
+
145
+ if (errorCode) {
146
+ errorCodeElement.textContent = errorCode;
147
+ errorContainer.style.display = 'block';
148
+ } else {
149
+ errorContainer.style.display = 'none';
150
+ }
151
+ };
152
+
153
+ document.addEventListener(FraudPreventionEvents.namespace, (event) => {
154
+ switch (event.detail.type) {
155
+ case FraudPreventionEvents.types.fingerprintTokenReady: {
156
+ token = event.detail.payload.token;
157
+ break;
158
+ }
159
+ case FraudPreventionEvents.types.fingerprintTokenError: {
160
+ errorCode = event.detail.payload.code;
161
+ break;
162
+ }
163
+ default: {
164
+ throw new Error(
165
+ `${FraudPreventionEvents.namespace} emitted an unsupported event: ${JSON.stringify(event.detail)}.`,
166
+ );
167
+ }
168
+ }
169
+
170
+ render();
171
+ });
172
+
173
+ new FraudPreventionService().withForter({
174
+ siteId: 'YOUR_SITE_ID_OR_SUBSITE_ID',
175
+ mode: 'test',
176
+ csp: false, // set to true if your website uses Content-Security-Policies
177
+ });
178
+ </script>
179
+ </body>
180
+
181
+ </html>
182
+ ```
183
+
184
+ #### Forter: Content Security Policies
185
+
186
+ If your site enforces Content Security Policies (CSP), make sure to:
187
+
188
+ 1. Set the `csp` option to `true` when invoking `withForter` on your `FraudPreventionService` instance.
189
+ 2. Allowlist Forter's domains on `connect-src`, `script-src`, `script-src-element` and, `worker-src` as shown below.
190
+
191
+ ```bash
192
+ connect-src https://*.forter.com wss://cdn0.forter.com https://d2o5idwacg3gyw.cloudfront.net https://dz8rit8v72mig.cloudfront.net https://db7q4jg5rkhk8.cloudfront.net https://1.1.1.1 https://d94qwxh6czci4.cloudfront.net https://dr6vcclmzwk74.cloudfront.net https://d6rak4b14t5gp.cloudfront.net https://d3k4bt74u9esq1.cloudfront.net https://d1ezzflfzltk6e.cloudfront.net https://d3nocrch4qti4v.cloudfront.net https://duuytoqss3gu4.cloudfront.net https://df45ay5pw60dy.cloudfront.net
193
+ script-src https://*.forter.com https://dlthst9q2beh8.cloudfront.net https://d2nww8zpyj5pk0.cloudfront.net https://d2w2nqfk3z9hdt.cloudfront.net
194
+ script-src-elem https://*.forter.com https://dlthst9q2beh8.cloudfront.net https://d2nww8zpyj5pk0.cloudfront.net https://d2w2nqfk3z9hdt.cloudfront.net
195
+ worker-src blob:
196
+ ```
File without changes
@@ -17,7 +17,7 @@ const widget = new Paydock.HtmlWidget('#selector', 'publicKey', 'gatewayId');
17
17
  ```
18
18
 
19
19
  ```js
20
- // default import - We do not provide default exports. They are handled differently by different tools!
20
+ // default import - Not officially supported . They are handled differently by different tools / settings!
21
21
 
22
22
  import paydock from '@paydock/client-sdk'
23
23
  >>> "Uncaught SyntaxError: The requested module does not provide an export named 'default'"
@@ -0,0 +1,59 @@
1
+ ## PayPalDataCollector Widget
2
+
3
+ Widget that collect browser-based data to help reduce fraud. Upon checkout, these data elements are sent directly to PayPal Risk Services for fraud and risk assessment.
4
+
5
+ The general flow to use the widgets is:
6
+ 1. Initialize the PayPal Data Collector Widget, providing a Source Website Identifier (Flow ID), plus optional config parameters for the widget. The general format is:
7
+ ```js
8
+ vat paypalDataCollector = new paydock.PayPalDataCollector(
9
+ sourceWebsiteIdentifier,
10
+ widgetConfigParams,
11
+ );
12
+ ```
13
+ 2. Handle the `collectDeviceData` function, that will return the generated correlation ID, like following:
14
+ ```js
15
+ const collectedDeviceData = await paypalDataCollector.collectDeviceData();
16
+ const correlationId = collectedDeviceData.correlation_id;
17
+ ```
18
+ 3. Use freely the correlation_id value as is needed.
19
+ 4. Handle the `onError` callback.
20
+ 5. If you are using Content Security Policy (CSP), you must allowlist the paypal fraudnet script URL: `https://c.paypal.com`. See reference [here](https://developer.paypal.com/limited-release/fraudnet/integrate/#link-contentsecuritypolicyintegration).
21
+
22
+ ### PayPalDataCollector Widget example
23
+
24
+ A full description of the config parameters for [PayPalDataCollector](#PayPalDataCollector) meta parameters can be found [here](#PayPalDataCollectorConfig). Below you will find a fully working html example.
25
+
26
+ ```html
27
+ <!DOCTYPE html>
28
+ <html lang="en">
29
+ <head>
30
+ <meta charset="UTF-8">
31
+ <title>Title</title>
32
+ </head>
33
+ <body>
34
+ <h2>Using PayDock PayPalDataCollector Widget!</h2>
35
+ <div id="widget"></div>
36
+ </body>
37
+ <script src="https://widget.paydock.com/sdk/latest/widget.umd.min.js" ></script>
38
+ <script>
39
+ let payPalDataCollector = new paydock.PayPalDataCollector(
40
+ 'FLOW_ID',
41
+ {
42
+ mouse_movement: true
43
+ }
44
+ );
45
+
46
+ payPalDataCollector.setEnv('test');
47
+
48
+ payPalDataCollector.onError(function(error) {
49
+ console.log("On Error Callback", error);
50
+ });
51
+
52
+ payPalDataCollector.collectDeviceData().then(function(collectedDeviceData) {
53
+ //Here when the promise is resolved, it should be able to see the correlation_id.
54
+ const correlationId = collectedDeviceData.correlation_id;
55
+ console.log("On Success", correlationId);
56
+ });
57
+ </script>
58
+ </html>
59
+ ```
@@ -0,0 +1,149 @@
1
+ ## Classes
2
+
3
+ <dl>
4
+ <dt><a href="#PayPalDataCollector">PayPalDataCollector</a></dt>
5
+ <dd><p>PayPal Data Collector Widget constructor</p>
6
+ </dd>
7
+ </dl>
8
+
9
+ ## Typedefs
10
+
11
+ <dl>
12
+ <dt><a href="#OnErrorCallback">OnErrorCallback</a> : <code>function</code></dt>
13
+ <dd><p>Callback for onError method.</p>
14
+ </dd>
15
+ </dl>
16
+
17
+ ## Interfaces
18
+
19
+ <dl>
20
+ <dt><a href="#PayPalDataCollectorConfig">PayPalDataCollectorConfig</a> : <code>object</code></dt>
21
+ <dd><p>Interface of data used for PayPal configuration. For further information refer to <a href="https://developer.paypal.com/sdk/js/reference/#style">the documentation</a>.</p>
22
+ </dd>
23
+ <dt><a href="#CollectedDeviceData">CollectedDeviceData</a> : <code>object</code></dt>
24
+ <dd><p>Data object with the corresponding <code>correlation_id</code>.</p>
25
+ </dd>
26
+ <dt><a href="#IOnErrorEventData">IOnErrorEventData</a> : <code>object</code></dt>
27
+ <dd><p>Interface for IOnErrorEventData</p>
28
+ </dd>
29
+ </dl>
30
+
31
+ <a name="PayPalDataCollectorConfig" id="PayPalDataCollectorConfig" href="#PayPalDataCollectorConfig">&nbsp;</a>
32
+
33
+ ## PayPalDataCollectorConfig : <code>object</code>
34
+ Interface of data used for PayPal configuration. For further information refer to [the documentation](https://developer.paypal.com/sdk/js/reference/#style).
35
+
36
+ **Kind**: global interface
37
+
38
+ | Param | Type | Description |
39
+ | --- | --- | --- |
40
+ | [mouse_movement] | <code>boolean</code> | Used for indicating if is enabled mouse movement collection. |
41
+
42
+ <a name="CollectedDeviceData" id="CollectedDeviceData" href="#CollectedDeviceData">&nbsp;</a>
43
+
44
+ ## CollectedDeviceData : <code>object</code>
45
+ Data object with the corresponding `correlation_id`.
46
+
47
+ **Kind**: global interface
48
+
49
+ | Param | Type | Description |
50
+ | --- | --- | --- |
51
+ | [correlation_id] | <code>string</code> | The correlation ID that was used on the subsecuent requests. |
52
+
53
+ <a name="IOnErrorEventData" id="IOnErrorEventData" href="#IOnErrorEventData">&nbsp;</a>
54
+
55
+ ## IOnErrorEventData : <code>object</code>
56
+ Interface for IOnErrorEventData
57
+
58
+ **Kind**: global interface
59
+
60
+ | Param | Type | Description |
61
+ | --- | --- | --- |
62
+ | error_code | <code>string</code> | Error code. One of 'promise_not_enabled' or 'script_error'. |
63
+
64
+ <a name="PayPalDataCollector" id="PayPalDataCollector" href="#PayPalDataCollector">&nbsp;</a>
65
+
66
+ ## PayPalDataCollector
67
+ PayPal Data Collector Widget constructor
68
+
69
+ **Kind**: global class
70
+
71
+ * [PayPalDataCollector](#PayPalDataCollector)
72
+ * [new PayPalDataCollector([flowId], [config])](#new_PayPalDataCollector_new)
73
+ * [.collectDeviceData()](#PayPalDataCollector+collectDeviceData) ⇒ [<code>Promise.&lt;CollectedDeviceData&gt;</code>](#CollectedDeviceData)
74
+ * [.onError([callback])](#PayPalDataCollector+onError)
75
+ * [.setEnv(env)](#PayPalDataCollector+setEnv)
76
+
77
+ <a name="new_PayPalDataCollector_new" id="new_PayPalDataCollector_new" href="#new_PayPalDataCollector_new">&nbsp;</a>
78
+
79
+ ### new PayPalDataCollector([flowId], [config])
80
+
81
+ | Param | Type | Description |
82
+ | --- | --- | --- |
83
+ | [flowId] | <code>string</code> | This string identifies the source website of the FraudNet request. |
84
+ | [config] | [<code>PayPalDataCollectorConfig</code>](#PayPalDataCollectorConfig) | Extra configuration for the widget. |
85
+
86
+ **Example**
87
+ ```js
88
+ var payPalDataCollector = new PayPalDataCollector('FLOW_ID', {});
89
+ ```
90
+ <a name="PayPalDataCollector+collectDeviceData" id="PayPalDataCollector+collectDeviceData" href="#PayPalDataCollector+collectDeviceData">&nbsp;</a>
91
+
92
+ ### payPalDataCollector.collectDeviceData() ⇒ [<code>Promise.&lt;CollectedDeviceData&gt;</code>](#CollectedDeviceData)
93
+ After configuring the PayPalDataCollector Widget, starts the process and returns
94
+ the correlation id used among the requests asynchronously.
95
+
96
+ **Kind**: instance method of [<code>PayPalDataCollector</code>](#PayPalDataCollector)
97
+ **Returns**: [<code>Promise.&lt;CollectedDeviceData&gt;</code>](#CollectedDeviceData) - Promise when resolved, returns an object
98
+ that contains the `correlation_id` key.
99
+ **Example**
100
+ ```js
101
+ const collectedDeviceData = await payPalDataCollectorWidget.collectDeviceData();
102
+ console.log(collectedDeviceData.correlation_id)
103
+ ```
104
+ <a name="PayPalDataCollector+onError" id="PayPalDataCollector+onError" href="#PayPalDataCollector+onError">&nbsp;</a>
105
+
106
+ ### payPalDataCollector.onError([callback])
107
+ If the process fails, the function passed as parameter will be called.
108
+ Important: Do not perform thread blocking operations in callback such as window.alert() calls.
109
+
110
+ **Kind**: instance method of [<code>PayPalDataCollector</code>](#PayPalDataCollector)
111
+
112
+ | Param | Type | Description |
113
+ | --- | --- | --- |
114
+ | [callback] | [<code>OnErrorCallback</code>](#OnErrorCallback) | Function to be called when there is an error in the flow. |
115
+
116
+ **Example**
117
+ ```js
118
+ PayPalDataCollector.onError((eventData) => console.log('Some error occur'));
119
+ ```
120
+ <a name="PayPalDataCollector+setEnv" id="PayPalDataCollector+setEnv" href="#PayPalDataCollector+setEnv">&nbsp;</a>
121
+
122
+ ### payPalDataCollector.setEnv(env)
123
+ Current method can change environment. By default environment = test.
124
+ This method does not affect Paydock's API calls or environments, is only for PayPal Data Collector
125
+ script, in order to know if the script is injected on a live server or is a testing
126
+ environment. The available values are `test` and `live`. This should match with the used
127
+ `gateway.mode` in Paydock to process the transaction.
128
+
129
+ **Kind**: instance method of [<code>PayPalDataCollector</code>](#PayPalDataCollector)
130
+
131
+ | Param | Type | Description |
132
+ | --- | --- | --- |
133
+ | env | <code>string</code> | test, live |
134
+
135
+ **Example**
136
+ ```js
137
+ PayPalDataCollector.setEnv('live');
138
+ ```
139
+ <a name="OnErrorCallback" id="OnErrorCallback" href="#OnErrorCallback">&nbsp;</a>
140
+
141
+ ## OnErrorCallback : <code>function</code>
142
+ Callback for onError method.
143
+
144
+ **Kind**: global typedef
145
+
146
+ | Param | Type |
147
+ | --- | --- |
148
+ | data | [<code>IOnErrorEventData</code>](#IOnErrorEventData) \| <code>null</code> |
149
+
@@ -0,0 +1,63 @@
1
+ ## PayPalSavePaymentSource Widget
2
+
3
+ PayPalSavePaymentSource Widget allows to obtain a Paydock one time token linked with a Paypal payment source from the customer.
4
+
5
+ The general flow to use the widgets is:
6
+ 1. Configure your PayPal gateway and connect it using Paydock API or Dashboard.
7
+ 2. Create a container in your site
8
+ ```html
9
+ <div id="widget"></div>
10
+ ```
11
+ 3. Initialize the specific `PayPalSavePaymentSourceWidget`, providing your Access token or Public Key, the Gateway ID that Paydock provides plus required and optional config parameter for the widget in use. The general format is:
12
+ ```js
13
+ new paydock.PayPalSavePaymentSourceWidget(
14
+ "#widget",
15
+ accessTokenOrPublicKey,
16
+ gatewayId,
17
+ widgetSpecificConfig,
18
+ );
19
+ ```
20
+ 4. Handle the `onSuccess`, `onError` and `onCancel` for paypal setup token results.
21
+ 5. If `onSuccess` event is emmited, event data should contain `token` and `email` ready to use.
22
+
23
+ ### Example
24
+
25
+ A full description of the config parameters for [PayPalSavePaymentSourceWidget](#PayPalSavePaymentSourceWidget) meta parameters can be found [here](#PayPalSavePaymentSourceWidgetConfig). Below you will find a fully working html example.
26
+
27
+ ```html
28
+ <!DOCTYPE html>
29
+ <html lang="en">
30
+ <head>
31
+ <meta charset="UTF-8">
32
+ <title>Title</title>
33
+ </head>
34
+ <body>
35
+ <h2>Using PayDock PayPalSavePaymentSourceWidget!</h2>
36
+ <div id="widget"></div>
37
+ </body>
38
+ <script src="https://widget.paydock.com/sdk/latest/widget.umd.min.js" ></script>
39
+ <script>
40
+ let button = new paydock.PayPalSavePaymentSourceWidget(
41
+ "#widget",
42
+ accessTokenOrPublicKey,
43
+ gatewayId,
44
+ {
45
+ style: {
46
+ layout: 'vertical',
47
+ color: 'gold',
48
+ shape: 'pill',
49
+ label: 'paypal'
50
+ }
51
+ }
52
+ );
53
+
54
+ payPalSavePaymentSourceWidget.onSuccess((data) => console.log('On success: ', data));
55
+ payPalSavePaymentSourceWidget.onError((data) => console.log('On error: ', data));
56
+ payPalSavePaymentSourceWidget.onCancel(() => console.log('On cancelled'));
57
+
58
+ button.setEnv('sandbox');
59
+
60
+ button.load();
61
+ </script>
62
+ </html>
63
+ ```