@leatcom/portal-sessions
v0.0.84
Published
This is the Javascript SDK for integrating with Leat | Piggy using Portal Sessions. Sign up for a free Leat | Piggy account [here](https://business.piggy.eu/sign-up).
Downloads
239
Keywords
Readme
Portal Sessions by Leat | Piggy
This is the Javascript SDK for integrating with Leat | Piggy using Portal Sessions. Sign up for a free Leat | Piggy account here.
More information on Portal Sessions and their specific API calls can be found on the API Documentation.
Installation
Install using
npm install @leatcom/portal-sessions
yarn add @leatcom/portal-sessions
Documentation
Usage
Portal Sessions come in different types, each with their own use. To initiate a Portal Sessions, an API key is required,
which can be created in your account's Dashboard. A Portal BaseSession is also always
created for
a specific Shop
, so the shopUuid
is also required. You can find a Shop's UUID in
your Dashboard or
by API.
Currently, there are five Portal BaseSession types:
PORTAL
: This is the 'default' session type, which doesn't have a predefined aim, but rather allows for flexible use. See this as a way for customers to login to their own portal.REDEEM_GIFTCARD
: A session to use and redeem gift card(s). Best used as payment option.TOP_UP_GIFTCARD
: A session to sell and/or top up existing gift cards.PAY_PREPAID
: A session to handle prepaid transactions.TOP_UP_PREPAID
: A session to top up prepaid balance.POINTS_TRANSACTION
: A session to handle an order and a subsequent credit reception.VOUCHER
: A session to redeem vouchers.
Initiate a new Portal BaseSession as follows:
<PortalSession
apiKey={apiKey}
shopUuid={shopUuid}
type="PORTAL"
onRedeemVoucher={(voucher) => handleVoucherLogic(voucher)}
/>
Portal BaseSession Props
| Prop | Type | Required | Description |
|-------------------------------|--------------------------------------------------------------|----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| apiKey
| string
| Yes | API key used to authenticate. |
| shopUuid
| string
| Yes | The shop's uuid. |
| contactUuid
| string
| No | Optional contact uuid. This opens the portal session for this contact specifically. |
| type
| PortalType
| No | Optional portal type, defaults to "PORTAL"
. |
| primaryIdentificationMethod
| string
| No | Start the identification flow with either "email"
or "identifier"
, defaults to "identifier"
. |
| cameraService
| number
| No | Specify which camera package to use to scan QR codes. |
| cameraFacingMode
| string
| No | MediaTrackConstraints facingMode. Specifies the default camera if applicable ("user"
(front) or "environment"
(back)), defaults to "user"
. |
| enableEmailIdentification
| boolean
| No | Optional alternative route to identify a contact. |
| enableOnScreenKeyboard
| boolean
| No | Optional on-screen keyboard. |
| allowMultipleGiftcards
| boolean
| No | Allow using multiple giftcards in one session. Applies to sessions with PortalType
"REDEEM_GIFTCARD"
. |
| amountInCents
| number
| No | A purchase amount in cents. Applies to sessions with PortalType
"REDEEM_GIFTCARD"
and "PAY_PREPAID"
. |
| onContactLink
| (contact: ContactResource) => void
| No | Optional callback. Called when a contact is linked to the portal session. |
| onClaimReward
| (reward: RewardResource, transactionUuid?: string) => void
| No | Optional callback. Called when a reward is claimed. |
| onRedeemVoucher
| (voucher: VoucherResource) => void
| No | Optional callback. Called when a voucher is redeemed. |
| onUseGiftcard
| (giftcardTransaction: GiftcardTransactionResource) => void
| No | Optional callback. Called when a giftcard payment is made. |
Types
PortalType
export enum PortalType {
REDEEM_GIFTCARD = "REDEEM_GIFTCARD",
TOP_UP_GIFTCARD = "TOP_UP_GIFTCARD",
PORTAL = "PORTAL",
PAY_PREPAID = "PAY_PREPAID",
TOP_UP_PREPAID = "TOP_UP_PREPAID",
POINTS_TRANSACTION = "POINTS_TRANSACTION",
VOUCHER = "VOUCHER",
}