https://github.com/perusworld/node-qkr-api-server
Simple Server to front Mastercard Qkr! APIs
https://github.com/perusworld/node-qkr-api-server
mastercard-qkr nodejs
Last synced: 5 months ago
JSON representation
Simple Server to front Mastercard Qkr! APIs
- Host: GitHub
- URL: https://github.com/perusworld/node-qkr-api-server
- Owner: perusworld
- Created: 2017-06-30T00:26:12.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2023-11-27T21:41:55.000Z (over 2 years ago)
- Last Synced: 2024-04-14T09:59:29.651Z (about 2 years ago)
- Topics: mastercard-qkr, nodejs
- Language: TypeScript
- Size: 433 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Simple Server to front Mastercard Qkr! APIs #
[](https://www.bithound.io/github/perusworld/node-qkr-api-server)
[](https://www.bithound.io/github/perusworld/node-qkr-api-server/master/dependencies/npm)
[](https://www.bithound.io/github/perusworld/node-qkr-api-server)
You could use this to host your backend services that can house calls to Mastercard Qkr! APIs.
If you are looking to call Qkr! APIs directly then head over to [node-qkr-api](https://github.com/perusworld/node-qkr-api)
If you are looking to build a mobile app using the server APIs then head over to [qkr-mobile-app](https://github.com/perusworld/qkr-mobile-app)
You can add your API call authentication logic in [api.ts](./src/api.ts) marked by
```javascript
//TODO: Your API Request Authentication Logic
```
## Demo Video ##
curl,postman calls
---
[](https://youtu.be/Bot4S__zANc)
## Run ##
- Bash
```bash
export QKR_PUBLIC_KEY="---qkr-public-key---"
export QKR_PRIVATE_KEY="---qkr-private-key---"
export QKR_URL="---qkr-sandbox-or-production-url---"
npm run build && npm start
```
- Powershell
```powershell
$env:QKR_PUBLIC_KEY="---qkr-public-key---"
$env:QKR_PRIVATE_KEY="---qkr-private-key---"
$env:QKR_URL="---qkr-sandbox-or-production-url---"
npm run build ; npm start
```
-Heroku
```bash
heroku create yourappserver
heroku config:set NPM_CONFIG_PRODUCTION=false
heroku config:set QKR_PUBLIC_KEY="---qkr-public-key---"
heroku config:set QKR_PRIVATE_KEY="---qkr-private-key---"
heroku config:set QKR_URL="---qkr-sandbox-or-production-url---"
git push heroku master
```
### Enabling simple API Key based authentication ###
- Bash
```bash
export QKR_PUBLIC_KEY="---qkr-public-key---"
export QKR_PRIVATE_KEY="---qkr-private-key---"
export QKR_URL="---qkr-sandbox-or-production-url---"
export API_KEY_ENABLED="true"
export API_KEY_SOURCE="request"
export API_KEY_NAME="yourKeyName"
export API_KEY_VALUE="yourKeyValue"
npm run build && npm start
```
- Powershell
```powershell
$env:QKR_PUBLIC_KEY="---qkr-public-key---"
$env:QKR_PRIVATE_KEY="---qkr-private-key---"
$env:QKR_URL="---qkr-sandbox-or-production-url---"
$env:API_KEY_ENABLED="true"
$env:API_KEY_SOURCE="request"
$env:API_KEY_NAME="yourKeyName"
$env:API_KEY_VALUE="yourKeyValue"
npm run build ; npm start
```
-Heroku
```bash
heroku create yourappserver
heroku config:set NPM_CONFIG_PRODUCTION=false
heroku config:set QKR_PUBLIC_KEY="---qkr-public-key---"
heroku config:set QKR_PRIVATE_KEY="---qkr-private-key---"
heroku config:set QKR_URL="---qkr-sandbox-or-production-url---"
heroku config:set API_KEY_ENABLED="true"
heroku config:set API_KEY_SOURCE="request"
heroku config:set API_KEY_NAME="yourKeyName"
heroku config:set API_KEY_VALUE="yourKeyValue"
git push heroku master
```
## Test Calls (the [test](./test) folder contains sample test calls as well) ##
### There is also a postman collection of calls that you can directly import from [node-qkr-api-server sample postman calls collection](./node-qkr-api-server.postman_collection.json) ###
### Lightbox ###
```bash
curl --request POST \
--url http://localhost:3000/api/v1/lightbox \
--header 'cache-control: no-cache' \
--header 'content-type: application/json' \
--data '{"countryOfResidence":"US","callbackUrl":"myapp://lightbox"}'
```
### Login ###
```bash
curl --request POST \
--url http://localhost:3000/api/v1/login \
--header 'cache-control: no-cache' \
--header 'content-type: application/json' \
--data '{"email":"someemail@somedomain.com","pwd":"somepassword99"}'
```
### Merchant List ###
```bash
curl --request POST \
--url http://localhost:3000/api/v1/merchant/list \
--header 'cache-control: no-cache'
```
### Product List ###
```bash
curl --request POST \
--url http://localhost:3000/api/v1/product/list \
--header 'cache-control: no-cache' \
--header 'content-type: application/json' \
--data '{"id":"155952"}'
```
### Cart Add ###
```bash
curl --request POST \
--url http://localhost:3000/api/v1/cart/add \
--header 'cache-control: no-cache' \
--header 'content-type: application/json' \
--data '{"token": "logintoken","request":{"locatedScanId": "155955","outletId": "155942","purchaseNote": "Some note","quantity": 1,"variantId": "155954"}}'
```
### Card List ###
```bash
curl --request POST \
--url http://localhost:3000/api/v1/card/list \
--header 'cache-control: no-cache' \
--header 'content-type: application/json' \
--data '{"token": "logintoken"}'
```
### Cart List ###
```bash
curl --request POST \
--url http://localhost:3000/api/v1/cart/list \
--header 'cache-control: no-cache' \
--header 'content-type: application/json' \
--data '{"token": "logintoken"}'
```
### Cart Checkout ###
```bash
curl --request POST \
--url http://localhost:3000/api/v1/cart/checkout \
--header 'cache-control: no-cache' \
--header 'content-type: application/json' \
--data '{"token": "logintoken","request":{"amountMinorUnits": "200","cardId": "1","cartId": "1","tipAmount": 0}}'
```
### Address List ###
```bash
curl --request POST \
--url http://localhost:3000/api/v1/address/list \
--header 'cache-control: no-cache' \
--header 'content-type: application/json' \
--data '{"token": "logintoken"}'
```
### Address Add ###
```bash
curl --request POST \
--url http://localhost:3000/api/v1/address/add \
--header 'cache-control: no-cache' \
--header 'content-type: application/json' \
--data '{"token": "---your-auth-token---","request":{"city": "San Carlos","country": "US","line1": "Mastercard","line2": "959 Skyway Rd","zip": "94070","state": "CA","alias": "somealias","isDefault": "false","recipientName": "John Doe","recipientPhone":"--your-optional-phone-number--","recipientPhoneCountryCode":"1"}}'
```
### Address Delete ###
```bash
curl --request DELETE \
--url http://localhost:3000/api/v1/address/delete \
--header 'cache-control: no-cache' \
--header 'content-type: application/json' \
--data '{"token": "logintoken", "id": "---address-id---"}'
```
### Express Checkout ###
```diff
- Make sure the partnerTxId is unique per call
```
```bash
curl --request POST \
--url http://localhost:3000/api/v1/express/checkout \
--header 'cache-control: no-cache' \
--header 'content-type: application/json' \
--data '{"token": "---your-auth-token---","request":{"amount": "200","cardId": "c0b37d63-4c2b-4677-a956-522761914ee1","description": "some description","outletId":"155942","partnerTxId": "some tx id"}}'
```
### User Profile ###
```bash
curl --request POST \
--url http://localhost:3000/api/v1/profile \
--header 'cache-control: no-cache' \
--header 'content-type: application/json' \
--data '{"token": "---your-auth-token---","id":"---internalAccountId-from-authresponse---"}'
```