@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
package/slate.md CHANGED
@@ -73,7 +73,7 @@ const widget = new Paydock.HtmlWidget('#selector', 'publicKey', 'gatewayId');
73
73
  ```
74
74
 
75
75
  ```js
76
- // default import - We do not provide default exports. They are handled differently by different tools!
76
+ // default import - Not officially supported . They are handled differently by different tools / settings!
77
77
 
78
78
  import paydock from '@paydock/client-sdk'
79
79
  >>> "Uncaught SyntaxError: The requested module does not provide an export named 'default'"
@@ -199,6 +199,20 @@ widget.setSupportedCardIcons(['mastercard', 'visa']); // add icons of supported
199
199
 
200
200
  This example shows how you can use a lot of other methods to settings your form
201
201
 
202
+
203
+ ### Error handling
204
+
205
+ ```javascript
206
+ widget.on('error', (error) => {
207
+ const errorDiv = document.getElementById('error');
208
+ const errorMessage = document.getElementById('error-message');
209
+
210
+ errorMessage.textContent = error.data.message;
211
+ errorDiv.style.display = 'block';
212
+ });
213
+ ```
214
+
215
+
202
216
  ### Full example
203
217
 
204
218
  ```html
@@ -214,7 +228,34 @@ This example shows how you can use a lot of other methods to settings your form
214
228
  <div id="widget"
215
229
  widget-style="text-color: #FFFFAA; border-color: #yellow"
216
230
  title="Payment form"
217
- finish-text="Payment resource was successfully accepted"></div>
231
+ finish-text="Payment resource was successfully accepted">
232
+ </div>
233
+
234
+ <div
235
+ id="error"
236
+ style="
237
+ display: none;
238
+ max-width: 600px;
239
+ margin: 16px auto;
240
+ padding: 16px 20px;
241
+ border-radius: 8px;
242
+ background-color: #FEF2F2;
243
+ border: 1px solid #FEE2E2;
244
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
245
+ font-family: system-ui, -apple-system, sans-serif;
246
+ color: #991B1B;
247
+ line-height: 1.5;
248
+ font-size: 14px;
249
+ "
250
+ title="error"
251
+ >
252
+ <div style="display: flex; align-items: flex-start; gap: 12px;">
253
+ <div>
254
+ <h4 style="margin: 0 0 4px 0; font-size: 14px; font-weight: 600;">Access Error</h4>
255
+ <div id="error-message"></div>
256
+ </div>
257
+ </div>
258
+ </div>
218
259
  </form>
219
260
 
220
261
  <script src="https://widget.paydock.com/sdk/latest/widget.umd.js" ></script>
@@ -224,11 +265,15 @@ This example shows how you can use a lot of other methods to settings your form
224
265
  widget.setSupportedCardIcons(['mastercard', 'visa']);
225
266
  widget.setFormFields(['phone', 'email']);
226
267
  widget.setRefId('custom-ref-id');
227
- widget.onFinishInsert('input[name="payment_source_token"]', 'payment_source');z
268
+ widget.onFinishInsert('input[name="payment_source_token"]', 'payment_source');
228
269
 
270
+ widget.on('error', (error) => {
271
+ document.getElementById('error-message').textContent = error.data.message;
272
+ document.getElementById('error').style.display = 'block';
273
+ });
229
274
  widget.load();
230
275
  </script>
231
- </script>
276
+
232
277
  </body>
233
278
  </html>
234
279
  ```
@@ -1481,7 +1526,7 @@ _(Required `meta` fields: - . Optional `meta` fields: -)_
1481
1526
  },
1482
1527
  );
1483
1528
  button.setEnv('sandbox');
1484
- button.onUnavailable(() => console.log("No wallet buttons available"));
1529
+ button.onUnavailable((data) => console.log("No wallet buttons available"));
1485
1530
  button.onPaymentSuccessful((data) => console.log("The payment was successful"));
1486
1531
  button.onPaymentError((data) => console.log("The payment was not successful"));
