@paydock/client-sdk 1.115.0 → 1.116.2

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 (53) hide show
  1. package/README.md +531 -40
  2. package/bundles/index.cjs +515 -87
  3. package/bundles/index.cjs.d.ts +214 -1
  4. package/bundles/index.mjs +514 -88
  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/checkout/layout-widgets/payment-methods.d.ts +0 -1
  10. package/bundles/types/checkout/layout-widgets/payment-methods.d.ts.map +1 -1
  11. package/bundles/types/index-cba.d.ts +2 -0
  12. package/bundles/types/index-cba.d.ts.map +1 -1
  13. package/bundles/types/index.d.ts +2 -0
  14. package/bundles/types/index.d.ts.map +1 -1
  15. package/bundles/types/paypal-data-collector/index.d.ts +23 -0
  16. package/bundles/types/paypal-data-collector/index.d.ts.map +1 -0
  17. package/bundles/types/paypal-data-collector/paypal-data-collector.d.ts +58 -0
  18. package/bundles/types/paypal-data-collector/paypal-data-collector.d.ts.map +1 -0
  19. package/bundles/types/paypal-data-collector/paypal-data-collector.interfaces.d.ts +21 -0
  20. package/bundles/types/paypal-data-collector/paypal-data-collector.interfaces.d.ts.map +1 -0
  21. package/bundles/types/paypal-data-collector/paypal-data-collector.service.d.ts +17 -0
  22. package/bundles/types/paypal-data-collector/paypal-data-collector.service.d.ts.map +1 -0
  23. package/bundles/types/paypal-save-payment-source/index.d.ts +61 -0
  24. package/bundles/types/paypal-save-payment-source/index.d.ts.map +1 -0
  25. package/bundles/types/paypal-save-payment-source/paypal-save-payment-source.d.ts +85 -0
  26. package/bundles/types/paypal-save-payment-source/paypal-save-payment-source.d.ts.map +1 -0
  27. package/bundles/types/paypal-save-payment-source/paypal-save-payment-source.interfaces.d.ts +84 -0
  28. package/bundles/types/paypal-save-payment-source/paypal-save-payment-source.interfaces.d.ts.map +1 -0
  29. package/bundles/types/paypal-save-payment-source/paypal-save-payment-source.service.d.ts +36 -0
  30. package/bundles/types/paypal-save-payment-source/paypal-save-payment-source.service.d.ts.map +1 -0
  31. package/bundles/types/secure-remote-commerce/index.d.ts +0 -1
  32. package/bundles/types/secure-remote-commerce/index.d.ts.map +1 -1
  33. package/bundles/types/secure-remote-commerce/interfaces.d.ts +1 -5
  34. package/bundles/types/secure-remote-commerce/interfaces.d.ts.map +1 -1
  35. package/bundles/types/secure-remote-commerce/providers/mastercard-src/mastercard-src.d.ts.map +1 -1
  36. package/bundles/types/wallet-buttons-express/base.wallet-button-express.d.ts.map +1 -1
  37. package/bundles/types/wallet-buttons-express/interfaces/wallet-capture-request.interface.d.ts +1 -0
  38. package/bundles/types/wallet-buttons-express/interfaces/wallet-capture-request.interface.d.ts.map +1 -1
  39. package/bundles/types/wallet-buttons-express/services/apple-pay/apple-pay.wallet-button-express.d.ts.map +1 -1
  40. package/bundles/types/wallet-buttons-express/services/paypal/paypal.wallet-button-express.d.ts.map +1 -1
  41. package/bundles/widget.umd.js +515 -87
  42. package/bundles/widget.umd.js.d.ts +214 -1
  43. package/bundles/widget.umd.js.min.d.ts +214 -1
  44. package/bundles/widget.umd.min.js +7 -7
  45. package/docs/click-to-pay-examples.md +0 -36
  46. package/docs/click-to-pay.md +0 -3
  47. package/docs/paypal-data-collector-examples.md +58 -0
  48. package/docs/paypal-data-collector.md +149 -0
  49. package/docs/paypal-save-payment-source-examples.md +63 -0
  50. package/docs/paypal-save-payment-source.md +256 -0
  51. package/docs/wallet-buttons-express-examples.md +1 -1
  52. package/package.json +1 -1
  53. package/slate.md +0 -36
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");
@@ -7629,42 +7629,6 @@ src.setStyles({
7629
7629
  });
