payment-backoffice-api v1.15.0
payment-backoffice-api 
This project acts like an authentication proxy. Each route will call the desired API.
For payload and params validation, please refer to specific API documentation.
versions
v0.5.0
requirements
- node.js
- postgres
Developers will probably need to run docker
environment variables
The project needs some environment variables to run properly.
In development mode, you can use a .env file to define them.
ACCOUNTING_API_URL: accounting api urlACCOUNTING_API_SHARED_KEY: accounting api shared key without ending slashAUTH_HEADER_KEY=oyst-authorizationAUTH_HEADER_PREFIX=OystBO_PAY_FRONT_URL: url of payment-backoffice-frontDATABASE_URL: Databse connection stringMAIL_FROM_ADDR="no-reply@oyst.com"MAIL_FROM_ALIAS="OYST Validator"MAIL_SUPPORT_TO: email address to which the support message will be sentMAIL_VALIDATION_TO: email address to which the validation email will be sentMERCHANT_API_SHARED_KEY: Shared key for merchant-apiMERCHANT_API_URL: Merchant's API endpointPAYMENT_API_URL: Payment's API endpointPAYMENT_API_SHARED_KEY: Shared key for payment-apiSENDGRID_API_KEY: API key for sendgridSHARED_KEY: Shared encryption key used to sign and verify JsonWebTokenSWAGGER_HOST(optional): define the URL used by Swagger to test APIs. eg:localhost:8080USER_API_URL: User API endpoint
install
$ npm installrun the project
In development mode, be sure docker is running postgres:
$ docker-compose up -dThen, in development mode:
$ $(npm bin)/gulp serveOr, in production mode:
$ $(npm bin)/npm run startroutes
Auth protected routes
If a route needs authentication, you have to provide an auth header
AUTH_HEADER_KEY: AUTH_HEADER_PREFIX jwt_token
Signup
POST /usersneeds auth:
FALSEpayload
Joi.object({ email: Joi.string().email().required(), password: Joi.string().min(8).max(20).required(), password_confirmation: Joi.any() .valid(Joi.ref('password')) .required().options({language: {any: {allowOnly: 'must match password'}}}) .strip(), phone: phoneValidator.phone().mobile().required() })- return
{ "token": "JWT token used for authentication", "user": { "created_at": "", "email": "", "id": "", "merchants": ["merchantID"], "phone": "", "scopes": ["USER"], "updated_at": "" } }
Signin
POST /sessionsneeds auth:
FALSEpayload
Joi.object({ email: Joi.string().email().required(), password: Joi.string().required() })- return
{ "token": "JWT token used for authentication", "merchant": {}, "user": { "created_at": "", "email": "", "id": "", "merchants": ["merchantID"], "phone": "", "scopes": ["USER"], "updated_at": "" } }
Check if user is authenticated
GET /sessions/{token}needs auth:
TRUEreturn
404Bad token401Not authenticated200authenticated{ "token": "JWT token used for authentication", "user": { "created_at": "", "email": "", "id": "", "merchants": ["merchantID"], "phone": "", "scopes": ["USER"], "updated_at": "" } }
Update user infos
PUT /users/{id}- needs auth:
TRUE - payload:
Joi.object().keys({ email: Joi.string().email(), password: Joi.string().min(8), password_confirmation: Joi.any() .valid(Joi.ref('password')) .required().options({language: {any: {allowOnly: 'must match password'}}}) .strip().optional(), phone: phoneValidator.phone().mobile() }).or( 'email', 'password', 'password_confirmation', 'phone' )- return
{ "statusCode": 200, "success": true, "user": { "created_at": "", "email": "", "id": "", "merchants": ["merchantID"], "phone": "", "scopes": ["USER"], "updated_at": "" } }- needs auth:
Support
POST /support/mail- needs auth:
FALSE - payload:
Joi.object({ email: Joi.string().email().required(), message: Joi.string().required(), subject: Joi.string().required() })- return
{ "statusCode": 200, "success": true }- needs auth:
Change password
PATCH /users/password- needs auth:
TRUE - payload:
Joi.object({ current: Joi.string().min(8).max(20).required(), password: Joi.string().min(8).max(20).required(), password_confirmation: Joi.any() .valid(Joi.ref('password')) .required().options({language: {any: {allowOnly: 'must match password'}}}) .strip() })- return
{ "statusCode": 200, "success": true }- needs auth:
Forgot password
Step 1
POST /users/password/forgot- needs auth:
FALSE - payload:
Joi.object({ email: Joi.string().email().required() })- return
{ "statusCode": 200, "success": true }- needs auth:
Step 2
GET /users/password/checkToken- needs auth:
FALSE - querystring:
Joi.object({ id: Joi.string().guid().required(), token: jwt.required() })- return
{ "statusCode": 200, "success": true }- needs auth:
Step 3
PATCH /users/password/new- needs auth:
FALSE - payload:
Joi.object({ password: Joi.string().min(8).max(20).required(), password_confirmation: Joi.any() .valid(Joi.ref('password')) .required().options({language: {any: {allowOnly: 'must match password'}}}) .strip() })- querystring:
Joi.object({ id: Joi.string().guid().required(), token: jwt.required() })- return
{ "token": "JWT token used for authentication", "user": { "created_at": "", "email": "", "id": "", "merchants": ["merchantID"], "phone": "", "scopes": ["USER"], "updated_at": "" } }- needs auth:
Merchant-API calls
GET /merchants/{id}/activate/{token}
Activate a merchant using link provided by email (OYST side)
needs auth:
FALSEparams
{ id: Joi.string().guid().required(), token: jwt.required() }remote endpoint:
PATCH /merchants/{id}/activate
GET /merchants/{id}/deactivate/{token}
Deactivate a merchant using link provided by email (OYST side)
needs auth:
FALSEparams
{ id: Joi.string().guid().required(), token: jwt.required() }remote endpoint:
PATCH /merchants/{id}/deactivate
POST /merchants
Create a merchant
needs auth:
TRUE
GET /merchants
Get merchant's informations based on logged in user's merchantID
needs auth:
TRUEremote endpoint:
GET /merchants/{id}
PUT /merchants
Update merchant's informations based on logged in user's merchantID
needs auth:
TRUEremote endpoint:
PUT /merchants/{id}
PUT /merchants/upload/{type}
Upload merchant's CGV/logo based on logged in user's merchantID
needs auth:
TRUEparams
{ type: Joi.string().valid([ 'cgv', 'logo' ]) }remote endpoint:
PUT /merchants/{id}/upload/{type}
Payment-API calls
GET /payments
Get all transactions with pagination based on logged in user's merchantID
needs auth:
TRUEquery params
{ page: Joi.number().integer().min(1).default(1), per_page: Joi.number().integer().max(100).default(10) }remote endpoint:
GET /merchants/{merchant_id}/payments
POST /payments/{id}/cancel
Cancel desired transaction based on logged in user's merchantID
needs auth:
TRUEremote endpoint:
POST /merchants/{merchant_id}/payments/{id}/cancel
POST /payments/{id}/refund
Refund desired transaction based on logged in user's merchantID
needs auth:
TRUEremote endpoint:
POST /merchants/{merchant_id}/payments/{id}/refund
GET /payments/{id}
Get desired transaction based on logged in user's merchantID
needs auth:
TRUEremote endpoint: **/!\ Not yet implemented /!**
GET /payments/overview
Get overview for transactions based on logged in user's merchantID
needs auth:
TRUEremote endpoint:
/merchants/{merchant_id}/payments/overview
Accounting-API calls
GET /accounting/overview
Get merchant's account's overview based on logged in user's merchantID
needs auth:
TRUEremote endpoint:
/merchants/${merchant_id}/payments/overview
Payout calls
POST /payouts
Create new payout
needs auth:
TRUEremote endpoint:
POST /merchants/{merchant_id}/payouts/submit
GET /payouts
Get all payouts from current logged in merchant
needs auth:
TRUEremote endpoint:
GET /merchants/{merchant_id}/payouts
Changelog
v0.8.0
- Feature get all payouts from merchant
- New route
- GET /payouts
- Update README
- New tests
- Update to v0.8.0
v0.7.0
- Feature change result from merchant's activation
- Return
ValidatedorRefused
v0.6.0
- Feature create payout
- New class Payout
- New route POST /payouts
- New tests
- Update README
- Update to v0.6.0
- Feature create payout
v0.5.0
- Return also merchant infos on check token
- GET /sessions/token
- Return also merchant infos on check token
v0.4.1
- Fix bug on login when no merchant created
v0.4.0
- Returns merchant's infos on login
- Force https on activate/deactivate routes
8 years ago