1487
1532
  button.onAuthTokensChanged((data) => console.log('Authentication tokens changed'));
@@ -1922,3 +1967,200 @@ src.setStyles({
1922
1967
  font_family: 'Arial',
1923
1968
  });
1924
1969
  ```
1970
+
1971
+ # Fraud prevention
1972
+
1973
+ The Fraud Prevention module allows you to add security layers to your payment workflows
1974
+ by integrating with any of our underlying fraud prevention providers.
1975
+
1976
+ ## Real time user behavior analysis
1977
+
1978
+ ### Forter
1979
+
1980
+ One of Forter's key features is our ability to track the user's real-time behavior on
1981
+ the site and use it to separate fraudsters from legitimate buyers. To take advantage
1982
+ of Forter's technology, a JavaScript snippet needs to be placed on EVERY page
1983
+ of your commerce site beginning with the homepage and up to and including the final
1984
+ "Thank you for your purchase" page.
1985
+
1986
+ The integration is simple and straightforward - you only need to configure event
1987
+ listeners and then instantiate a FraudPreventionService with your site configuration.
1988
+
1989
+ Additional setup is required in case your website uses Content Security Policies (CSP)
1990
+
1991
+ #### Forter: Code snippet
1992
+
1993
+ ```html
1994
+ <!doctype html>
1995
+ <html lang="en">
1996
+
1997
+ <head>
1998
+ <meta charset="utf-8">
1999
+ <title>Real time user behaviour anaylsis - Forter example</title>
2000
+ <base href="/">
2001
+ <meta name="viewport" content="width=device-width, initial-scale=1">
2002
+ <link rel="icon" type="image/x-icon" href="favicon.ico">
2003
+ <script src="../../../bundles/widget.umd.js"></script>
2004
+ <style>
2005
+ body {
2006
+ min-width: 320px;
2007
+ max-width: 1440px;
2008
+ min-height: 100svh;
2009
+ }
2010
+
2011
+ main {
2012
+ padding: 2rem;
2013
+ margin: 0 auto;
2014
+ }
2015
+
2016
+ .forter-test {
2017
+ padding: 1rem;
2018
+ border-radius: 8px;
2019
+ background: #f5f5f5;
2020
+ }
2021
+
2022
+ .status-card {
2023
+ background: white;
2024
+ padding: 1rem;
2025
+ border-radius: 4px;
2026
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
2027
+ }
2028
+
2029
+ .status {
2030
+ display: inline-block;
2031
+ padding: 0.25rem 0.5rem;
2032
+ border-radius: 4px;
2033
+ font-weight: 500;
2034
+ }
2035
+
2036
+ .status.success {
2037
+ background: #e6ffe6;
2038
+ color: #006600;
2039
+ }
2040
+
2041
+ .status.pending {
2042
+ background: rgb(255, 249, 205);
2043
+ color: rgb(255, 204, 0);
2044
+ }
2045
+
2046
+ .status.error {
2047
+ background: #ffe6e6;
2048
+ color: #cc0000;
2049
+ }
2050
+
2051
+ .error {
2052
+ display: inline-block;
2053
+ padding: 0.25rem 0.5rem;
2054
+ border-radius: 4px;
2055
+ background: #ffe6e6;
2056
+ color: #cc0000;
2057
+ font-weight: 500;
2058
+ }
2059
+
2060
+ code {
2061
+ background: #f0f0f0;
2062
+ padding: 0.2rem 0.4rem;
2063
+ border-radius: 4px;
2064
+ font-family: monospace;
2065
+ }
2066
+ </style>
2067
+ </head>
2068
+
2069
+ <body>
2070
+ <main>
2071
+ <h1>Real time user behaviour anaylsis - Forter example</h1>
2072
+ <div class="forter-test">
2073
+ <h2>Forter Integration Test</h2>
2074
+
2075
+ <div class="status-card">
2076
+ <p>
2077
+ <strong>Integration Status:</strong>
2078
+ <span data-fraud-prevention="status-indicator" class="status pending">
2079
+ Pending
2080
+ </span>
2081
+ </p>
2082
+ <p>
2083
+ <strong>Token Value:</strong>
2084
+ <code data-fraud-prevention="forter-token">Not available</code>
2085
+ </p>
2086
+ <p data-fraud-prevention="error-container" style="display: none;">
2087
+ <strong>Error Code:</strong>
2088
+ <span data-fraud-prevention="error-code" class="error"></span>
2089
+ </p>
2090
+ </div>
2091
+ </div>
2092
+ </main>
2093
+ <script>
2094
+ const { FraudPreventionEvents, FraudPreventionService } = window.paydock
2095
+
2096
+ let token = '';
2097
+ let errorCode = '';
2098
+
2099
+ const render = () => {
2100
+ const statusIndicator = document.querySelector('[data-fraud-prevention="status-indicator"]');
2101
+ const tokenValue = document.querySelector('[data-fraud-prevention="forter-token"]');
2102
+ const errorContainer = document.querySelector('[data-fraud-prevention="error-container"]');
2103
+ const errorCodeElement = document.querySelector('[data-fraud-prevention="error-code"]');
2104
+
2105
+ if (token) {
2106
+ statusIndicator.className = 'status success';
2107
+ statusIndicator.textContent = 'Active';
2108
+ tokenValue.textContent = token;
2109
+ } else {
2110
+ statusIndicator.className = 'status pending';
2111
+ statusIndicator.textContent = 'Pending';
2112
+ tokenValue.textContent = 'Not available';
2113
+ }
2114
+
2115
+ if (errorCode) {
2116
+ errorCodeElement.textContent = errorCode;
2117
+ errorContainer.style.display = 'block';
2118
+ } else {
2119
+ errorContainer.style.display = 'none';
2120
+ }
2121
+ };
2122
+
2123
+ document.addEventListener(FraudPreventionEvents.namespace, (event) => {
2124
+ switch (event.detail.type) {
2125
+ case FraudPreventionEvents.types.fingerprintTokenReady: {
2126
+ token = event.detail.payload.token;
2127
+ break;
2128
+ }
2129
+ case FraudPreventionEvents.types.fingerprintTokenError: {
2130
+ errorCode = event.detail.payload.code;
2131
+ break;
2132
+ }
2133
+ default: {
2134
+ throw new Error(
2135
+ `${FraudPreventionEvents.namespace} emitted an unsupported event: ${JSON.stringify(event.detail)}.`,
2136
+ );
2137
+ }
2138
+ }
2139
+
2140
+ render();
2141
+ });
2142
+
2143
+ new FraudPreventionService().withForter({
2144
+ siteId: 'YOUR_SITE_ID_OR_SUBSITE_ID',
2145
+ mode: 'test',
2146
+ csp: false, // set to true if your website uses Content-Security-Policies
2147
+ });
2148
+ </script>
2149
+ </body>
2150
+
2151
+ </html>
2152
+ ```
2153
+
2154
+ #### Forter: Content Security Policies
2155
+
2156
+ If your site enforces Content Security Policies (CSP), make sure to:
2157
+
2158
+ 1. Set the `csp` option to `true` when invoking `withForter` on your `FraudPreventionService` instance.
2159
+ 2. Allowlist Forter's domains on `connect-src`, `script-src`, `script-src-element` and, `worker-src` as shown below.
2160
+
2161
+ ```bash
2162
+ 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
2163
+ script-src https://*.forter.com https://dlthst9q2beh8.cloudfront.net https://d2nww8zpyj5pk0.cloudfront.net https://d2w2nqfk3z9hdt.cloudfront.net
2164
+ script-src-elem https://*.forter.com https://dlthst9q2beh8.cloudfront.net https://d2nww8zpyj5pk0.cloudfront.net https://d2w2nqfk3z9hdt.cloudfront.net
2165
+ worker-src blob:
2166
+ ```