Skip to content

Wallmob/POSConnector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

POSConnector

POSConnector Allows for communication with the native POS application.

Kind: global class

POSConnector.LineItem

Kind: static class of POSConnector

new LineItem(name, quantity, unitPrice, [vatPercentage], [salesTaxPercentage], [productId], [imei], [discounts], [isExternalProduct], [userId], [contributingUsers], [productVariantId])

Represents a line item

Throws:

  • Error Missing 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

POSConnector.Transaction

Kind: static class of POSConnector

new Transaction(transactionType, amount)

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

POSConnector.Discount

Kind: static class of POSConnector

new Discount(description, [amount], [percentage])

Represents a discount on either a basket or a line item. Either amount or percentage must be set, but not both

Throws:

  • Error Missing 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)

POSConnector.Basket

Kind: static class of POSConnector

new Basket(id, lineItems, [transactions], [discounts], [customerId])

Represents a shopping basket

Throws:

  • Error Missing 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

POSConnector.LoginInformation

Kind: static class of POSConnector

new LoginInformation(shopId, shopName, registerId, registerName, userId, userName)

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

POSConnector.ContributingUser

Kind: static class of POSConnector

new ContributingUser(userId, contributionPercentage)

Represents a contributing user for line item

Throws:

  • Error Missing 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

POSConnector.TransactionType : enum

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"

POSConnector.EventType : enum

Enum of possible event types

Kind: static enum property of POSConnector
Properties

Name Type Default
BarcodeScanned string "BarcodeScanned"

POSConnector.addEventListener(type, listener)

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

POSConnector.removeEventListener(listener)

Remove an event listener

Kind: static method of POSConnector

Param Type Description
listener barcodeScannedListener The listener function to remove

POSConnector.isConnected() ⇒ boolean

Check for connection toward the POS

Kind: static method of POSConnector
Returns: boolean - The connection status

POSConnector.payBasket(basket, callback, validate)

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.

POSConnector.addBasket(basket, callback, validate, closeWebview)

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

POSConnector.getLoginInformation(callback)

Get current login information from the native POS

Kind: static method of POSConnector

Param Type Description
callback getLoginInformationCallback Called when the operation concludes

POSConnector.openURL(url, callback)

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

POSConnector.printDocumentAtURL(url, callback)

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

POSConnector.printDocumentWithData(data, [callback])

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

POSConnector.sendPOSConnectorObjectPathToPOS(objectPath, [callback])

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.

POSConnector~barcodeScannedListener : function

Passed to POSConnector.addEventListener for EventType.BarcodeScanned

Kind: inner typedef of POSConnector

Param Type Description
barcode string The barcode that was scanned

POSConnector~payBasketCallback : function

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

POSConnector~addBasketCallback : function

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

POSConnector~getLoginInformationCallback : function

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

POSConnector~openURLCallback : function

Passed to the openURL function

Kind: inner typedef of POSConnector

Param Type Description
[error] string The error that occurred if unsuccessful

POSConnector~printDocumentCallback : function

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

POSConnector~sendPOSConnectorObjectPathToPOSCallback : function

Passed to the sendPOSConnectorObjectPathToPOS function

Kind: inner typedef of POSConnector

Param Type Description
[error] string The error that occurred if unsuccessful