@paydock/client-sdk 1.115.0-beta → 1.116.0-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 (43) hide show
  1. package/README.md +531 -1
  2. package/bundles/index.cjs +498 -4
  3. package/bundles/index.cjs.d.ts +214 -1
  4. package/bundles/index.mjs +497 -5
  5. package/bundles/index.mjs.d.ts +214 -1
  6. package/bundles/types/api/api-charge-internal.d.ts +1 -0
  7. package/bundles/types/api/api-charge-internal.d.ts.map +1 -1
  8. package/bundles/types/checkout/instructions/v1/instruction.generic.show_message.d.ts.map +1 -1
  9. package/bundles/types/index-cba.d.ts +2 -0
  10. package/bundles/types/index-cba.d.ts.map +1 -1
  11. package/bundles/types/index.d.ts +2 -0
  12. package/bundles/types/index.d.ts.map +1 -1
  13. package/bundles/types/paypal-data-collector/index.d.ts +23 -0
  14. package/bundles/types/paypal-data-collector/index.d.ts.map +1 -0
  15. package/bundles/types/paypal-data-collector/paypal-data-collector.d.ts +58 -0
  16. package/bundles/types/paypal-data-collector/paypal-data-collector.d.ts.map +1 -0
  17. package/bundles/types/paypal-data-collector/paypal-data-collector.interfaces.d.ts +21 -0
  18. package/bundles/types/paypal-data-collector/paypal-data-collector.interfaces.d.ts.map +1 -0
  19. package/bundles/types/paypal-data-collector/paypal-data-collector.service.d.ts +17 -0
  20. package/bundles/types/paypal-data-collector/paypal-data-collector.service.d.ts.map +1 -0
  21. package/bundles/types/paypal-save-payment-source/index.d.ts +61 -0
  22. package/bundles/types/paypal-save-payment-source/index.d.ts.map +1 -0
  23. package/bundles/types/paypal-save-payment-source/paypal-save-payment-source.d.ts +85 -0
  24. package/bundles/types/paypal-save-payment-source/paypal-save-payment-source.d.ts.map +1 -0
  25. package/bundles/types/paypal-save-payment-source/paypal-save-payment-source.interfaces.d.ts +84 -0
  26. package/bundles/types/paypal-save-payment-source/paypal-save-payment-source.interfaces.d.ts.map +1 -0
  27. package/bundles/types/paypal-save-payment-source/paypal-save-payment-source.service.d.ts +36 -0
  28. package/bundles/types/paypal-save-payment-source/paypal-save-payment-source.service.d.ts.map +1 -0
  29. package/bundles/types/wallet-buttons-express/base.wallet-button-express.d.ts.map +1 -1
  30. package/bundles/types/wallet-buttons-express/interfaces/wallet-capture-request.interface.d.ts +1 -0
  31. package/bundles/types/wallet-buttons-express/interfaces/wallet-capture-request.interface.d.ts.map +1 -1
  32. package/bundles/types/wallet-buttons-express/services/apple-pay/apple-pay.wallet-button-express.d.ts.map +1 -1
  33. package/bundles/types/wallet-buttons-express/services/paypal/paypal.wallet-button-express.d.ts.map +1 -1
  34. package/bundles/widget.umd.js +498 -4
  35. package/bundles/widget.umd.js.d.ts +214 -1
  36. package/bundles/widget.umd.js.min.d.ts +214 -1
  37. package/bundles/widget.umd.min.js +7 -7
  38. package/docs/paypal-data-collector-examples.md +58 -0
  39. package/docs/paypal-data-collector.md +149 -0
  40. package/docs/paypal-save-payment-source-examples.md +63 -0
  41. package/docs/paypal-save-payment-source.md +256 -0
  42. package/docs/wallet-buttons-express-examples.md +1 -1
  43. package/package.json +1 -1
package/README.md CHANGED
@@ -6473,7 +6473,7 @@ A full description of the meta parameters for [ApplePayWalletButtonExpress](#App
6473
6473
  }
6474
6474
  );
6475
6475
 
6476
- button.setEnv(sandbox);
6476
+ button.setEnv('sandbox');
6477
6477
 
