@paydock/client-sdk 1.116.2 → 1.116.8-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 (127) hide show
  1. package/README.md +245 -35
  2. package/bundles/index.cjs +1698 -365
  3. package/bundles/index.cjs.d.ts +2376 -2046
  4. package/bundles/index.mjs +1694 -362
  5. package/bundles/index.mjs.d.ts +2376 -2046
  6. package/bundles/types/api/api-base.d.ts +3 -3
  7. package/bundles/types/api/api-base.d.ts.map +1 -1
  8. package/bundles/types/api/api-checkout-internal.d.ts +1 -0
  9. package/bundles/types/api/api-checkout-internal.d.ts.map +1 -1
  10. package/bundles/types/checkout/helpers/instruction-module.d.ts +1 -1
  11. package/bundles/types/checkout/helpers/instruction-module.d.ts.map +1 -1
  12. package/bundles/types/checkout/helpers/resource-helper.d.ts +4 -3
  13. package/bundles/types/checkout/helpers/resource-helper.d.ts.map +1 -1
  14. package/bundles/types/checkout/helpers/session-helper.d.ts +3 -0
  15. package/bundles/types/checkout/helpers/session-helper.d.ts.map +1 -1
  16. package/bundles/types/checkout/instructions/v1/instruction.afterpay_checkout_form.show.d.ts.map +1 -1
  17. package/bundles/types/checkout/instructions/v1/instruction.card_form.show.d.ts.map +1 -1
  18. package/bundles/types/checkout/instructions/v1/instruction.payment_methods.show.d.ts.map +1 -1
  19. package/bundles/types/checkout/instructions/v1/instruction.zip_checkout_form.show.d.ts.map +1 -1
  20. package/bundles/types/checkout/layout-widgets/additionals.d.ts +1 -1
  21. package/bundles/types/checkout/layout-widgets/additionals.d.ts.map +1 -1
  22. package/bundles/types/checkout/layout-widgets/payment-methods-template.d.ts.map +1 -1
  23. package/bundles/types/checkout/layout-widgets/payment-methods.d.ts +1 -0
  24. package/bundles/types/checkout/layout-widgets/payment-methods.d.ts.map +1 -1
  25. package/bundles/types/components/iframe-event.d.ts +39 -29
  26. package/bundles/types/components/iframe-event.d.ts.map +1 -1
  27. package/bundles/types/components/iframe.d.ts +2 -2
  28. package/bundles/types/components/iframe.d.ts.map +1 -1
  29. package/bundles/types/components/param.d.ts +2 -0
  30. package/bundles/types/components/param.d.ts.map +1 -1
  31. package/bundles/types/configs/env/environment.cba.d.ts +8 -7
  32. package/bundles/types/configs/env/environment.cba.d.ts.map +1 -1
  33. package/bundles/types/configs/env/environment.interface.d.ts +6 -6
  34. package/bundles/types/configs/env/environment.interface.d.ts.map +1 -1
  35. package/bundles/types/configs/env/environment.paydock.d.ts +8 -7
  36. package/bundles/types/configs/env/environment.paydock.d.ts.map +1 -1
  37. package/bundles/types/fraud-prevention/fraud-prevention.constants.d.ts +9 -0
  38. package/bundles/types/fraud-prevention/fraud-prevention.constants.d.ts.map +1 -0
  39. package/bundles/types/fraud-prevention/fraud-prevention.events.d.ts +42 -0
  40. package/bundles/types/fraud-prevention/fraud-prevention.events.d.ts.map +1 -0
  41. package/bundles/types/fraud-prevention/fraud-prevention.service.d.ts +163 -0
  42. package/bundles/types/fraud-prevention/fraud-prevention.service.d.ts.map +1 -0
  43. package/bundles/types/fraud-prevention/index.d.ts +3 -0
  44. package/bundles/types/fraud-prevention/index.d.ts.map +1 -0
  45. package/bundles/types/fraud-prevention/providers/forter/forter-device-agent.service.d.ts +79 -0
  46. package/bundles/types/fraud-prevention/providers/forter/forter-device-agent.service.d.ts.map +1 -0
  47. package/bundles/types/fraud-prevention/providers/forter/templates/forter-snippet-2025-02-06t14:19:34z.template.d.ts +2 -0
  48. package/bundles/types/fraud-prevention/providers/forter/templates/forter-snippet-2025-02-06t14:19:34z.template.d.ts.map +1 -0
  49. package/bundles/types/fraud-prevention/resources/find-service-config.repository.d.ts +20 -0
  50. package/bundles/types/fraud-prevention/resources/find-service-config.repository.d.ts.map +1 -0
  51. package/bundles/types/helper/access-token.d.ts +1 -0
  52. package/bundles/types/helper/access-token.d.ts.map +1 -1
  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 +3 -1
  57. package/bundles/types/index-cba.d.ts.map +1 -1
  58. package/bundles/types/index.d.ts +2 -1
  59. package/bundles/types/index.d.ts.map +1 -1
  60. package/bundles/types/paypal-data-collector/paypal-data-collector.d.ts +4 -4
  61. package/bundles/types/paypal-save-payment-source/paypal-save-payment-source.interfaces.d.ts +0 -1
  62. package/bundles/types/paypal-save-payment-source/paypal-save-payment-source.interfaces.d.ts.map +1 -1
  63. package/bundles/types/paypal-save-payment-source/paypal-save-payment-source.service.d.ts +0 -1
  64. package/bundles/types/paypal-save-payment-source/paypal-save-payment-source.service.d.ts.map +1 -1
  65. package/bundles/types/secure-remote-commerce/click-to-pay-secure-remote-commerce.d.ts +1 -1
  66. package/bundles/types/secure-remote-commerce/click-to-pay-secure-remote-commerce.d.ts.map +1 -1
  67. package/bundles/types/secure-remote-commerce/index.d.ts +2 -0
  68. package/bundles/types/secure-remote-commerce/index.d.ts.map +1 -1
  69. package/bundles/types/secure-remote-commerce/interfaces.d.ts +1 -0
  70. package/bundles/types/secure-remote-commerce/interfaces.d.ts.map +1 -1
  71. package/bundles/types/shared/http/authorization-strategy.d.ts +41 -0
  72. package/bundles/types/shared/http/authorization-strategy.d.ts.map +1 -0
  73. package/bundles/types/shared/http/http-fetcher.d.ts +28 -0
  74. package/bundles/types/shared/http/http-fetcher.d.ts.map +1 -0
  75. package/bundles/types/shared/http/http-fetcher.factory.d.ts +17 -0
  76. package/bundles/types/shared/http/http-fetcher.factory.d.ts.map +1 -0
  77. package/bundles/types/shared/http/http-request.d.ts +1 -1
  78. package/bundles/types/shared/http/http-request.d.ts.map +1 -1
  79. package/bundles/types/shared/http/http-response.dto.d.ts +19 -0
  80. package/bundles/types/shared/http/http-response.dto.d.ts.map +1 -0
  81. package/bundles/types/shared/services/configuration-validation/configuration-validation.d.ts +12 -0
  82. package/bundles/types/shared/services/configuration-validation/configuration-validation.d.ts.map +1 -0
  83. package/bundles/types/shared/services/configuration-validation/types.d.ts +73 -0
  84. package/bundles/types/shared/services/configuration-validation/types.d.ts.map +1 -0
  85. package/bundles/types/shared/services/instrumentation/instrumentation.types.d.ts +1 -1
  86. package/bundles/types/shared/services/instrumentation/instrumentation.types.d.ts.map +1 -1
  87. package/bundles/types/shared/shared.constants.d.ts +2 -0
  88. package/bundles/types/shared/shared.constants.d.ts.map +1 -0
  89. package/bundles/types/wallet-buttons/enums.d.ts +12 -0
  90. package/bundles/types/wallet-buttons/enums.d.ts.map +1 -0
  91. package/bundles/types/wallet-buttons/index.d.ts +2 -1
  92. package/bundles/types/wallet-buttons/index.d.ts.map +1 -1
  93. package/bundles/types/wallet-buttons/wallet-buttons.d.ts +28 -15
  94. package/bundles/types/wallet-buttons/wallet-buttons.d.ts.map +1 -1
  95. package/bundles/types/wallet-buttons-express/base.wallet-button-express.d.ts +10 -10
  96. package/bundles/types/wallet-buttons-express/base.wallet-button-express.d.ts.map +1 -1
  97. package/bundles/types/wallet-buttons-express/index.d.ts +1 -0
  98. package/bundles/types/wallet-buttons-express/index.d.ts.map +1 -1
  99. package/bundles/types/wallet-buttons-express/services/paypal/interfaces/paypal-wallet-meta.interface.d.ts +1 -0
  100. package/bundles/types/wallet-buttons-express/services/paypal/interfaces/paypal-wallet-meta.interface.d.ts.map +1 -1
  101. package/bundles/types/widget/configuration.d.ts +13 -9
  102. package/bundles/types/widget/configuration.d.ts.map +1 -1
  103. package/bundles/types/widget/html-multi-widget.d.ts +1 -2
  104. package/bundles/types/widget/html-multi-widget.d.ts.map +1 -1
  105. package/bundles/types/widget/html-widget.d.ts +15 -14
  106. package/bundles/types/widget/html-widget.d.ts.map +1 -1
  107. package/bundles/types/widget/multi-widget.d.ts +5 -1
  108. package/bundles/types/widget/multi-widget.d.ts.map +1 -1
  109. package/bundles/widget.umd.js +1698 -365
  110. package/bundles/widget.umd.js.d.ts +2376 -2046
  111. package/bundles/widget.umd.js.min.d.ts +2376 -2046
  112. package/bundles/widget.umd.min.js +1 -61
  113. package/docs/api-widget.md +25 -20
  114. package/docs/click-to-pay.md +1 -0
  115. package/docs/fraud-prevention-examples.md +154 -0
  116. package/docs/fraud-prevention.md +0 -0
  117. package/docs/install/npm.example.md +1 -1
  118. package/docs/paypal-data-collector-examples.md +6 -5
  119. package/docs/paypal-data-collector.md +6 -6
  120. package/docs/wallet-buttons-express.md +1 -0
  121. package/docs/wallet-buttons.md +1 -0
  122. package/docs/widget-examples.md +48 -3
  123. package/examples/multi-html-widget/extend.html +5 -0
  124. package/package.json +15 -10
  125. package/slate.md +204 -4
  126. package/bundles/types/shared/http/index.d.ts +0 -2
  127. package/bundles/types/shared/http/index.d.ts.map +0 -1
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
  ```
@@ -1922,3 +1967,158 @@ 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="https://widget.paydock.com/sdk/latest/widget.umd.js" ></script>
2004
+ </head>
2005
+
2006
+ <body>
2007
+ <main>
2008
+ <h1>Real time user behaviour anaylsis - Forter example</h1>
2009
+ <div class="forter-test">
2010
+ <h2>Forter Integration</h2>
2011
+
2012
+ <div class="status-card">
2013
+ <p>
2014
+ <strong>Integration Status:</strong>
2015
+ <span data-fraud-prevention="status-indicator" class="status pending">
2016
+ Pending
2017
+ </span>
2018
+ </p>
2019
+ <p>
2020
+ <strong>Token Value:</strong>
2021
+ <code data-fraud-prevention="forter-token">Not available</code>
2022
+ </p>
2023
+ <p data-fraud-prevention="error-container" style="display: none;">
2024
+ <strong>Error Code:</strong>
2025
+ <span data-fraud-prevention="error-code" class="error"></span>
2026
+ </p>
2027
+ </div>
2028
+ </div>
2029
+ </main>
2030
+ <script>
2031
+ const { FRAUD_PREVENTION_EVENTS, FraudPreventionService } = window.paydock
2032
+
2033
+ let token = '';
2034
+ let errorCode = '';
2035
+
2036
+ const render = () => {
2037
+ const statusIndicator = document.querySelector('[data-fraud-prevention="status-indicator"]');
2038
+ const tokenValue = document.querySelector('[data-fraud-prevention="forter-token"]');
2039
+ const errorContainer = document.querySelector('[data-fraud-prevention="error-container"]');
2040
+ const errorCodeElement = document.querySelector('[data-fraud-prevention="error-code"]');
2041
+
2042
+ if (token) {
2043
+ statusIndicator.className = 'status success';
2044
+ statusIndicator.textContent = 'Active';
2045
+ tokenValue.textContent = token;
2046
+ } else {
2047
+ statusIndicator.className = 'status pending';
2048
+ statusIndicator.textContent = 'Pending';
2049
+ tokenValue.textContent = 'Not available';
2050
+ }
2051
+
2052
+ if (errorCode) {
2053
+ errorCodeElement.textContent = errorCode;
2054
+ errorContainer.style.display = 'block';
2055
+ } else {
2056
+ errorContainer.style.display = 'none';
2057
+ }
2058
+ };
2059
+
2060
+ document.addEventListener(FRAUD_PREVENTION_EVENTS.NAMESPACE, (event) => {
2061
+ switch (event.detail.type) {
2062
+ case FRAUD_PREVENTION_EVENTS.TYPES.FINTERPRINT_TOKEN_READY: {
2063
+ token = event.detail.payload.token;
2064
+ break;
2065
+ }
2066
+ case FRAUD_PREVENTION_EVENTS.TYPES.FINGERPRINT_TOKEN_ERROR: {
2067
+ errorCode = event.detail.payload.code;
2068
+ break;
2069
+ }
2070
+ default: {
2071
+ throw new Error(
2072
+ `${FRAUD_PREVENTION_EVENTS.NAMESPACE} emitted an unsupported event: ${JSON.stringify(event.detail)}.`,
2073
+ );
2074
+ }
2075
+ }
2076
+
2077
+ render();
2078
+ });
2079
+
2080
+ const fraudPreventionServiceConfig = {
2081
+ environmentId: 'sandbox',
2082
+ mode: 'test'
2083
+ }
2084
+
2085
+ // Set "csp" to true if your website uses Content Security Policies
2086
+ const csp = false;
2087
+
2088
+ new FraudPreventionService(fraudPreventionServiceConfig)
2089
+ .withForter({
2090
+ siteId: 'example_site_id_or_subsite_id',
2091
+ csp,
2092
+ });
2093
+
2094
+ // new FraudPreventionService(fraudPreventionServiceConfig)
2095
+ // .withAccessTokenStrategy("eyJhb_access_token_example_...")
2096
+ // .withForter({
2097
+ // providerId: environment.forter.serviceId,
2098
+ // csp,
2099
+ // });
2100
+
2101
+ // new FraudPreventionService(fraudPreventionServiceConfig)
2102
+ // .withPublicKeyStrategy("pk_example_...")
2103
+ // .withForter({
2104
+ // providerId: environment.forter.serviceId,
2105
+ // csp,
2106
+ // });
2107
+ </script>
2108
+ </body>
2109
+
2110
+ </html>
2111
+ ```
2112
+
2113
+ #### Forter: Content Security Policies
2114
+
2115
+ If your site enforces Content Security Policies (CSP), make sure to:
2116
+
2117
+ 1. Set the `csp` option to `true` when invoking `withForter` on your `FraudPreventionService` instance.
2118
+ 2. Allowlist Forter's domains on `connect-src`, `script-src` and `worker-src` as shown below.
2119
+
2120
+ ```bash
2121
+ 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
2122
+ script-src https://*.forter.com https://dlthst9q2beh8.cloudfront.net https://d2nww8zpyj5pk0.cloudfront.net https://d2w2nqfk3z9hdt.cloudfront.net
2123
+ worker-src blob:
2124
+ ```
@@ -1,2 +0,0 @@
1
- export * from "./http-request";
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/shared/http/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA"}