UNPKG

@paydock/client-sdk

Version:

Paydock client sdk

105 lines (77 loc) 4.38 kB
## Classes <dl> <dt><a href="#AfterpayOnSiteMessaging">AfterpayOnSiteMessaging</a></dt> <dd><p>Afterpay On Site Messaging constructor</p> </dd> </dl> ## Typedefs <dl> <dt><a href="#OnErrorCallback">OnErrorCallback</a> : <code>function</code></dt> <dd><p>Callback for onError method.</p> </dd> </dl> ## Interfaces <dl> <dt><a href="#IAfterpayOnSiteMessagingConfig">IAfterpayOnSiteMessagingConfig</a> : <code>object</code></dt> <dd><p>Interface of data used for Afterpay On Site Messaging configuration. For further information refer to <a href="https://developers.afterpay.com/docs/api/afterpay-messaging/getting-started-with-afterpay-on-site-messaging">the documentation</a>.</p> </dd> </dl> <a name="IAfterpayOnSiteMessagingConfig" id="IAfterpayOnSiteMessagingConfig" href="#IAfterpayOnSiteMessagingConfig">&nbsp;</a> ## IAfterpayOnSiteMessagingConfig : <code>object</code> Interface of data used for Afterpay On Site Messaging configuration. For further information refer to [the documentation](https://developers.afterpay.com/docs/api/afterpay-messaging/getting-started-with-afterpay-on-site-messaging). **Kind**: global interface | Param | Type | Description | | --- | --- | --- | | [mpid] | <code>string</code> | Used for indicating the MPID. | | [placement_id] | <code>string</code> | Used for indicating the product Placement ID. | | [page_type] | <code>&#x27;cart&#x27;</code> \| <code>&#x27;product&#x27;</code> | Used for indicating the page type. Allowed values are: cart, product. | | [amount] | <code>string</code> | Used for indicating the amount. | | [currency] | <code>string</code> | Used for indicating the currency. | | [consumer_locale] | <code>string</code> | Used for indicating the consumer locale. | | [item_skus] | <code>string</code> | Used for indicating the SKU. | | [item_categories] | <code>string</code> | Used for indicating the category. | | [is_eligible] | <code>boolean</code> | Used for indicating if the user is eligible. | <a name="AfterpayOnSiteMessaging" id="AfterpayOnSiteMessaging" href="#AfterpayOnSiteMessaging">&nbsp;</a> ## AfterpayOnSiteMessaging Afterpay On Site Messaging constructor **Kind**: global class * [AfterpayOnSiteMessaging](#AfterpayOnSiteMessaging) * [new exports.AfterpayOnSiteMessaging(selector, config)](#new_AfterpayOnSiteMessaging_new) * [.load()](#AfterpayOnSiteMessaging+load) * [.onError([callback])](#AfterpayOnSiteMessaging+onError) <a name="new_AfterpayOnSiteMessaging_new" id="new_AfterpayOnSiteMessaging_new" href="#new_AfterpayOnSiteMessaging_new">&nbsp;</a> ### new exports.AfterpayOnSiteMessaging(selector, config) | Param | Type | Description | | --- | --- | --- | | selector | <code>string</code> | Selector of html element. Container for Afterpay On Site Messaging. | | config | [<code>IAfterpayOnSiteMessagingConfig</code>](#IAfterpayOnSiteMessagingConfig) | Required configuration for the Afterpay On Site Messaging. | **Example** ```js var afterpayOnSiteMessaging = new AfterpayOnSiteMessaging('#afterpayButton', config); ``` <a name="AfterpayOnSiteMessaging+load" id="AfterpayOnSiteMessaging+load" href="#AfterpayOnSiteMessaging+load">&nbsp;</a> ### afterpayOnSiteMessaging.load() The final method after configuring the AfterpayOnSiteMessaging to start the load process. **Kind**: instance method of [<code>AfterpayOnSiteMessaging</code>](#AfterpayOnSiteMessaging) <a name="AfterpayOnSiteMessaging+onError" id="AfterpayOnSiteMessaging+onError" href="#AfterpayOnSiteMessaging+onError">&nbsp;</a> ### afterpayOnSiteMessaging.onError([callback]) If the process fails, the function passed as parameter will be called. Important: Do not perform thread blocking operations in callback such as window.alert() calls. **Kind**: instance method of [<code>AfterpayOnSiteMessaging</code>](#AfterpayOnSiteMessaging) | Param | Type | Description | | --- | --- | --- | | [callback] | [<code>OnErrorCallback</code>](#OnErrorCallback) | Function to be called when there is an error in the flow. | **Example** ```js AfterpayOnSiteMessaging.onError((eventData) => console.log('Some error occur')); ``` <a name="OnErrorCallback" id="OnErrorCallback" href="#OnErrorCallback">&nbsp;</a> ## OnErrorCallback : <code>function</code> Callback for onError method. **Kind**: global typedef | Param | Type | | --- | --- | | data | <code>unknown</code> \| <code>null</code> |