Please make sure you read the Conventions before continuing with this guide.
Requirements.
You will need an X-API-KEY for all steps.
Login with a customer.
You will interact with the /accounts/customers endpoint of the Accounts Bucket
.
This step will require an additional header, Authorization
, which will be assigned the value of Basic
appended with {{customerNumber}}:{{customer-password}} encoded in base64.
If you want to use the email you replace the customerNumber with the email {{email}}:{{customer-password}} encoded in base64. You need to make sure the customer has loginByEmail enable to be able to login this way.
echo -n "user@btrz.com:secret1" | base64
// dXNlckBidHJ6LmNvbTpzZWNyZXQx
We will call it base64-encoded-username-and-pwd
.
Ie. 'Basic dXNlckBidHJ6LmNvbTpzZWNyZXQx'
When successful, a json customer and provider object as well as tokens will be returned.
Response :
{
"customer": {
"_id": "5a466f555555df550b555555",
"customerNumber": "123-123-123",
"accountId": "55555xx55yy55z000000000",
"agencyId": "",
"firstName": "Firstname-Test",
"lastName": "Lastname-Test",
"email": "test@betterez.com",
"phone": "",
"street": "",
"city": "",
"countryId": "",
"country": "",
"province": "",
"zip": "",
"activeCustomerAccount": true,
"cloutCategory": "Newbie",
"clout": {
"p0000_00": {
"purchases": 0,
"travels": 0,
"purchasesValue": 0,
"travelsValue": 0
}
},
"deleted": false,
"optIn": false,
"createdAt": {
"value": "2017-11-29T16:38:08.533Z",
"offset": 0
},
"updatedAt": {
"value": "2017-11-29T16:38:08.533Z",
"offset": 0
},
"mergedFrom": [],
"mergedTo": "",
"emailAndPwdLoginConfigured": true,
"emailAndPwdLoginActive": true,
"mustResetPassword": false
},
"provider": {
"_id": "55555xx55yy55z000000000",
"preferences": {
"commIdentity": [
{
"name": "Betterez",
"email": "info@betterez.com",
"verified": true,
"active": true
}
],
"dateFormat": "mm/dd/yyyy",
"lexicon": "buscompany",
"manifest": {
"brakePageOnNewLeg": false,
"showWalkOnFields": false
},
"network": {
"isSeller": true,
"searchableSeller": true,
"isOperator": false,
"searchableOperator": false
},
"optionalShowFields": {
"commentsPerPax": false,
"commentsPerPaxAgency": false,
"commentsPerPaxWidget": false,
"airlineInfoIfAirport": false
},
"paymentProviders": {
"cash": {
"provider": "inperson",
"params": {},
"appliesOnlyWhenLoggedIn": true,
"ord": 100,
"_id": "1",
"enabled": true,
"hasRefund": true,
"refundPriority": 0,
"requireConfirmation": false,
"externalSource": false,
"requireAddress": false,
"displayName": "cash",
"includeInDepositTotals": false,
"custom": false,
"method": "cash",
"flow": "standard",
"channels": {
"backoffice": {
"available": true
},
"agency-backoffice": {
"available": true
},
"websales": {
"available": false
},
"agency-websales": {
"available": false
}
},
"requireAddressBackoffice": false,
"requireAddressWebsales": false
},
"debit": {
"provider": "inperson",
"params": {},
"appliesOnlyWhenLoggedIn": true,
"ord": 200,
"_id": "2",
"enabled": true,
"hasRefund": true,
"refundPriority": 0,
"requireConfirmation": false,
"externalSource": false,
"requireAddress": false,
"displayName": "debit",
"includeInDepositTotals": false,
"custom": false,
"method": "debit",
"flow": "standard",
"channels": {
"backoffice": {
"available": true
},
"agency-backoffice": {
"available": true
},
"websales": {
"available": false
},
"agency-websales": {
"available": false
}
},
"requireAddressBackoffice": false,
"requireAddressWebsales": false
},
"credit": {
"provider": "inperson",
"params": {},
"appliesOnlyWhenLoggedIn": true,
"ord": 300,
"_id": "3",
"enabled": true,
"hasRefund": true,
"refundPriority": 0,
"requireConfirmation": false,
"externalSource": false,
"requireAddress": false,
"displayName": "credit",
"includeInDepositTotals": false,
"custom": false,
"creditCards": {
"visa": true,
"mastercard": true,
"amex": true
},
"method": "credit",
"flow": "standard",
"channels": {
"backoffice": {
"available": true
},
"agency-backoffice": {
"available": true
},
"websales": {
"available": false
},
"agency-websales": {
"available": false
}
},
"requireAddressBackoffice": false,
"requireAddressWebsales": false
}
},
"rounding": {
"policy": "default",
"decimals": "2"
},
"sales": {
"enableArbitraryRefunds": null,
"allowReissueToAPastDate": null,
"noTripsCustomMessage": "",
"quickView": "true",
"passbook": false,
"optionalEmailAddress": false,
"mobileSales": false
},
"scanningWorkflow": "simple",
"shortUrls": {
"widget": {
"longUrl": "",
"shortUrl": ""
},
"fullPage": {
"longUrl": "",
"shortUrl": ""
}
},
"timeFormat": "h:MM TT",
"timeZone": {
"name": "(UTC-5:00) New York (United States), Toronto (Canada)",
"daylight": true,
"tz": "America/Toronto"
},
"workflow": "route",
"customerAccounts": {
"enabled": false,
"customerPhone": false,
"optIn": false,
"optInMessage": ""
},
"colors": {
"mainBackground": "#FFFFFF",
"mainForeground": "#404040",
"brandBackground": "#4B986D",
"brandForeground": "#FFFFFF",
"complementaryBackground": "#F5F5F5",
"complementaryForeground": "#404040"
},
"connex": {
"enabled": false,
"maxWaitingTime": 240,
"minWaitingTime": 0,
"cache": {
"useCache": false,
"advancedCacheOnSameDay": true,
"numberOfEntryUsage": 100,
"numberOfDaysUsage": 7
},
"filter": {
"enabled": false,
"minutes": 0,
"percentage": 0
},
"version": 2,
"maxConnexWithDirectTrips": 0
},
"bookingSession": 180,
"pdfTicket": {
"tripName": null,
"autoPrint": false,
"custom": false,
"customPrinterModel": ""
},
"wl": {
"schema": ""
},
"hasWlSchema": false,
"validations": {
"validateTripScan": false,
"validateDateScan": false,
"validateOandDScan": false,
"validateFareScan": false,
"scanFaresValidations": {}
},
"receiptFields": {
"header": {
"label": "Receipt header",
"content": "",
"order": 0
},
"footer": {
"label": "Receipt footer",
"content": "",
"order": 1
}
},
"applications": [
"sales"
],
"support": {
"url": "http://support.betterez.com",
"noAccess": false
},
"vouchers": {
"enabledForAll": true,
"toc": "",
"instructions": "",
"products": {}
},
"reports": {
"exportAllAsEmail": false
},
"supportedCurrencies": [
{
"isocode": "USD",
"symbol": "$"
}
],
"newLayout": false,
"scanningSyncInterval": 0,
"expandedDownloadDateRange": false,
"acceptTicketsOnCheaperTrips": false,
"crossProductRedemption": false,
"useInventorySearch": false,
"reverseScanningForTickets": false,
"languages": {
"en": true,
"fr": true
},
"google": {
"analytics": ""
},
"scanningMode": "online",
"measuresSystem": "metric"
}
},
"token": "token_string",
"shortToken": "short_token_string"
}
Notes
Now that a customer has been created and successfully logged in, you can use the "shortToken" value returned in the response from Step 5 to call other endpoints that the customer is authorized to access.
For example, to call the operations/transactions
endpoint, you would add a querystring parameter with the customer number:
https://api.betterez.com/operations/transactions/?customer=123-123-123
In the headers, you would provide the x-api-key in addition to a new Authorization header, similar to the one provided before, 'authorization: Bearer {{jwt-short-token}}'.