POSConnector Allows for communication with the native POS application.
Kind: global class
- POSConnector
- static
- .LineItem
- .Transaction
- .Discount
- .Basket
- .LoginInformation
- .ContributingUser
- .TransactionType :
enum - .EventType :
enum - .addEventListener(type, listener)
- .removeEventListener(listener)
- .isConnected() ⇒
boolean - .payBasket(basket, callback, validate)
- .addBasket(basket, callback, validate, closeWebview)
- .getLoginInformation(callback)
- .openURL(url, callback)
- .printDocumentAtURL(url, callback)
- .printDocumentWithData(data, [callback])
- .sendPOSConnectorObjectPathToPOS(objectPath, [callback])
- inner
- ~barcodeScannedListener :
function - ~payBasketCallback :
function - ~addBasketCallback :
function - ~getLoginInformationCallback :
function - ~openURLCallback :
function - ~printDocumentCallback :
function - ~sendPOSConnectorObjectPathToPOSCallback :
function
- ~barcodeScannedListener :
- static
Kind: static class of POSConnector
new LineItem(name, quantity, unitPrice, [vatPercentage], [salesTaxPercentage], [productId], [imei], [discounts], [isExternalProduct], [userId], [contributingUsers], [productVariantId])
Represents a line item
Throws:
ErrorMissing required fields
| Param | Type | Description |
|---|---|---|
| name | string |
Name of the line item |
| quantity | number |
Number of items, positive or negative, represented on the line (eg. 5). Should always be integer |
| unitPrice | number |
The price of each item on the line (eg. 9.95) |
| [vatPercentage] | number | null |
The VAT included in the unit price (eg. 0.25). If not provided, price region default VAT rate is used |
| [salesTaxPercentage] | number | null |
The sales tax to apply to the unit price (eg. 0.05). If not provided, price region default sales tax rate is used |
| [productId] | string | null |
Id of the product represented on the line |
| [imei] | string | null |
IMEI of the product represented on the line |
| [discounts] | Array.<Discount> | null |
Discounts on the line item |
| [isExternalProduct] | boolean |
External product means product is physically in a different location (e.g. a warehouse). External products will not support adding shipping on POS |
| [userId] | string | null |
User id of line item |
| [contributingUsers] | Array.<ContributingUser> | null |
ContributingUsers on the line item |
| [productVariantId] | string | null |
Product variant id of line item |
Kind: static class of POSConnector
Represents a payment transaction. Can be used to allow the customer to make full or partial payment through your own system, instead of the POS. Note, that after sending a basket to POS, it can still be canceled or fail because of other reasons. In that case you should refund this transaction to the customer yourself.
| Param | Type | Description |
|---|---|---|
| transactionType | TransactionType |
The type of payment transaction |
| amount | number |
Amount payed by the transaction |
Kind: static class of POSConnector
Represents a discount on either a basket or a line item. Either amount or percentage must be set, but not both
Throws:
ErrorMissing required parameters or incorrectly set amount/percentage
| Param | Type | Description |
|---|---|---|
| description | string |
Reason for the discount to be given (shown on receipt) |
| [amount] | number | null |
Amount that the discount applies (eg. 90.50) |
| [percentage] | number | null |
The percentage which will be calculated based on what it's applied to (eg. 0.5 for 50% discount) |
Kind: static class of POSConnector
Represents a shopping basket
Throws:
ErrorMissing required parameters
| Param | Type | Description |
|---|---|---|
| id | string |
Id of the basket |
| lineItems | [ 'Array' ].<LineItem> |
Line items contained in the basket |
| [transactions] | Array.<Transaction> | null |
Transactions on the basket |
| [discounts] | Array.<Discount> | null |
Discounts on the basket |
| [customerId] | string | null |
Baskets Customers id |
Kind: static class of POSConnector
| Param | Type | Description |
|---|---|---|
| shopId | string |
Shop's id |
| shopName | string |
Shop's name |
| registerId | string |
Register's id |
| registerName | string |
Register's name |
| userId | string |
User's id |
| userName | string |
User's name |
Kind: static class of POSConnector
Represents a contributing user for line item
Throws:
ErrorMissing required parameters or incorrectly set contributionPercentage
| Param | Type | Description |
|---|---|---|
| userId | string |
ID of the User object in POS system |
| contributionPercentage | number |
Integer percentage (in range of 1-100) of user contribution |
Enum of possible transaction types
Kind: static enum property of POSConnector
Properties
| Name | Type | Default |
|---|---|---|
| Cash | string |
"Cash" |
| DebitorAccount | string |
"DebitorAccount" |
| Ecommerce | string |
"Ecommerce" |
| External | string |
"External" |
| ExternalCard | string |
"ExternalCard" |
| ExternalGiftCard | string |
"ExternalGiftCard" |
| GiftCardVoucher | string |
"GiftCardVoucher" |
| Installment | string |
"Installment" |
| MobilePay | string |
"MobilePay" |
| Vipps | string |
"Vipps" |
| Dintero | string |
"Dintero" |
| Invoice | string |
"Invoice" |
Enum of possible event types
Kind: static enum property of POSConnector
Properties
| Name | Type | Default |
|---|---|---|
| BarcodeScanned | string |
"BarcodeScanned" |
Add an event listener
Kind: static method of POSConnector
| Param | Type | Description |
|---|---|---|
| type | EventType |
The type of event to listen for |
| listener | barcodeScannedListener |
The listener function to add |
Remove an event listener
Kind: static method of POSConnector
| Param | Type | Description |
|---|---|---|
| listener | barcodeScannedListener |
The listener function to remove |
Check for connection toward the POS
Kind: static method of POSConnector
Returns: boolean - The connection status
Pass a basket to the POS and immediately go to payment view.
Note, that this will skip some steps in POS, like showing shipping method selection, setting delivery date,
adding a customer, etc. If you need any of these steps in your order, you should instead use addBasket function
Kind: static method of POSConnector
| Param | Type | Description |
|---|---|---|
| basket | Basket |
Basket to pass on to the POS |
| callback | payBasketCallback |
Called when the operation concludes |
| validate | boolean |
If true, POS will validate basket items against the database. All line items must have productId set. If any productId is not found in the database, POS will return an error through the callback. Also, provided line item properties (name, unit price, etc) will be overridden with those from the database. |
Pass a basket to the POS but don't go to payment view
Kind: static method of POSConnector
| Param | Type | Description |
|---|---|---|
| basket | Basket |
Basket to pass on to the POS |
| callback | addBasketCallback |
Called when the operation concludes |
| validate | boolean |
If true, POS will validate basket items against the database. All line items must have productId set. If any productId is not found in the database, POS will return an error through the callback. Also, provided line item properties (name, unit price, etc) will be overridden with those from the database. |
| closeWebview | boolean |
If true, Webview will be closed after adding item to the basket |
Get current login information from the native POS
Kind: static method of POSConnector
| Param | Type | Description |
|---|---|---|
| callback | getLoginInformationCallback |
Called when the operation concludes |
Request opening of a URL from the native application. The URL will open in which ever application the device prefers, typically Safari.
Kind: static method of POSConnector
| Param | Type | Description |
|---|---|---|
| url | string |
The URL to open |
| callback | openURLCallback |
Called when the native application opened or rejected opening the URL |
Request printing of a document located at a URL
Kind: static method of POSConnector
| Param | Type | Description |
|---|---|---|
| url | string |
The URL pointing toward the document to print |
| callback | printDocumentCallback |
Called when the operation concludes |
Requests printing of a document with a data object
Kind: static method of POSConnector
| Param | Type | Description |
|---|---|---|
| data | Blob | string |
The document data either contained in a Blob object or a base64 string |
| [callback] | printDocumentCallback |
Called when the operation concludes |
Send an object path for the POSConnector to the native POS application. You'd do this if you're utilizing modules or similar and you don't want to depend on having the POSConnector object with that specific variable name in the global scope.
Kind: static method of POSConnector
| Param | Type | Description |
|---|---|---|
| objectPath | string |
Path the the POSConnector object (ie. "Vendor.Wallmob.POSLink") |
| [callback] | sendPOSConnectorObjectPathToPOSCallback |
Called when the operation concludes. |
Passed to POSConnector.addEventListener for EventType.BarcodeScanned
Kind: inner typedef of POSConnector
| Param | Type | Description |
|---|---|---|
| barcode | string |
The barcode that was scanned |
Passed to the payBasket function
Kind: inner typedef of POSConnector
| Param | Type | Description |
|---|---|---|
| result | boolean |
Whether or not the payment was completed |
| [error] | string |
Optional string describing what went wrong |
Passed to the addBasket function
Kind: inner typedef of POSConnector
| Param | Type | Description |
|---|---|---|
| result | boolean |
Whether the item was successfully added to the basket |
| [error] | string |
Optional string describing what went wrong |
Passed to the getLoginInformation function
Kind: inner typedef of POSConnector
| Param | Type | Description |
|---|---|---|
| [result] | LoginInformation |
The requested login information if successful |
| [error] | string |
The error that occurred if unsuccessful |
Passed to the openURL function
Kind: inner typedef of POSConnector
| Param | Type | Description |
|---|---|---|
| [error] | string |
The error that occurred if unsuccessful |
Passed to the printDocumentAtURL and printDocumentData functions
Kind: inner typedef of POSConnector
| Param | Type | Description |
|---|---|---|
| result | boolean |
Whether or not the printing job was completed |
| [error] | string |
The error that occurred if printing wasn't just cancelled by the user |
Passed to the sendPOSConnectorObjectPathToPOS function
Kind: inner typedef of POSConnector
| Param | Type | Description |
|---|---|---|
| [error] | string |
The error that occurred if unsuccessful |