6478
6478
  button.onUnavailable(function() {
6479
6479
  console.log("Button not available");
@@ -8005,5 +8005,535 @@ List of available event data types
8005
8005
  | SUCCESS | <code>string</code> | <code>&quot;Success&quot;</code> | |
8006
8006
 
8007
8007
 
8008
+ ## PayPalSavePaymentSource Widget
8009
+
8010
+ PayPalSavePaymentSource Widget allows to obtain a Paydock one time token linked with a Paypal payment source from the customer.
8011
+
8012
+ The general flow to use the widgets is:
8013
+ 1. Configure your PayPal gateway and connect it using Paydock API or Dashboard.
8014
+ 2. Create a container in your site
8015
+ ```html
8016
+ <div id="widget"></div>
8017
+ ```
8018
+ 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:
8019
+ ```js
8020
+ new paydock.PayPalSavePaymentSourceWidget(
8021
+ "#widget",
8022
+ accessTokenOrPublicKey,
8023
+ gatewayId,
8024
+ widgetSpecificConfig,
8025
+ );
8026
+ ```
8027
+ 4. Handle the `onSuccess`, `onError` and `onCancel` for paypal setup token results.
8028
+ 5. If `onSuccess` event is emmited, event data should contain `token` and `email` ready to use.
8029
+
8030
+ ### Example
8031
+
8032
+ 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.
8033
+
8034
+ ```html
8035
+ <!DOCTYPE html>
8036
+ <html lang="en">
8037
+ <head>
8038
+ <meta charset="UTF-8">
8039
+ <title>Title</title>
8040
+ </head>
8041
+ <body>
8042
+ <h2>Using PayDock PayPalSavePaymentSourceWidget!</h2>
8043
+ <div id="widget"></div>
8044
+ </body>
8045
+ <script src="https://widget.paydock.com/sdk/latest/widget.umd.min.js" ></script>
8046
+ <script>
8047
+ let button = new paydock.PayPalSavePaymentSourceWidget(
8048
+ "#widget",
8049
+ accessTokenOrPublicKey,
8050
+ gatewayId,
8051
+ {
8052
+ style: {
8053
+ layout: 'vertical',
8054
+ color: 'gold',
8055
+ shape: 'pill',
8056
+ label: 'paypal'
8057
+ }
8058
+ }
8059
+ );
8060
+
8061
+ payPalSavePaymentSourceWidget.onSuccess((data) => console.log('On success: ', data));
8062
+ payPalSavePaymentSourceWidget.onError((data) => console.log('On error: ', data));
8063
+ payPalSavePaymentSourceWidget.onCancel(() => console.log('On cancelled'));
8064
+
8065
+ button.setEnv('sandbox');
8066
+
8067
+ button.load();
8068
+ </script>
8069
+ </html>
8070
+ ```
8071
+
8072
+ ## Classes
8073
+
8074
+ <dl>
8075
+ <dt><a href="#PayPalSavePaymentSourceWidget">PayPalSavePaymentSourceWidget</a></dt>
8076
+ <dd><p>PayPal Save Payment Source Widget constructor</p>
8077
+ </dd>
8078
+ </dl>
8079
+
8080
+ ## Typedefs
8081
+
8082
+ <dl>
8083
+ <dt><a href="#OnSuccessCallback">OnSuccessCallback</a> : <code>function</code></dt>
8084
+ <dd><p>Callback for onSuccess method.</p>
8085
+ </dd>
8086
+ <dt><a href="#OnErrorCallback">OnErrorCallback</a> : <code>function</code></dt>
8087
+ <dd><p>Callback for onError method.</p>
8088
+ </dd>
8089
+ <dt><a href="#OnCancelCallback">OnCancelCallback</a> : <code>function</code></dt>
8090
+ <dd><p>Callback for onCancel method.</p>
8091
+ </dd>
8092
+ </dl>
8093
+
8094
+ ## Interfaces
8095
+
8096
+ <dl>
8097
+ <dt><a href="#PayPalSavePaymentSourceWidgetConfig">PayPalSavePaymentSourceWidgetConfig</a> : <code>object</code></dt>
8098
+ <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>
8099
+ </dd>
8100
+ <dt><a href="#ErrorCodes">ErrorCodes</a> : <code>object</code></dt>
8101
+ <dd><p>Interface of possible error codes inside onError event data.</p>
8102
+ </dd>
8103
+ <dt><a href="#IOnSuccessEventData">IOnSuccessEventData</a> : <code>object</code></dt>
8104
+ <dd><p>Interface for IOnSuccessEventData</p>
8105
+ </dd>
8106
+ <dt><a href="#IOnErrorEventData">IOnErrorEventData</a> : <code>object</code></dt>
8107
+ <dd><p>Interface for IOnErrorEventData</p>
8108
+ </dd>
8109
+ <dt><a href="#IOnCancelEventData">IOnCancelEventData</a> : <code>object</code></dt>
8110
+ <dd><p>Interface for IOnCancelEventData</p>
8111
+ </dd>
8112
+ </dl>
8113
+
8114
+ <a name="PayPalSavePaymentSourceWidgetConfig" id="PayPalSavePaymentSourceWidgetConfig" href="#PayPalSavePaymentSourceWidgetConfig">&nbsp;</a>
8115
+
8116
+ ## PayPalSavePaymentSourceWidgetConfig : <code>object</code>
8117
+ Interface of data used for PayPal configuration. For further information refer to [the documentation](https://developer.paypal.com/sdk/js/reference/#style).
8118
+
8119
+ **Kind**: global interface
8120
+
8121
+ | Param | Type | Description |
8122
+ | --- | --- | --- |
8123
+ | [style.layout] | <code>&#x27;vertical&#x27;</code> \| <code>&#x27;horizontal&#x27;</code> | Used for indicating the PayPal Button layout. |
8124
+ | [style.color] | <code>&#x27;blue&#x27;</code> \| <code>&#x27;gold&#x27;</code> \| <code>&#x27;silver&#x27;</code> \| <code>&#x27;black&#x27;</code> \| <code>&#x27;white&#x27;</code> | Used for indicating the main color of the PayPal Button. |
8125
+ | [style.shape] | <code>&#x27;rect&#x27;</code> \| <code>&#x27;sharp&#x27;</code> \| <code>&#x27;pill&#x27;</code> | Used for indicating the shape of the PayPal Button. |
8126
+ | [style.label] | <code>&#x27;paypal&#x27;</code> \| <code>&#x27;checkout&#x27;</code> \| <code>&#x27;buynow&#x27;</code> \| <code>&#x27;pay&#x27;</code> | Used for indicating the label of the PayPal Button. |
8127
+ | [style.disableMaxWidth] | <code>boolean</code> | Used for indicating if the max width will be disabled. |
8128
+ | [style.disableMaxHeight] | <code>boolean</code> | Used for indicating the max height will be disabled. |
8129
+ | [style.height] | <code>number</code> | Used for indicating the height of the PayPal Button, if disableMaxHeight is true. |
8130
+ | [style.borderRadius] | <code>number</code> | Used for indicating the border radius of the PayPal Button. |
8131
+ | [style.tagline] | <code>boolean</code> | Used for indicating the tagline of the PayPal Button. |
8132
+ | [message.amount] | <code>number</code> | Used for indicating an amount before the payment. |
8133
+ | [message.align] | <code>&#x27;center&#x27;</code> \| <code>&#x27;left&#x27;</code> \| <code>&#x27;right&#x27;</code> | Used for indicating the align of the message. |
8134
+ | [message.color] | <code>&#x27;black&#x27;</code> \| <code>&#x27;white&#x27;</code> | Used for indicating the color of the message. |
8135
+ | [message.position] | <code>&#x27;top&#x27;</code> \| <code>&#x27;bottom&#x27;</code> | Used for indicating the position of the message. |
8136
+
8137
+ <a name="ErrorCodes" id="ErrorCodes" href="#ErrorCodes">&nbsp;</a>
8138
+
8139
+ ## ErrorCodes : <code>object</code>
8140
+ Interface of possible error codes inside onError event data.
8141
+
8142
+ **Kind**: global interface
8143
+
8144
+ | Param | Type | Description |
8145
+ | --- | --- | --- |
8146
+ | [unavailable] | <code>string</code> | Error code when an error occurs loading the widget. |
8147
+ | [onPaypalVaultSetupTokenError] | <code>string</code> | Error code when an error occrus on PayPal side. |
8148
+ | [onGetIdTokenError] | <code>string</code> | Error code when trying to get ID token from PayPal. |
8149
+ | [onGetWalletConfigError] | <code>string</code> | Error code when trying to get wallet config from Paydock. |
8150
+ | [onGetSetupTokenError] | <code>string</code> | Error code when trying to get the setup token from PayPal. |
8151
+ | [onOneTimeTokenError] | <code>string</code> | Error code when trying to get the one time token from Paydock. |
8152
+
8153
+ <a name="IOnSuccessEventData" id="IOnSuccessEventData" href="#IOnSuccessEventData">&nbsp;</a>
8154
+
8155
+ ## IOnSuccessEventData : <code>object</code>
8156
+ Interface for IOnSuccessEventData
8157
+
8158
+ **Kind**: global interface
8159
+
8160
+ | Param | Type | Description |
8161
+ | --- | --- | --- |
8162
+ | event | <code>EVENTS</code> | Event Name is 'ON_SUCCESS' |
8163
+ | data | <code>object</code> | Data object |
8164
+ | data.token | <code>string</code> | One Time Token to be exchanged for a Paydock Customer. |
8165
+ | [data.email] | <code>string</code> | Paypal account customer email if retrieved from Paypal servers. |
8166
+
8167
+ <a name="IOnErrorEventData" id="IOnErrorEventData" href="#IOnErrorEventData">&nbsp;</a>
8168
+
8169
+ ## IOnErrorEventData : <code>object</code>
8170
+ Interface for IOnErrorEventData
8171
+
8172
+ **Kind**: global interface
8173
+
8174
+ | Param | Type | Description |
8175
+ | --- | --- | --- |
8176
+ | event | <code>EVENTS</code> | Event Name is 'ON_ERROR' |
8177
+ | data | <code>object</code> | Error data object |
8178
+ | data.error_code | [<code>ErrorCodes</code>](#ErrorCodes) | Error code. One of ErrorCodes. |
8179
+ | [data.details] | <code>string</code> | Error details. |
8180
+ | [data.message] | <code>string</code> | Error message. |
8181
+
8182
+ <a name="IOnCancelEventData" id="IOnCancelEventData" href="#IOnCancelEventData">&nbsp;</a>
8183
+
8184
+ ## IOnCancelEventData : <code>object</code>
8185
+ Interface for IOnCancelEventData
8186
+
8187
+ **Kind**: global interface
8188
+
8189
+ | Param | Type | Description |
8190
+ | --- | --- | --- |
8191
+ | event | <code>EVENTS</code> | Event Name is 'ON_CANCEL' |
8192
+
8193
+ <a name="PayPalSavePaymentSourceWidget" id="PayPalSavePaymentSourceWidget" href="#PayPalSavePaymentSourceWidget">&nbsp;</a>
8194
+
8195
+ ## PayPalSavePaymentSourceWidget
8196
+ PayPal Save Payment Source Widget constructor
8197
+
8198
+ **Kind**: global class
8199
+
8200
+ * [PayPalSavePaymentSourceWidget](#PayPalSavePaymentSourceWidget)
8201
+ * [new PayPalSavePaymentSourceWidget(selector, publicKey, gatewayId, config)](#new_PayPalSavePaymentSourceWidget_new)
8202
+ * [.load()](#PayPalSavePaymentSourceWidget+load)
8203
+ * [.setEnv(env, [alias])](#PayPalSavePaymentSourceWidget+setEnv)
8204
+ * [.onSuccess([callback])](#PayPalSavePaymentSourceWidget+onSuccess)
8205
+ * [.onError([callback])](#PayPalSavePaymentSourceWidget+onError)
8206
+ * [.onCancel([callback])](#PayPalSavePaymentSourceWidget+onCancel)
8207
+
8208
+ <a name="new_PayPalSavePaymentSourceWidget_new" id="new_PayPalSavePaymentSourceWidget_new" href="#new_PayPalSavePaymentSourceWidget_new">&nbsp;</a>
8209
+
8210
+ ### new PayPalSavePaymentSourceWidget(selector, publicKey, gatewayId, config)
8211
+
8212
+ | Param | Type | Description |
8213
+ | --- | --- | --- |
8214
+ | selector | <code>string</code> | Selector of html element. Container for PayPal Save Payment Source Widget. |
8215
+ | publicKey | <code>string</code> | PayDock users public key. |
8216
+ | gatewayId | <code>string</code> | PayDock's PayPal gatewayId. |
8217
+ | config | [<code>PayPalSavePaymentSourceWidgetConfig</code>](#PayPalSavePaymentSourceWidgetConfig) | Extra configuration for the widget, like styles. |
8218
+
8219
+ **Example**
8220
+ ```js
8221
+ var payPalSavePaymentSourceWidget = new PayPalSavePaymentSourceWidget('#paypalButton', 'public_key', 'gateway_id');
8222
+ ```
8223
+ <a name="PayPalSavePaymentSourceWidget+load" id="PayPalSavePaymentSourceWidget+load" href="#PayPalSavePaymentSourceWidget+load">&nbsp;</a>
8224
+
8225
+ ### payPalSavePaymentSourceWidget.load()
8226
+ The final method after configuring the PayPalSavePaymentSource Widget to
8227
+ start the load process.
8228
+
8229
+ **Kind**: instance method of [<code>PayPalSavePaymentSourceWidget</code>](#PayPalSavePaymentSourceWidget)
8230
+ <a name="PayPalSavePaymentSourceWidget+setEnv" id="PayPalSavePaymentSourceWidget+setEnv" href="#PayPalSavePaymentSourceWidget+setEnv">&nbsp;</a>
8231
+
8232
+ ### payPalSavePaymentSourceWidget.setEnv(env, [alias])
8233
+ Current method can change environment. By default environment = sandbox.
8234
+ Also we can change domain alias for this environment. By default domain_alias = paydock.com
8235
+
8236
+ **Kind**: instance method of [<code>PayPalSavePaymentSourceWidget</code>](#PayPalSavePaymentSourceWidget)
8237
+
8238
+ | Param | Type | Description |
8239
+ | --- | --- | --- |
8240
+ | env | <code>string</code> | sandbox, production |
8241
+ | [alias] | <code>string</code> | Own domain alias |
8242
+
8243
+ **Example**
8244
+ ```js
8245
+ payPalSavePaymentSourceWidget.setEnv('production');
8246
+ ```
8247
+ <a name="PayPalSavePaymentSourceWidget+onSuccess" id="PayPalSavePaymentSourceWidget+onSuccess" href="#PayPalSavePaymentSourceWidget+onSuccess">&nbsp;</a>
8248
+
8249
+ ### payPalSavePaymentSourceWidget.onSuccess([callback])
8250
+ If the setup token was successfully approved and a OTT was generated, the function passed as parameter will be called.
8251
+ Important: Do not perform thread blocking operations in callback such as window.alert() calls.
8252
+
8253
+ **Kind**: instance method of [<code>PayPalSavePaymentSourceWidget</code>](#PayPalSavePaymentSourceWidget)
8254
+
8255
+ | Param | Type | Description |
8256
+ | --- | --- | --- |
8257
+ | [callback] | [<code>OnSuccessCallback</code>](#OnSuccessCallback) | Function to be called when the result is successful. |
8258
+
8259
+ **Example**
8260
+ ```js
8261
+ payPalSavePaymentSourceWidget.onSuccess((eventData) => console.log('One time token and email obtained successfully'));
8262
+ ```
8263
+ <a name="PayPalSavePaymentSourceWidget+onError" id="PayPalSavePaymentSourceWidget+onError" href="#PayPalSavePaymentSourceWidget+onError">&nbsp;</a>
8264
+
8265
+ ### payPalSavePaymentSourceWidget.onError([callback])
8266
+ If in the process for obtaining the setup token fails, the function passed as parameter will be called.
8267
+ Important: Do not perform thread blocking operations in callback such as window.alert() calls.
8268
+
8269
+ **Kind**: instance method of [<code>PayPalSavePaymentSourceWidget</code>](#PayPalSavePaymentSourceWidget)
8270
+
8271
+ | Param | Type | Description |
8272
+ | --- | --- | --- |
8273
+ | [callback] | [<code>OnErrorCallback</code>](#OnErrorCallback) | Function to be called when there is an error in the flow. |
8274
+
8275
+ **Example**
8276
+ ```js
8277
+ payPalSavePaymentSourceWidget.onError((eventData) => console.log('Some error occurred'));
8278
+ ```
8279
+ <a name="PayPalSavePaymentSourceWidget+onCancel" id="PayPalSavePaymentSourceWidget+onCancel" href="#PayPalSavePaymentSourceWidget+onCancel">&nbsp;</a>
8280
+
8281
+ ### payPalSavePaymentSourceWidget.onCancel([callback])
8282
+ If in the process for obtaining the setup token was cancelled, the function passed as parameter will be called.
8283
+ Important: Do not perform thread blocking operations in callback such as window.alert() calls.
8284
+
8285
+ **Kind**: instance method of [<code>PayPalSavePaymentSourceWidget</code>](#PayPalSavePaymentSourceWidget)
8286
+
8287
+ | Param | Type | Description |
8288
+ | --- | --- | --- |
8289
+ | [callback] | [<code>OnCancelCallback</code>](#OnCancelCallback) | Function to be called when the operation is cancelled. |
8290
+
8291
+ **Example**
8292
+ ```js
8293
+ payPalSavePaymentSourceWidget.onCancel(() => console.log('Operation cancelled'));
8294
+ ```
8295
+ <a name="OnSuccessCallback" id="OnSuccessCallback" href="#OnSuccessCallback">&nbsp;</a>
8296
+
8297
+ ## OnSuccessCallback : <code>function</code>
8298
+ Callback for onSuccess method.
8299
+
8300
+ **Kind**: global typedef
8301
+
8302
+ | Param | Type |
8303
+ | --- | --- |
8304
+ | data | [<code>IOnSuccessEventData</code>](#IOnSuccessEventData) |
8305
+
8306
+ <a name="OnErrorCallback" id="OnErrorCallback" href="#OnErrorCallback">&nbsp;</a>
8307
+
8308
+ ## OnErrorCallback : <code>function</code>
8309
+ Callback for onError method.
8310
+
8311
+ **Kind**: global typedef
8312
+
8313
+ | Param | Type |
8314
+ | --- | --- |
8315
+ | data | [<code>IOnErrorEventData</code>](#IOnErrorEventData) |
8316
+
8317
+ <a name="OnCancelCallback" id="OnCancelCallback" href="#OnCancelCallback">&nbsp;</a>
8318
+
8319
+ ## OnCancelCallback : <code>function</code>
8320
+ Callback for onCancel method.
8321
+
8322
+ **Kind**: global typedef
8323
+
8324
+ | Param | Type |
8325
+ | --- | --- |
8326
+ | data | [<code>IOnCancelEventData</code>](#IOnCancelEventData) |
8327
+
8328
+
8329
+ ## PayPalDataCollector Widget
8330
+
8331
+ 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.
8332
+
8333
+ The general flow to use the widgets is:
8334
+ 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:
8335
+ ```js
8336
+ vat paypalDataCollector = new paydock.PayPalDataCollector(
8337
+ sourceWebsiteIdentifier,
8338
+ widgetConfigParams,
8339
+ );
8340
+ ```
8341
+ 2. Handle the `collectDeviceData` function, that will return the generated correlation ID, like following:
8342
+ ```js
8343
+ const collectedDeviceData = await paypalDataCollector.collectDeviceData();
8344
+ const correlationId = collectedDeviceData.correlation_id;
8345
+ ```
8346
+ 3. Use freely the correlation_id value as is needed.
8347
+ 4. Handle the `onError` callback.
8348
+ 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).
8349
+
8350
+ ### PayPalDataCollector Widget example
8351
+
8352
+ 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.
8353
+
8354
+ ```html
8355
+ <!DOCTYPE html>
8356
+ <html lang="en">
8357
+ <head>
8358
+ <meta charset="UTF-8">
8359
+ <title>Title</title>
8360
+ </head>
8361
+ <body>
8362
+ <h2>Using PayDock PayPalDataCollector Widget!</h2>
8363
+ <div id="widget"></div>
8364
+ </body>
8365
+ <script src="https://widget.paydock.com/sdk/latest/widget.umd.min.js" ></script>
8366
+ <script>
8367
+ let payPalDataCollector = new paydock.PayPalDataCollector(
8368
+ sourceWebsiteIdentifier,
8369
+ {
8370
+ mouse_movement: true
8371
+ }
8372
+ );
8373
+
8374
+ payPalDataCollector.setEnv('test');
8375
+
8376
+ payPalDataCollector.onError(function(error) {
8377
+ console.log("On Error Callback", error);
8378
+ });
8379
+
8380
+ const collectedDeviceData = await payPalDataCollector.collectDeviceData();
8381
+
8382
+ //Here when the promise is resolved, it should be able to see the correlation_id.
8383
+ const correlationId = collectedDeviceData.correlation_id
8384
+ </script>
8385
+ </html>
8386
+ ```
8387
+
8388
+ ## Classes
8389
+
8390
+ <dl>
8391
+ <dt><a href="#PayPalDataCollector">PayPalDataCollector</a></dt>
8392
+ <dd><p>PayPal Data Collector Widget constructor</p>
8393
+ </dd>
8394
+ </dl>
8395
+
8396
+ ## Typedefs
8397
+
8398
+ <dl>
8399
+ <dt><a href="#OnErrorCallback">OnErrorCallback</a> : <code>function</code></dt>
8400
+ <dd><p>Callback for onError method.</p>
8401
+ </dd>
8402
+ </dl>
8403
+
8404
+ ## Interfaces
8405
+
8406
+ <dl>
8407
+ <dt><a href="#PayPalDataCollectorConfig">PayPalDataCollectorConfig</a> : <code>object</code></dt>
8408
+ <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>
8409
+ </dd>
8410
+ <dt><a href="#CollectedDeviceData">CollectedDeviceData</a> : <code>object</code></dt>
8411
+ <dd><p>Data object with the corresponding <code>correlation_id</code>.</p>
8412
+ </dd>
8413
+ <dt><a href="#IOnErrorEventData">IOnErrorEventData</a> : <code>object</code></dt>
8414
+ <dd><p>Interface for IOnErrorEventData</p>
8415
+ </dd>
8416
+ </dl>
8417
+
8418
+ <a name="PayPalDataCollectorConfig" id="PayPalDataCollectorConfig" href="#PayPalDataCollectorConfig">&nbsp;</a>
8419
+
8420
+ ## PayPalDataCollectorConfig : <code>object</code>
8421
+ Interface of data used for PayPal configuration. For further information refer to [the documentation](https://developer.paypal.com/sdk/js/reference/#style).
8422
+
8423
+ **Kind**: global interface
8424
+
8425
+ | Param | Type | Description |
8426
+ | --- | --- | --- |
8427
+ | [mouse_movement] | <code>boolean</code> | Used for indicating if is enabled mouse movement collection. |
8428
+
8429
+ <a name="CollectedDeviceData" id="CollectedDeviceData" href="#CollectedDeviceData">&nbsp;</a>
8430
+
8431
+ ## CollectedDeviceData : <code>object</code>
8432
+ Data object with the corresponding `correlation_id`.
8433
+
8434
+ **Kind**: global interface
8435
+
8436
+ | Param | Type | Description |
8437
+ | --- | --- | --- |
8438
+ | [correlation_id] | <code>string</code> | The correlation ID that was used on the subsecuent requests. |
8439
+
8440
+ <a name="IOnErrorEventData" id="IOnErrorEventData" href="#IOnErrorEventData">&nbsp;</a>
8441
+
8442
+ ## IOnErrorEventData : <code>object</code>
8443
+ Interface for IOnErrorEventData
8444
+
8445
+ **Kind**: global interface
8446
+
8447
+ | Param | Type | Description |
8448
+ | --- | --- | --- |
8449
+ | error_code | <code>string</code> | Error code. One of 'promise_not_enabled' or 'script_error'. |
8450
+
8451
+ <a name="PayPalDataCollector" id="PayPalDataCollector" href="#PayPalDataCollector">&nbsp;</a>
8452
+
8453
+ ## PayPalDataCollector
8454
+ PayPal Data Collector Widget constructor
8455
+
8456
+ **Kind**: global class
8457
+
8458
+ * [PayPalDataCollector](#PayPalDataCollector)
8459
+ * [new PayPalDataCollector(flowId, config)](#new_PayPalDataCollector_new)
8460
+ * [.collectDeviceData()](#PayPalDataCollector+collectDeviceData) ⇒ [<code>Promise.&lt;CollectedDeviceData&gt;</code>](#CollectedDeviceData)
8461
+ * [.onError([callback])](#PayPalDataCollector+onError)
8462
+ * [.setEnv(env)](#PayPalDataCollector+setEnv)
8463
+
8464
+ <a name="new_PayPalDataCollector_new" id="new_PayPalDataCollector_new" href="#new_PayPalDataCollector_new">&nbsp;</a>
8465
+
8466
+ ### new PayPalDataCollector(flowId, config)
8467
+
8468
+ | Param | Type | Description |
8469
+ | --- | --- | --- |
8470
+ | flowId | <code>string</code> | This string identifies the source website of the FraudNet request. |
8471
+ | config | [<code>PayPalDataCollectorConfig</code>](#PayPalDataCollectorConfig) | Extra configuration for the widget. |
8472
+
8473
+ **Example**
8474
+ ```js
8475
+ var payPalDataCollector = new PayPalDataCollector('FLOW_ID', {});
8476
+ ```
8477
+ <a name="PayPalDataCollector+collectDeviceData" id="PayPalDataCollector+collectDeviceData" href="#PayPalDataCollector+collectDeviceData">&nbsp;</a>
8478
+
8479
+ ### payPalDataCollector.collectDeviceData() ⇒ [<code>Promise.&lt;CollectedDeviceData&gt;</code>](#CollectedDeviceData)
8480
+ After configuring the PayPalDataCollector Widget, starts the process and returns
8481
+ the correlation id used among the requests.
8482
+
8483
+ **Kind**: instance method of [<code>PayPalDataCollector</code>](#PayPalDataCollector)
8484
+ **Returns**: [<code>Promise.&lt;CollectedDeviceData&gt;</code>](#CollectedDeviceData) - Promise when resolved, returnsa an object
8485
+ that contains the `correlation_id` key.
8486
+ **Example**
8487
+ ```js
8488
+ const collectedDeviceData = await payPalDataCollectorWidget.collectDeviceData();
8489
+ console.log(collectedDeviceData.correlation_id)
8490
+ ```
8491
+ <a name="PayPalDataCollector+onError" id="PayPalDataCollector+onError" href="#PayPalDataCollector+onError">&nbsp;</a>
8492
+
8493
+ ### payPalDataCollector.onError([callback])
8494
+ If the process fails, the function passed as parameter will be called.
8495
+ Important: Do not perform thread blocking operations in callback such as window.alert() calls.
8496
+
8497
+ **Kind**: instance method of [<code>PayPalDataCollector</code>](#PayPalDataCollector)
8498
+
8499
+ | Param | Type | Description |
8500
+ | --- | --- | --- |
8501
+ | [callback] | [<code>OnErrorCallback</code>](#OnErrorCallback) | Function to be called when there is an error in the flow. |
8502
+
8503
+ **Example**
8504
+ ```js
8505
+ PayPalDataCollector.onError((eventData) => console.log('Some error occur'));
8506
+ ```
8507
+ <a name="PayPalDataCollector+setEnv" id="PayPalDataCollector+setEnv" href="#PayPalDataCollector+setEnv">&nbsp;</a>
8508
+
8509
+ ### payPalDataCollector.setEnv(env)
8510
+ Current method can change environment. By default environment = test.
8511
+ This method does not affect Paydock's API calls or environments, is only for PayPal Data Collector
8512
+ script, in order to know if the script is injected on a live server or is a testing
8513
+ environment. The available values are `test` and `live`. This should match with the used
8514
+ `gateway.mode` in Paydock to process the transaction.
8515
+
8516
+ **Kind**: instance method of [<code>PayPalDataCollector</code>](#PayPalDataCollector)
8517
+
8518
+ | Param | Type | Description |
8519
+ | --- | --- | --- |
8520
+ | env | <code>string</code> | test, live |
8521
+
8522
+ **Example**
8523
+ ```js
8524
+ PayPalDataCollector.setEnv('live');
8525
+ ```
8526
+ <a name="OnErrorCallback" id="OnErrorCallback" href="#OnErrorCallback">&nbsp;</a>
8527
+
8528
+ ## OnErrorCallback : <code>function</code>
8529
+ Callback for onError method.
8530
+
8531
+ **Kind**: global typedef
8532
+
8533
+ | Param | Type |
8534
+ | --- | --- |
8535
+ | data | [<code>IOnErrorEventData</code>](#IOnErrorEventData) \| <code>null</code> |
8536
+
8537
+
8008
8538
  ## License
8009
8539
  Copyright (c) 2024 paydock