@paydock/client-sdk 1.113.2 → 1.114.7-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 (107) hide show
  1. package/README.md +757 -80
  2. package/bundles/index.cjs +1344 -190
  3. package/bundles/index.cjs.d.ts +2355 -2058
  4. package/bundles/index.mjs +1340 -187
  5. package/bundles/index.mjs.d.ts +2355 -2058
  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 +1 -0
  10. package/bundles/types/api/api-checkout-internal.d.ts.map +1 -1
  11. package/bundles/types/checkout/helpers/resource-helper.d.ts +4 -3
  12. package/bundles/types/checkout/helpers/resource-helper.d.ts.map +1 -1
  13. package/bundles/types/checkout/helpers/session-helper.d.ts +3 -0
  14. package/bundles/types/checkout/helpers/session-helper.d.ts.map +1 -1
  15. package/bundles/types/checkout/instructions/v1/instruction.afterpay_checkout_form.show.d.ts.map +1 -1
  16. package/bundles/types/checkout/instructions/v1/instruction.card_form.show.d.ts.map +1 -1
  17. package/bundles/types/checkout/instructions/v1/instruction.generic.show_message.d.ts.map +1 -1
  18. package/bundles/types/checkout/instructions/v1/instruction.zip_checkout_form.show.d.ts.map +1 -1
  19. package/bundles/types/checkout/layout-widgets/additionals.d.ts +1 -1
  20. package/bundles/types/checkout/layout-widgets/additionals.d.ts.map +1 -1
  21. package/bundles/types/checkout/layout-widgets/payment-methods-template.d.ts.map +1 -1
  22. package/bundles/types/checkout/layout-widgets/payment-methods.d.ts +1 -1
  23. package/bundles/types/checkout/layout-widgets/payment-methods.d.ts.map +1 -1
  24. package/bundles/types/components/iframe-event.d.ts +34 -29
  25. package/bundles/types/components/iframe-event.d.ts.map +1 -1
  26. package/bundles/types/components/iframe.d.ts +2 -2
  27. package/bundles/types/components/iframe.d.ts.map +1 -1
  28. package/bundles/types/components/param.d.ts +3 -0
  29. package/bundles/types/components/param.d.ts.map +1 -1
  30. package/bundles/types/configs/env/environment.paydock.d.ts.map +1 -1
  31. package/bundles/types/helper/event-error.d.ts +55 -0
  32. package/bundles/types/helper/event-error.d.ts.map +1 -0
  33. package/bundles/types/helper/process-event-error.d.ts +9 -0
  34. package/bundles/types/helper/process-event-error.d.ts.map +1 -0
  35. package/bundles/types/index-cba.d.ts +5 -1
  36. package/bundles/types/index-cba.d.ts.map +1 -1
  37. package/bundles/types/index.d.ts +3 -1
  38. package/bundles/types/index.d.ts.map +1 -1
  39. package/bundles/types/paypal-data-collector/index.d.ts +23 -0
  40. package/bundles/types/paypal-data-collector/index.d.ts.map +1 -0
  41. package/bundles/types/paypal-data-collector/paypal-data-collector.d.ts +58 -0
  42. package/bundles/types/paypal-data-collector/paypal-data-collector.d.ts.map +1 -0
  43. package/bundles/types/paypal-data-collector/paypal-data-collector.interfaces.d.ts +21 -0
  44. package/bundles/types/paypal-data-collector/paypal-data-collector.interfaces.d.ts.map +1 -0
  45. package/bundles/types/paypal-data-collector/paypal-data-collector.service.d.ts +17 -0
  46. package/bundles/types/paypal-data-collector/paypal-data-collector.service.d.ts.map +1 -0
  47. package/bundles/types/paypal-save-payment-source/index.d.ts +61 -0
  48. package/bundles/types/paypal-save-payment-source/index.d.ts.map +1 -0
  49. package/bundles/types/paypal-save-payment-source/paypal-save-payment-source.d.ts +85 -0
  50. package/bundles/types/paypal-save-payment-source/paypal-save-payment-source.d.ts.map +1 -0
  51. package/bundles/types/paypal-save-payment-source/paypal-save-payment-source.interfaces.d.ts +83 -0
  52. package/bundles/types/paypal-save-payment-source/paypal-save-payment-source.interfaces.d.ts.map +1 -0
  53. package/bundles/types/paypal-save-payment-source/paypal-save-payment-source.service.d.ts +35 -0
  54. package/bundles/types/paypal-save-payment-source/paypal-save-payment-source.service.d.ts.map +1 -0
  55. package/bundles/types/secure-remote-commerce/index.d.ts +2 -1
  56. package/bundles/types/secure-remote-commerce/index.d.ts.map +1 -1
  57. package/bundles/types/secure-remote-commerce/interfaces.d.ts +2 -5
  58. package/bundles/types/secure-remote-commerce/interfaces.d.ts.map +1 -1
  59. package/bundles/types/secure-remote-commerce/providers/mastercard-src/mastercard-src.d.ts.map +1 -1
  60. package/bundles/types/shared/services/configuration-validation/configuration-validation.d.ts +12 -0
  61. package/bundles/types/shared/services/configuration-validation/configuration-validation.d.ts.map +1 -0
  62. package/bundles/types/shared/services/configuration-validation/types.d.ts +73 -0
  63. package/bundles/types/shared/services/configuration-validation/types.d.ts.map +1 -0
  64. package/bundles/types/wallet-buttons/enums.d.ts +12 -0
  65. package/bundles/types/wallet-buttons/enums.d.ts.map +1 -0
  66. package/bundles/types/wallet-buttons/index.d.ts +5 -1
  67. package/bundles/types/wallet-buttons/index.d.ts.map +1 -1
  68. package/bundles/types/wallet-buttons/wallet-buttons.d.ts +28 -15
  69. package/bundles/types/wallet-buttons/wallet-buttons.d.ts.map +1 -1
  70. package/bundles/types/wallet-buttons/wallet-services/wallet-service.d.ts +1 -1
  71. package/bundles/types/wallet-buttons/wallet-services/wallet-service.d.ts.map +1 -1
  72. package/bundles/types/wallet-buttons-express/base.wallet-button-express.d.ts.map +1 -1
  73. package/bundles/types/wallet-buttons-express/index.d.ts +1 -0
  74. package/bundles/types/wallet-buttons-express/index.d.ts.map +1 -1
  75. package/bundles/types/wallet-buttons-express/interfaces/wallet-capture-request.interface.d.ts +1 -0
  76. package/bundles/types/wallet-buttons-express/interfaces/wallet-capture-request.interface.d.ts.map +1 -1
  77. package/bundles/types/wallet-buttons-express/services/apple-pay/apple-pay.wallet-button-express.d.ts.map +1 -1
  78. package/bundles/types/wallet-buttons-express/services/paypal/interfaces/paypal-wallet-meta.interface.d.ts +1 -0
  79. package/bundles/types/wallet-buttons-express/services/paypal/interfaces/paypal-wallet-meta.interface.d.ts.map +1 -1
  80. package/bundles/types/wallet-buttons-express/services/paypal/paypal.wallet-button-express.d.ts.map +1 -1
  81. package/bundles/types/widget/configuration.d.ts +13 -9
  82. package/bundles/types/widget/configuration.d.ts.map +1 -1
  83. package/bundles/types/widget/html-multi-widget.d.ts +1 -2
  84. package/bundles/types/widget/html-multi-widget.d.ts.map +1 -1
  85. package/bundles/types/widget/html-widget.d.ts +2 -1
  86. package/bundles/types/widget/html-widget.d.ts.map +1 -1
  87. package/bundles/types/widget/multi-widget.d.ts +14 -2
  88. package/bundles/types/widget/multi-widget.d.ts.map +1 -1
  89. package/bundles/widget.umd.js +1344 -190
  90. package/bundles/widget.umd.js.d.ts +2355 -2058
  91. package/bundles/widget.umd.js.min.d.ts +2355 -2058
  92. package/bundles/widget.umd.min.js +1 -61
  93. package/docs/api-widget.md +59 -16
  94. package/docs/click-to-pay-examples.md +0 -36
  95. package/docs/click-to-pay.md +1 -3
  96. package/docs/paypal-data-collector-examples.md +59 -0
  97. package/docs/paypal-data-collector.md +149 -0
  98. package/docs/paypal-save-payment-source-examples.md +63 -0
  99. package/docs/paypal-save-payment-source.md +256 -0
  100. package/docs/wallet-buttons-examples.md +1 -1
  101. package/docs/wallet-buttons-express-examples.md +1 -1
  102. package/docs/wallet-buttons-express.md +1 -0
  103. package/docs/wallet-buttons.md +3 -0
  104. package/docs/widget-examples.md +162 -25
  105. package/examples/multi-html-widget/extend.html +5 -0
  106. package/package.json +2 -2
  107. package/slate.md +161 -60