7630
7630
  ```
7631
7631
 
7632
- ## Recognition token
7633
-
7634
- In order to store user information for further payments, click to pay provides a recognition token that is used to load user information.
7635
- If you already have a recognitionToken stored, you can use it in meta to load the user information.
7636
-
7637
- ### Storage suggestions
7638
- 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:
7639
-
7640
- - `Expiration Date=` cookie should be set to expire at a max 180 days
7641
- - `Secure` flag
7642
- - `httpOnly` flag
7643
- - `sameSite=` strict
7644
- - `Value=` recognition token JWT
7645
-
7646
- ### Example code
7647
-
7648
- ```javascript
7649
- var src = new paydock.ClickToPay(
7650
- "#checkoutIframe",
7651
- "service_id",
7652
- "paydock_public_key",
7653
- {
7654
- "recognition_token": "eyJraWQiOiIy...",
7655
- },
7656
- );
7657
- src.on('recognitionTokenRequested', (data) => {
7658
- console.log('Recognition token was found: ' + data.data.recognitionToken);
7659
- // Add recognition token to your store
7660
- });
7661
-
7662
- src.on('recognitionTokenDropped', () => {
7663
- console.log('Recognition token was droped');
7664
- // Delete recognition token from your store
7665
- });
7666
- ```
7667
-
7668
7632
  ## Classes
7669
7633
 
7670
7634
  <dl>
@@ -7745,7 +7709,6 @@ Interface of data used for the Mastercard Checkout. For further information refe
7745
7709
  | [customer.phone.country_code] | <code>string</code> | Customer phone country code (example "1" for US). |
7746
7710
  | [customer.phone.phone] | <code>string</code> | Customer phone number. |
7747
7711
  | [unaccepted_card_type] | <code>string</code> | Used to block a specific card type. Options are 'CREDIT', 'DEBIT'. |
7748
- | [recognition_token] | <code>string</code> | Used for Click to Pay to load user information and preferences. |
7749
7712
 
7750
7713
  <a name="EventData" id="EventData" href="#EventData">&nbsp;</a>
7751
7714
 
@@ -7988,8 +7951,6 @@ List of available event's name in the Click To Pay checkout lifecycle
7988
7951
  | 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. |
7989
7952
  | CHECKOUT_COMPLETED | <code>string</code> | <code>&quot;checkoutCompleted&quot;</code> | Event sent on successful checkout by customer. Check [data](#EventDataCheckoutCompletedData) for more information. |
7990
7953
  | CHECKOUT_ERROR | <code>string</code> | <code>&quot;checkoutError&quot;</code> | Event sent on error checkout by customer. Check [data](#EventData) for more information. |
7991
- | RECOGNITION_TOKEN_REQUESTED | <code>string</code> | <code>&quot;recognitionTokenRequested&quot;</code> | Event sent when a recognition token was found on the mastercard SDK response. |
7992
- | 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. |
7993
7954
 
7994
7955
  <a name="EVENT_DATA_TYPE" id="EVENT_DATA_TYPE" href="#EVENT_DATA_TYPE">&nbsp;</a>
7995
7956
 
@@ -8005,5 +7966,535 @@ List of available event data types
8005
7966
  | SUCCESS | <code>string</code> | <code>&quot;Success&quot;</code> | |
8006
7967
 
8007
7968
 
7969
+ ## PayPalSavePaymentSource Widget
7970
+
7971
+ PayPalSavePaymentSource Widget allows to obtain a Paydock one time token linked with a Paypal payment source from the customer.
7972
+
7973
+ The general flow to use the widgets is:
7974
+ 1. Configure your PayPal gateway and connect it using Paydock API or Dashboard.
7975
+ 2. Create a container in your site
7976
+ ```html
7977
+ <div id="widget"></div>
7978
+ ```
7979
+ 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:
7980
+ ```js
7981
+ new paydock.PayPalSavePaymentSourceWidget(
7982
+ "#widget",
7983
+ accessTokenOrPublicKey,
7984
+ gatewayId,
7985
+ widgetSpecificConfig,
7986
+ );
7987
+ ```
7988
+ 4. Handle the `onSuccess`, `onError` and `onCancel` for paypal setup token results.
7989
+ 5. If `onSuccess` event is emmited, event data should contain `token` and `email` ready to use.
7990
+
7991
+ ### Example
7992
+
7993
+ 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.
7994
+
7995
+ ```html
7996
+ <!DOCTYPE html>
7997
+ <html lang="en">
7998
+ <head>
7999
+ <meta charset="UTF-8">
8000
+ <title>Title</title>
8001
+ </head>
8002
+ <body>
8003
+ <h2>Using PayDock PayPalSavePaymentSourceWidget!</h2>
8004
+ <div id="widget"></div>
8005
+ </body>
8006
+ <script src="https://widget.paydock.com/sdk/latest/widget.umd.min.js" ></script>
8007
+ <script>
8008
+ let button = new paydock.PayPalSavePaymentSourceWidget(
8009
+ "#widget",
8010
+ accessTokenOrPublicKey,
8011
+ gatewayId,
8012
+ {
8013
+ style: {
8014
+ layout: 'vertical',
8015
+ color: 'gold',
8016
+ shape: 'pill',
8017
+ label: 'paypal'
8018
+ }
8019
+ }
8020
+ );
8021
+
8022
+ payPalSavePaymentSourceWidget.onSuccess((data) => console.log('On success: ', data));
8023
+ payPalSavePaymentSourceWidget.onError((data) => console.log('On error: ', data));
8024
+ payPalSavePaymentSourceWidget.onCancel(() => console.log('On cancelled'));
8025
+
8026
+ button.setEnv('sandbox');
8027
+
8028
+ button.load();
8029
+ </script>
8030
+ </html>
8031
+ ```
8032
+
8033
+ ## Classes
8034
+
8035
+ <dl>
8036
+ <dt><a href="#PayPalSavePaymentSourceWidget">PayPalSavePaymentSourceWidget</a></dt>
8037
+ <dd><p>PayPal Save Payment Source Widget constructor</p>
8038
+ </dd>
8039
+ </dl>
8040
+
8041
+ ## Typedefs
8042
+
8043
+ <dl>
8044
+ <dt><a href="#OnSuccessCallback">OnSuccessCallback</a> : <code>function</code></dt>
8045
+ <dd><p>Callback for onSuccess method.</p>
8046
+ </dd>
8047
+ <dt><a href="#OnErrorCallback">OnErrorCallback</a> : <code>function</code></dt>
8048
+ <dd><p>Callback for onError method.</p>
8049
+ </dd>
8050
+ <dt><a href="#OnCancelCallback">OnCancelCallback</a> : <code>function</code></dt>
8051
+ <dd><p>Callback for onCancel method.</p>
8052
+ </dd>
8053
+ </dl>
8054
+
8055
+ ## Interfaces
8056
+
8057
+ <dl>
8058
+ <dt><a href="#PayPalSavePaymentSourceWidgetConfig">PayPalSavePaymentSourceWidgetConfig</a> : <code>object</code></dt>
8059
+ <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>
8060
+ </dd>
8061
+ <dt><a href="#ErrorCodes">ErrorCodes</a> : <code>object</code></dt>
8062
+ <dd><p>Interface of possible error codes inside onError event data.</p>
8063
+ </dd>
8064
+ <dt><a href="#IOnSuccessEventData">IOnSuccessEventData</a> : <code>object</code></dt>
8065
+ <dd><p>Interface for IOnSuccessEventData</p>
8066
+ </dd>
8067
+ <dt><a href="#IOnErrorEventData">IOnErrorEventData</a> : <code>object</code></dt>
8068
+ <dd><p>Interface for IOnErrorEventData</p>
8069
+ </dd>
8070
+ <dt><a href="#IOnCancelEventData">IOnCancelEventData</a> : <code>object</code></dt>
8071
+ <dd><p>Interface for IOnCancelEventData</p>
8072
+ </dd>
8073
+ </dl>
8074
+
8075
+ <a name="PayPalSavePaymentSourceWidgetConfig" id="PayPalSavePaymentSourceWidgetConfig" href="#PayPalSavePaymentSourceWidgetConfig">&nbsp;</a>
8076
+
8077
+ ## PayPalSavePaymentSourceWidgetConfig : <code>object</code>
8078
+ Interface of data used for PayPal configuration. For further information refer to [the documentation](https://developer.paypal.com/sdk/js/reference/#style).
8079
+
8080
+ **Kind**: global interface
8081
+
8082
+ | Param | Type | Description |
8083
+ | --- | --- | --- |
8084
+ | [style.layout] | <code>&#x27;vertical&#x27;</code> \| <code>&#x27;horizontal&#x27;</code> | Used for indicating the PayPal Button layout. |
8085
+ | [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. |
8086
+ | [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. |
8087
+ | [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. |
8088
+ | [style.disableMaxWidth] | <code>boolean</code> | Used for indicating if the max width will be disabled. |
8089
+ | [style.disableMaxHeight] | <code>boolean</code> | Used for indicating the max height will be disabled. |
8090
+ | [style.height] | <code>number</code> | Used for indicating the height of the PayPal Button, if disableMaxHeight is true. |
8091
+ | [style.borderRadius] | <code>number</code> | Used for indicating the border radius of the PayPal Button. |
8092
+ | [style.tagline] | <code>boolean</code> | Used for indicating the tagline of the PayPal Button. |
8093
+ | [message.amount] | <code>number</code> | Used for indicating an amount before the payment. |
8094
+ | [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. |
8095
+ | [message.color] | <code>&#x27;black&#x27;</code> \| <code>&#x27;white&#x27;</code> | Used for indicating the color of the message. |
8096
+ | [message.position] | <code>&#x27;top&#x27;</code> \| <code>&#x27;bottom&#x27;</code> | Used for indicating the position of the message. |
8097
+
8098
+ <a name="ErrorCodes" id="ErrorCodes" href="#ErrorCodes">&nbsp;</a>
8099
+
8100
+ ## ErrorCodes : <code>object</code>
8101
+ Interface of possible error codes inside onError event data.
8102
+
8103
+ **Kind**: global interface
8104
+
8105
+ | Param | Type | Description |
8106
+ | --- | --- | --- |
8107
+ | [unavailable] | <code>string</code> | Error code when an error occurs loading the widget. |
8108
+ | [onPaypalVaultSetupTokenError] | <code>string</code> | Error code when an error occrus on PayPal side. |
8109
+ | [onGetIdTokenError] | <code>string</code> | Error code when trying to get ID token from PayPal. |
8110
+ | [onGetWalletConfigError] | <code>string</code> | Error code when trying to get wallet config from Paydock. |
8111
+ | [onGetSetupTokenError] | <code>string</code> | Error code when trying to get the setup token from PayPal. |
8112
+ | [onOneTimeTokenError] | <code>string</code> | Error code when trying to get the one time token from Paydock. |
8113
+
8114
+ <a name="IOnSuccessEventData" id="IOnSuccessEventData" href="#IOnSuccessEventData">&nbsp;</a>
8115
+
8116
+ ## IOnSuccessEventData : <code>object</code>
8117
+ Interface for IOnSuccessEventData
8118
+
8119
+ **Kind**: global interface
8120
+
8121
+ | Param | Type | Description |
8122
+ | --- | --- | --- |
8123
+ | event | <code>EVENTS</code> | Event Name is 'ON_SUCCESS' |
8124
+ | data | <code>object</code> | Data object |
8125
+ | data.token | <code>string</code> | One Time Token to be exchanged for a Paydock Customer. |
8126
+ | [data.email] | <code>string</code> | Paypal account customer email if retrieved from Paypal servers. |
8127
+
8128
+ <a name="IOnErrorEventData" id="IOnErrorEventData" href="#IOnErrorEventData">&nbsp;</a>
8129
+
8130
+ ## IOnErrorEventData : <code>object</code>
8131
+ Interface for IOnErrorEventData
8132
+
8133
+ **Kind**: global interface
8134
+
8135
+ | Param | Type | Description |
8136
+ | --- | --- | --- |
8137
+ | event | <code>EVENTS</code> | Event Name is 'ON_ERROR' |
8138
+ | data | <code>object</code> | Error data object |
8139
+ | data.error_code | [<code>ErrorCodes</code>](#ErrorCodes) | Error code. One of ErrorCodes. |
8140
+ | [data.details] | <code>string</code> | Error details. |
8141
+ | [data.message] | <code>string</code> | Error message. |
8142
+
8143
+ <a name="IOnCancelEventData" id="IOnCancelEventData" href="#IOnCancelEventData">&nbsp;</a>
8144
+
8145
+ ## IOnCancelEventData : <code>object</code>
8146
+ Interface for IOnCancelEventData
8147
+
8148
+ **Kind**: global interface
8149
+
8150
+ | Param | Type | Description |
8151
+ | --- | --- | --- |
8152
+ | event | <code>EVENTS</code> | Event Name is 'ON_CANCEL' |
8153
+
8154
+ <a name="PayPalSavePaymentSourceWidget" id="PayPalSavePaymentSourceWidget" href="#PayPalSavePaymentSourceWidget">&nbsp;</a>
8155
+
8156
+ ## PayPalSavePaymentSourceWidget
8157
+ PayPal Save Payment Source Widget constructor
8158
+
8159
+ **Kind**: global class
8160
+
8161
+ * [PayPalSavePaymentSourceWidget](#PayPalSavePaymentSourceWidget)
8162
+ * [new PayPalSavePaymentSourceWidget(selector, publicKey, gatewayId, config)](#new_PayPalSavePaymentSourceWidget_new)
8163
+ * [.load()](#PayPalSavePaymentSourceWidget+load)
8164
+ * [.setEnv(env, [alias])](#PayPalSavePaymentSourceWidget+setEnv)
8165
+ * [.onSuccess([callback])](#PayPalSavePaymentSourceWidget+onSuccess)
8166
+ * [.onError([callback])](#PayPalSavePaymentSourceWidget+onError)
8167
+ * [.onCancel([callback])](#PayPalSavePaymentSourceWidget+onCancel)
8168
+
8169
+ <a name="new_PayPalSavePaymentSourceWidget_new" id="new_PayPalSavePaymentSourceWidget_new" href="#new_PayPalSavePaymentSourceWidget_new">&nbsp;</a>
8170
+
8171
+ ### new PayPalSavePaymentSourceWidget(selector, publicKey, gatewayId, config)
8172
+
8173
+ | Param | Type | Description |
8174
+ | --- | --- | --- |
8175
+ | selector | <code>string</code> | Selector of html element. Container for PayPal Save Payment Source Widget. |
8176
+ | publicKey | <code>string</code> | PayDock users public key. |
8177
+ | gatewayId | <code>string</code> | PayDock's PayPal gatewayId. |
8178
+ | config | [<code>PayPalSavePaymentSourceWidgetConfig</code>](#PayPalSavePaymentSourceWidgetConfig) | Extra configuration for the widget, like styles. |
8179
+
8180
+ **Example**
8181
+ ```js
8182
+ var payPalSavePaymentSourceWidget = new PayPalSavePaymentSourceWidget('#paypalButton', 'public_key', 'gateway_id');
8183
+ ```
8184
+ <a name="PayPalSavePaymentSourceWidget+load" id="PayPalSavePaymentSourceWidget+load" href="#PayPalSavePaymentSourceWidget+load">&nbsp;</a>
8185
+
8186
+ ### payPalSavePaymentSourceWidget.load()
8187
+ The final method after configuring the PayPalSavePaymentSource Widget to
8188
+ start the load process.
8189
+
8190
+ **Kind**: instance method of [<code>PayPalSavePaymentSourceWidget</code>](#PayPalSavePaymentSourceWidget)
8191
+ <a name="PayPalSavePaymentSourceWidget+setEnv" id="PayPalSavePaymentSourceWidget+setEnv" href="#PayPalSavePaymentSourceWidget+setEnv">&nbsp;</a>
8192
+
8193
+ ### payPalSavePaymentSourceWidget.setEnv(env, [alias])
8194
+ Current method can change environment. By default environment = sandbox.
8195
+ Also we can change domain alias for this environment. By default domain_alias = paydock.com
8196
+
8197
+ **Kind**: instance method of [<code>PayPalSavePaymentSourceWidget</code>](#PayPalSavePaymentSourceWidget)
8198
+
8199
+ | Param | Type | Description |
8200
+ | --- | --- | --- |
8201
+ | env | <code>string</code> | sandbox, production |
8202
+ | [alias] | <code>string</code> | Own domain alias |
8203
+
8204
+ **Example**
8205
+ ```js
8206
+ payPalSavePaymentSourceWidget.setEnv('production');
8207
+ ```
8208
+ <a name="PayPalSavePaymentSourceWidget+onSuccess" id="PayPalSavePaymentSourceWidget+onSuccess" href="#PayPalSavePaymentSourceWidget+onSuccess">&nbsp;</a>
8209
+
8210
+ ### payPalSavePaymentSourceWidget.onSuccess([callback])
8211
+ If the setup token was successfully approved and a OTT was generated, the function passed as parameter will be called.
8212
+ Important: Do not perform thread blocking operations in callback such as window.alert() calls.
8213
+
8214
+ **Kind**: instance method of [<code>PayPalSavePaymentSourceWidget</code>](#PayPalSavePaymentSourceWidget)
8215
+
8216
+ | Param | Type | Description |
8217
+ | --- | --- | --- |
8218
+ | [callback] | [<code>OnSuccessCallback</code>](#OnSuccessCallback) | Function to be called when the result is successful. |
8219
+
8220
+ **Example**
8221
+ ```js
8222
+ payPalSavePaymentSourceWidget.onSuccess((eventData) => console.log('One time token and email obtained successfully'));
8223
+ ```
8224
+ <a name="PayPalSavePaymentSourceWidget+onError" id="PayPalSavePaymentSourceWidget+onError" href="#PayPalSavePaymentSourceWidget+onError">&nbsp;</a>
8225
+
8226
+ ### payPalSavePaymentSourceWidget.onError([callback])
8227
+ If in the process for obtaining the setup token fails, the function passed as parameter will be called.
8228
+ Important: Do not perform thread blocking operations in callback such as window.alert() calls.
8229
+
8230
+ **Kind**: instance method of [<code>PayPalSavePaymentSourceWidget</code>](#PayPalSavePaymentSourceWidget)
8231
+
8232
+ | Param | Type | Description |
8233
+ | --- | --- | --- |
8234
+ | [callback] | [<code>OnErrorCallback</code>](#OnErrorCallback) | Function to be called when there is an error in the flow. |
8235
+
8236
+ **Example**
8237
+ ```js
8238
+ payPalSavePaymentSourceWidget.onError((eventData) => console.log('Some error occurred'));
8239
+ ```
8240
+ <a name="PayPalSavePaymentSourceWidget+onCancel" id="PayPalSavePaymentSourceWidget+onCancel" href="#PayPalSavePaymentSourceWidget+onCancel">&nbsp;</a>
8241
+
8242
+ ### payPalSavePaymentSourceWidget.onCancel([callback])
8243
+ If in the process for obtaining the setup token was cancelled, the function passed as parameter will be called.
8244
+ Important: Do not perform thread blocking operations in callback such as window.alert() calls.
8245
+
8246
+ **Kind**: instance method of [<code>PayPalSavePaymentSourceWidget</code>](#PayPalSavePaymentSourceWidget)
8247
+
8248
+ | Param | Type | Description |
8249
+ | --- | --- | --- |
8250
+ | [callback] | [<code>OnCancelCallback</code>](#OnCancelCallback) | Function to be called when the operation is cancelled. |
8251
+
8252
+ **Example**
8253
+ ```js
8254
+ payPalSavePaymentSourceWidget.onCancel(() => console.log('Operation cancelled'));
8255
+ ```
8256
+ <a name="OnSuccessCallback" id="OnSuccessCallback" href="#OnSuccessCallback">&nbsp;</a>
8257
+
8258
+ ## OnSuccessCallback : <code>function</code>
8259
+ Callback for onSuccess method.
8260
+
8261
+ **Kind**: global typedef
8262
+
8263
+ | Param | Type |
8264
+ | --- | --- |
8265
+ | data | [<code>IOnSuccessEventData</code>](#IOnSuccessEventData) |
8266
+
8267
+ <a name="OnErrorCallback" id="OnErrorCallback" href="#OnErrorCallback">&nbsp;</a>
8268
+
8269
+ ## OnErrorCallback : <code>function</code>
8270
+ Callback for onError method.
8271
+
8272
+ **Kind**: global typedef
8273
+
8274
+ | Param | Type |
8275
+ | --- | --- |
8276
+ | data | [<code>IOnErrorEventData</code>](#IOnErrorEventData) |
8277
+
8278
+ <a name="OnCancelCallback" id="OnCancelCallback" href="#OnCancelCallback">&nbsp;</a>
8279
+
8280
+ ## OnCancelCallback : <code>function</code>
8281
+ Callback for onCancel method.
8282
+
8283
+ **Kind**: global typedef
8284
+
8285
+ | Param | Type |
8286
+ | --- | --- |
8287
+ | data | [<code>IOnCancelEventData</code>](#IOnCancelEventData) |
8288
+
8289
+
8290
+ ## PayPalDataCollector Widget
8291
+
8292
+ 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.
8293
+
8294
+ The general flow to use the widgets is:
8295
+ 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:
8296
+ ```js
8297
+ vat paypalDataCollector = new paydock.PayPalDataCollector(
8298
+ sourceWebsiteIdentifier,
8299
+ widgetConfigParams,
8300
+ );
8301
+ ```
8302
+ 2. Handle the `collectDeviceData` function, that will return the generated correlation ID, like following:
8303
+ ```js
8304
+ const collectedDeviceData = await paypalDataCollector.collectDeviceData();
8305
+ const correlationId = collectedDeviceData.correlation_id;
8306
+ ```
8307
+ 3. Use freely the correlation_id value as is needed.
8308
+ 4. Handle the `onError` callback.
8309
+ 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).
8310
+
8311
+ ### PayPalDataCollector Widget example
8312
+
8313
+ 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.
8314
+
8315
+ ```html
8316
+ <!DOCTYPE html>
8317
+ <html lang="en">
8318
+ <head>
8319
+ <meta charset="UTF-8">
8320
+ <title>Title</title>
8321
+ </head>
8322
+ <body>
8323
+ <h2>Using PayDock PayPalDataCollector Widget!</h2>
8324
+ <div id="widget"></div>
8325
+ </body>
8326
+ <script src="https://widget.paydock.com/sdk/latest/widget.umd.min.js" ></script>
8327
+ <script>
8328
+ let payPalDataCollector = new paydock.PayPalDataCollector(
8329
+ sourceWebsiteIdentifier,
8330
+ {
8331
+ mouse_movement: true
8332
+ }
8333
+ );
8334
+
8335
+ payPalDataCollector.setEnv('test');
8336
+
8337
+ payPalDataCollector.onError(function(error) {
8338
+ console.log("On Error Callback", error);
8339
+ });
8340
+
8341
+ const collectedDeviceData = await payPalDataCollector.collectDeviceData();
8342
+
8343
+ //Here when the promise is resolved, it should be able to see the correlation_id.
8344
+ const correlationId = collectedDeviceData.correlation_id
8345
+ </script>
8346
+ </html>
8347
+ ```
8348
+
8349
+ ## Classes
8350
+
8351
+ <dl>
8352
+ <dt><a href="#PayPalDataCollector">PayPalDataCollector</a></dt>
8353
+ <dd><p>PayPal Data Collector Widget constructor</p>
8354
+ </dd>
8355
+ </dl>
8356
+
8357
+ ## Typedefs
8358
+
8359
+ <dl>
8360
+ <dt><a href="#OnErrorCallback">OnErrorCallback</a> : <code>function</code></dt>
8361
+ <dd><p>Callback for onError method.</p>
8362
+ </dd>
8363
+ </dl>
8364
+
8365
+ ## Interfaces
8366
+
8367
+ <dl>
8368
+ <dt><a href="#PayPalDataCollectorConfig">PayPalDataCollectorConfig</a> : <code>object</code></dt>
8369
+ <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>
8370
+ </dd>
8371
+ <dt><a href="#CollectedDeviceData">CollectedDeviceData</a> : <code>object</code></dt>
8372
+ <dd><p>Data object with the corresponding <code>correlation_id</code>.</p>
8373
+ </dd>
8374
+ <dt><a href="#IOnErrorEventData">IOnErrorEventData</a> : <code>object</code></dt>
8375
+ <dd><p>Interface for IOnErrorEventData</p>
8376
+ </dd>
8377
+ </dl>
8378
+
8379
+ <a name="PayPalDataCollectorConfig" id="PayPalDataCollectorConfig" href="#PayPalDataCollectorConfig">&nbsp;</a>
8380
+
8381
+ ## PayPalDataCollectorConfig : <code>object</code>
8382
+ Interface of data used for PayPal configuration. For further information refer to [the documentation](https://developer.paypal.com/sdk/js/reference/#style).
8383
+
8384
+ **Kind**: global interface
8385
+
8386
+ | Param | Type | Description |
8387
+ | --- | --- | --- |
8388
+ | [mouse_movement] | <code>boolean</code> | Used for indicating if is enabled mouse movement collection. |
8389
+
8390
+ <a name="CollectedDeviceData" id="CollectedDeviceData" href="#CollectedDeviceData">&nbsp;</a>
8391
+
8392
+ ## CollectedDeviceData : <code>object</code>
8393
+ Data object with the corresponding `correlation_id`.
8394
+
8395
+ **Kind**: global interface
8396
+
8397
+ | Param | Type | Description |
8398
+ | --- | --- | --- |
8399
+ | [correlation_id] | <code>string</code> | The correlation ID that was used on the subsecuent requests. |
8400
+
8401
+ <a name="IOnErrorEventData" id="IOnErrorEventData" href="#IOnErrorEventData">&nbsp;</a>
8402
+
8403
+ ## IOnErrorEventData : <code>object</code>
8404
+ Interface for IOnErrorEventData
8405
+
8406
+ **Kind**: global interface
8407
+
8408
+ | Param | Type | Description |
8409
+ | --- | --- | --- |
8410
+ | error_code | <code>string</code> | Error code. One of 'promise_not_enabled' or 'script_error'. |
8411
+
8412
+ <a name="PayPalDataCollector" id="PayPalDataCollector" href="#PayPalDataCollector">&nbsp;</a>
8413
+
8414
+ ## PayPalDataCollector
8415
+ PayPal Data Collector Widget constructor
8416
+
8417
+ **Kind**: global class
8418
+
8419
+ * [PayPalDataCollector](#PayPalDataCollector)
8420
+ * [new PayPalDataCollector(flowId, config)](#new_PayPalDataCollector_new)
8421
+ * [.collectDeviceData()](#PayPalDataCollector+collectDeviceData) ⇒ [<code>Promise.&lt;CollectedDeviceData&gt;</code>](#CollectedDeviceData)
8422
+ * [.onError([callback])](#PayPalDataCollector+onError)
8423
+ * [.setEnv(env)](#PayPalDataCollector+setEnv)
8424
+
8425
+ <a name="new_PayPalDataCollector_new" id="new_PayPalDataCollector_new" href="#new_PayPalDataCollector_new">&nbsp;</a>
8426
+
8427
+ ### new PayPalDataCollector(flowId, config)
8428
+
8429
+ | Param | Type | Description |
8430
+ | --- | --- | --- |
8431
+ | flowId | <code>string</code> | This string identifies the source website of the FraudNet request. |
8432
+ | config | [<code>PayPalDataCollectorConfig</code>](#PayPalDataCollectorConfig) | Extra configuration for the widget. |
8433
+
8434
+ **Example**
8435
+ ```js
8436
+ var payPalDataCollector = new PayPalDataCollector('FLOW_ID', {});
8437
+ ```
8438
+ <a name="PayPalDataCollector+collectDeviceData" id="PayPalDataCollector+collectDeviceData" href="#PayPalDataCollector+collectDeviceData">&nbsp;</a>
8439
+
8440
+ ### payPalDataCollector.collectDeviceData() ⇒ [<code>Promise.&lt;CollectedDeviceData&gt;</code>](#CollectedDeviceData)
8441
+ After configuring the PayPalDataCollector Widget, starts the process and returns
8442
+ the correlation id used among the requests.
8443
+
8444
+ **Kind**: instance method of [<code>PayPalDataCollector</code>](#PayPalDataCollector)
8445
+ **Returns**: [<code>Promise.&lt;CollectedDeviceData&gt;</code>](#CollectedDeviceData) - Promise when resolved, returnsa an object
8446
+ that contains the `correlation_id` key.
8447
+ **Example**
8448
+ ```js
8449
+ const collectedDeviceData = await payPalDataCollectorWidget.collectDeviceData();
8450
+ console.log(collectedDeviceData.correlation_id)
8451
+ ```
8452
+ <a name="PayPalDataCollector+onError" id="PayPalDataCollector+onError" href="#PayPalDataCollector+onError">&nbsp;</a>
8453
+
8454
+ ### payPalDataCollector.onError([callback])
8455
+ If the process fails, the function passed as parameter will be called.
8456
+ Important: Do not perform thread blocking operations in callback such as window.alert() calls.
8457
+
8458
+ **Kind**: instance method of [<code>PayPalDataCollector</code>](#PayPalDataCollector)
8459
+
8460
+ | Param | Type | Description |
8461
+ | --- | --- | --- |
8462
+ | [callback] | [<code>OnErrorCallback</code>](#OnErrorCallback) | Function to be called when there is an error in the flow. |
8463
+
8464
+ **Example**
8465
+ ```js
8466
+ PayPalDataCollector.onError((eventData) => console.log('Some error occur'));
8467
+ ```
8468
+ <a name="PayPalDataCollector+setEnv" id="PayPalDataCollector+setEnv" href="#PayPalDataCollector+setEnv">&nbsp;</a>
8469
+
8470
+ ### payPalDataCollector.setEnv(env)
8471
+ Current method can change environment. By default environment = test.
8472
+ This method does not affect Paydock's API calls or environments, is only for PayPal Data Collector
8473
+ script, in order to know if the script is injected on a live server or is a testing
8474
+ environment. The available values are `test` and `live`. This should match with the used
8475
+ `gateway.mode` in Paydock to process the transaction.
8476
+
8477
+ **Kind**: instance method of [<code>PayPalDataCollector</code>](#PayPalDataCollector)
8478
+
8479
+ | Param | Type | Description |
8480
+ | --- | --- | --- |
8481
+ | env | <code>string</code> | test, live |
8482
+
8483
+ **Example**
8484
+ ```js
8485
+ PayPalDataCollector.setEnv('live');
8486
+ ```
8487
+ <a name="OnErrorCallback" id="OnErrorCallback" href="#OnErrorCallback">&nbsp;</a>
8488
+
8489
+ ## OnErrorCallback : <code>function</code>
8490
+ Callback for onError method.
8491
+
8492
+ **Kind**: global typedef
8493
+
8494
+ | Param | Type |
8495
+ | --- | --- |
8496
+ | data | [<code>IOnErrorEventData</code>](#IOnErrorEventData) \| <code>null</code> |
8497
+
8498
+
8008
8499
  ## License
8009
8500
  Copyright (c) 2024 paydock