@flyeralarmdigital/fadc_order v1.0.3
FlyerAlarm @Digital
Npm Order Package
Requires headers "X-CLIENT-KEY". SO to use this services, you must be a valid registered client and have an active client key. YOu shall also be required to hae the scopes to create an order. Most methods will have a client_key parameter where applicable. Here just insert your key and if valid you request will be sent.
If you are going to proxy this request to a backend application instead, for example if you are using a front end application and wnat to keep your client_key secret, then you would send this request to your backend application where you can insert teh client key into the header, then routes where this is applicable will have an API override.
Methods
Countries
Clients may query the order system to get a list of couries and accepted country codes that the order system will accept orders for.
Method:
countries(API = null, set_cache = true, get_cache = true, ttl = 43200)
Order Create
To create and order you sahll send a JSON of "params" to this method. It shall be validated and then will send a request to the order api. Returns the entire order with the order_token.
Requires:
Method:
create(params, client_key = null, API = null)
Example order object
params = {
"reference": '',
"paymentMethod": '',
"merchantAccount": '',
"amount": {
"currency": 'EUR',
"value": '',
},
"shopperLocale": 'de_DE',
"countryCode" : order.country_code,
"telephoneNumber": user.phone,
"shopperIP": user.ip,
"shopperEmail": user.email,
"shopperName": {
"firstName": user.first_name,
"gender": "UNKNOWN",
"lastName": user.last_name
},
"shopperReference": user.user_token,
"billingAddress": {
"city": '',
"country": '',
"houseNumberOrName": '',
"postalCode": '',
"street": '',
},
"deliveryAddress": {
"city": '',
"country": '',
"houseNumberOrName": '',
"postalCode": '',
"street": '',
},
"returnUrl": paymentRedirectTo, //Where shall the user be redirected to after the bank response
"lineItems": []
}
order.items.forEach(item => {
let itemData = {
"quantity": "1",
"amountExcludingTax": '',
"taxPercentage": '',
"description": '',
"id": item.product_id,
"taxAmount": '',
"amountIncludingTax": '',
}
params.lineItems.push(itemData)
})
Get an Order
One may get a single order for a user by sending the requested order_token. THe user will be pulled from the user_access token. THis way a user can not request any order which does not belong to them.
Method:
get(order_token, API = null, false, false, ttl = 43200)
Requires:
Get ALL User orders
One may request all orders for a logged in user simply be execting the below method. THe method will get the logged in user from the cookie and query the DB.
Method:
all( client_key = '', API = null, false, false, ttl = 43200)
Cancel a user Order
TBD