@@ -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>
@@ -421,6 +426,7 @@ Class Widget include method for working on html and include extended by HtmlMult
421
426
  * [.setRefId(refId)](#user-content-w_MultiWidget+setRefId)
422
427
  * [.useGatewayFieldValidation()](#user-content-w_MultiWidget+useGatewayFieldValidation)
423
428
  * [.setSupportedCardIcons(elements, validateCardNumberInput)](#user-content-w_MultiWidget+setSupportedCardIcons)
429
+ * [.hideUiErrors()](#user-content-w_MultiWidget+hideUiErrors)
424
430
  * [.setEnv(env, [alias])](#user-content-w_MultiWidget+setEnv)
425
431
  * [.loadIFrameUrl()](#user-content-w_MultiWidget+loadIFrameUrl)
426
432
  * [.setLanguage(code)](#user-content-w_MultiWidget+setLanguage)
@@ -1052,6 +1058,18 @@ Current method can set icons of supported card types
1052
1058
  ```javascript
1053
1059
  widget.setSupportedCardIcons(['mastercard', 'visa'], validateCardNumberInput);
1054
1060
  ```
1061
+ <a name="w_MultiWidget+hideUiErrors" id="w_MultiWidget+hideUiErrors" href="#user-content-w_MultiWidget+hideUiErrors">&nbsp;</a>
1062
+
1063
+ ### htmlWidget.hideUiErrors()
1064
+ Current method can hide prevent the widget from showing the error messages
1065
+
1066
+ **Kind**: instance method of [<code>HtmlWidget</code>](#user-content-w_HtmlWidget)
1067
+ **Overrides**: [<code>hideUiErrors</code>](#user-content-w_MultiWidget+hideUiErrors)
1068
+ **Example**
1069
+
1070
+ ```javascript
1071
+ widget.hideUiErrors('id');
1072
+ ```
1055
1073
  <a name="w_MultiWidget+setEnv" id="w_MultiWidget+setEnv" href="#user-content-w_MultiWidget+setEnv">&nbsp;</a>
1056
1074
 
1057
1075
  ### htmlWidget.setEnv(env, [alias])
@@ -1146,6 +1164,7 @@ Class HtmlMultiWidget include method for working with html
1146
1164
  * [.setRefId(refId)](#user-content-w_MultiWidget+setRefId)
1147
1165
  * [.useGatewayFieldValidation()](#user-content-w_MultiWidget+useGatewayFieldValidation)
1148
1166
  * [.setSupportedCardIcons(elements, validateCardNumberInput)](#user-content-w_MultiWidget+setSupportedCardIcons)
1167
+ * [.hideUiErrors()](#user-content-w_MultiWidget+hideUiErrors)
1149
1168
  * [.setEnv(env, [alias])](#user-content-w_MultiWidget+setEnv)
1150
1169
  * [.loadIFrameUrl()](#user-content-w_MultiWidget+loadIFrameUrl)
1151
1170
  * [.setLanguage(code)](#user-content-w_MultiWidget+setLanguage)
@@ -1678,6 +1697,18 @@ Current method can set icons of supported card types
1678
1697
  ```javascript
1679
1698
  widget.setSupportedCardIcons(['mastercard', 'visa'], validateCardNumberInput);
1680
1699
  ```
1700
+ <a name="w_MultiWidget+hideUiErrors" id="w_MultiWidget+hideUiErrors" href="#user-content-w_MultiWidget+hideUiErrors">&nbsp;</a>
1701
+
1702
+ ### htmlMultiWidget.hideUiErrors()
1703
+ Current method can hide prevent the widget from showing the error messages
1704
+
1705
+ **Kind**: instance method of [<code>HtmlMultiWidget</code>](#user-content-w_HtmlMultiWidget)
1706
+ **Overrides**: [<code>hideUiErrors</code>](#user-content-w_MultiWidget+hideUiErrors)
1707
+ **Example**
1708
+
1709
+ ```javascript
1710
+ widget.hideUiErrors('id');
1711
+ ```
1681
1712
  <a name="w_MultiWidget+setEnv" id="w_MultiWidget+setEnv" href="#user-content-w_MultiWidget+setEnv">&nbsp;</a>
1682
1713
 
1683
1714
  ### htmlMultiWidget.setEnv(env, [alias])
@@ -1931,6 +1962,7 @@ Class MultiWidget include method for for creating iframe url
1931
1962
  * [.setRefId(refId)](#user-content-w_MultiWidget+setRefId)
1932
1963
  * [.useGatewayFieldValidation()](#user-content-w_MultiWidget+useGatewayFieldValidation)
1933
1964
  * [.setSupportedCardIcons(elements, validateCardNumberInput)](#user-content-w_MultiWidget+setSupportedCardIcons)
1965
+ * [.hideUiErrors()](#user-content-w_MultiWidget+hideUiErrors)
1934
1966
  * [.setEnv(env, [alias])](#user-content-w_MultiWidget+setEnv)
1935
1967
  * [.loadIFrameUrl()](#user-content-w_MultiWidget+loadIFrameUrl)
1936
1968
  * [.setLanguage(code)](#user-content-w_MultiWidget+setLanguage)
@@ -2218,6 +2250,17 @@ Current method can set icons of supported card types
2218
2250
  ```javascript
2219
2251
  widget.setSupportedCardIcons(['mastercard', 'visa'], validateCardNumberInput);
2220
2252
  ```
2253
+ <a name="w_MultiWidget+hideUiErrors" id="w_MultiWidget+hideUiErrors" href="#user-content-w_MultiWidget+hideUiErrors">&nbsp;</a>
2254
+
2255
+ ### multiWidget.hideUiErrors()
2256
+ Current method can hide prevent the widget from showing the error messages
2257
+
2258
+ **Kind**: instance method of [<code>MultiWidget</code>](#user-content-w_MultiWidget)
2259
+ **Example**
2260
+
2261
+ ```javascript
2262
+ widget.hideUiErrors('id');
2263
+ ```
2221
2264
  <a name="w_MultiWidget+setEnv" id="w_MultiWidget+setEnv" href="#user-content-w_MultiWidget+setEnv">&nbsp;</a>
2222
2265
 
2223
2266
  ### multiWidget.setEnv(env, [alias])
@@ -2267,6 +2310,19 @@ Method for setting a custom language code
2267
2310
  ```javascript
2268
2311
  config.setLanguage('en');
2269
2312
  ```
2313
+ <a name="w_PURPOSE" id="w_PURPOSE" href="#user-content-w_PURPOSE">&nbsp;</a>
2314
+
2315
+ ## PURPOSE : <code>object</code>
2316
+ Purposes
2317
+
2318
+ **Kind**: global variable
2319
+
2320
+ | Param | Type | Default |
2321
+ | --- | --- | --- |
2322
+ | PAYMENT_SOURCE | <code>string</code> | <code>&quot;payment_source&quot;</code> |
2323
+ | CARD_PAYMENT_SOURCE_WITH_CVV | <code>string</code> | <code>&quot;card_payment_source_with_cvv&quot;</code> |
2324
+ | CARD_PAYMENT_SOURCE_WITHOUT_CVV | <code>string</code> | <code>&quot;card_payment_source_without_cvv&quot;</code> |
2325
+
2270
2326
  <a name="w_EVENT" id="w_EVENT" href="#user-content-w_EVENT">&nbsp;</a>
2271
2327
 
2272
2328
  ## EVENT : <code>object</code>
@@ -2316,19 +2372,6 @@ List of available payment source types
2316
2372
  | BANK_ACCOUNT | <code>string</code> | <code>&quot;bank_account&quot;</code> |
2317
2373
  | CHECKOUT | <code>string</code> | <code>&quot;checkout&quot;</code> |
2318
2374
 
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
2375
  <a name="w_FORM_FIELD" id="w_FORM_FIELD" href="#user-content-w_FORM_FIELD">&nbsp;</a>
2333
2376
 
2334
2377
  ## FORM\_FIELD : <code>object</code>
@@ -229,39 +229,3 @@ src.setStyles({
229
229
  font_family: 'Arial',
230
230
  });
231
231
  ```
232
-
233
- ## Recognition token
234
-
235
- In order to store user information for further payments, click to pay provides a recognition token that is used to load user information.
236
- If you already have a recognitionToken stored, you can use it in meta to load the user information.
237
-
238
- ### Storage suggestions
239
- Merchant can store the tokens by dropping the token as a 1st party cookie in the browser, and must ensure to manage all the security aspects around dropping/storing the cookie by following the security standards:
240
-
241
- - `Expiration Date=` cookie should be set to expire at a max 180 days
242
- - `Secure` flag
243
- - `httpOnly` flag
244
- - `sameSite=` strict
245
- - `Value=` recognition token JWT
246
-
247
- ### Example code
248
-
249
- ```javascript
250
- var src = new paydock.ClickToPay(
251
- "#checkoutIframe",
252
- "service_id",
253
- "paydock_public_key",
254
- {
255
- "recognition_token": "eyJraWQiOiIy...",
256
- },
257
- );
258
- src.on('recognitionTokenRequested', (data) => {
259
- console.log('Recognition token was found: ' + data.data.recognitionToken);
260
- // Add recognition token to your store
261
- });
262
-
263
- src.on('recognitionTokenDropped', () => {
264
- console.log('Recognition token was droped');
265
- // Delete recognition token from your store
266
- });
267
- ```
@@ -78,7 +78,6 @@ Interface of data used for the Mastercard Checkout. For further information refe
78
78
  | [customer.phone.country_code] | <code>string</code> | Customer phone country code (example "1" for US). |
79
79
  | [customer.phone.phone] | <code>string</code> | Customer phone number. |
80
80
  | [unaccepted_card_type] | <code>string</code> | Used to block a specific card type. Options are 'CREDIT', 'DEBIT'. |
81
- | [recognition_token] | <code>string</code> | Used for Click to Pay to load user information and preferences. |
82
81
 
83
82
  <a name="EventData" id="EventData" href="#EventData">&nbsp;</a>
84
83
 
@@ -104,6 +103,7 @@ When the flow type is src, masked checkoutData available is also returned
104
103
  | --- | --- | --- |
105
104
  | type | <code>string</code> | type of the checkout, can be `src` or `manual`. |
106
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`. |
107
107
  | [checkoutData] | <code>object</code> | Optional checkout data related to the checkout information. Only available on src flow. |
108
108
  | [checkoutData.card_number_bin] | <code>string</code> | The BIN of the card used for the transaction. |
109
109
  | [checkoutData.card_number_last4] | <code>string</code> | The last four digits of the card number. |
@@ -321,8 +321,6 @@ List of available event's name in the Click To Pay checkout lifecycle
321
321
  | CHECKOUT_POPUP_CLOSE | <code>string</code> | <code>&quot;checkoutPopupClose&quot;</code> | Event sent when Click To Pay checkout flow is closed, regardless of embedded or windowed mode. |
322
322
  | CHECKOUT_COMPLETED | <code>string</code> | <code>&quot;checkoutCompleted&quot;</code> | Event sent on successful checkout by customer. Check [data](#EventDataCheckoutCompletedData) for more information. |
323
323
  | CHECKOUT_ERROR | <code>string</code> | <code>&quot;checkoutError&quot;</code> | Event sent on error checkout by customer. Check [data](#EventData) for more information. |
324
- | RECOGNITION_TOKEN_REQUESTED | <code>string</code> | <code>&quot;recognitionTokenRequested&quot;</code> | Event sent when a recognition token was found on the mastercard SDK response. |
325
- | RECOGNITION_TOKEN_DROPPED | <code>string</code> | <code>&quot;recognitionTokenDropped&quot;</code> | Event sent when a recognition token needs to be dropped for user be no longer remembered. |
326
324
 
327
325
  <a name="EVENT_DATA_TYPE" id="EVENT_DATA_TYPE" href="#EVENT_DATA_TYPE">&nbsp;</a>
328
326
 
@@ -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
+ ```