Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

7653 Send staff payment data #389

Merged
merged 2 commits into from
May 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "name-request",
"version": "2.2.3",
"version": "2.2.4",
"private": true,
"appName": "Name Request UI",
"sbcName": "SBC Common Components",
Expand Down
43 changes: 35 additions & 8 deletions src/mixins/payment-mixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import { AxiosRequestConfig } from 'axios'
import { ACCEPTED, CREATED, NO_CONTENT, OK } from 'http-status-codes'

import { SessionStorageKeys } from 'sbc-common-components/src/util/constants'
import { PaymentStatus } from '@/enums'
import { PaymentStatus, StaffPaymentOptions } from '@/enums'
import { ActionMixin } from '@/mixins'
import * as paymentTypes from '@/modules/payment/store/types'
import { CreatePaymentParams, NameRequestPaymentResponse } from '@/modules/payment/models'
import errorModule from '@/modules/error'
import { ErrorI } from '@/modules/error/store/actions'
import { StaffPaymentIF } from '@/interfaces'
import { ActionBindingIF } from '@/interfaces/store-interfaces'
import NamexServices from '@/services/namex.services'

Expand All @@ -25,6 +26,7 @@ export class PaymentMixin extends Mixins(ActionMixin) {

// Global getter
@Getter getCurrentJsDate!: Date
@Getter getStaffPayment!: StaffPaymentIF

get sbcPayment () {
return this.$store.getters[paymentTypes.GET_SBC_PAYMENT]
Expand Down Expand Up @@ -148,14 +150,14 @@ export class PaymentMixin extends Mixins(ActionMixin) {
}
const token = sessionStorage.getItem(SessionStorageKeys.KeyCloakToken)
const accountInfo = sessionStorage.getItem(SessionStorageKeys.CurrentAccount)
let headers = {}
if (token && accountInfo) {
let headers = this.buildStaffPayment()
if (token) {
headers['Authorization'] = `Bearer ${token}`
headers['Content-Type'] = 'application/json'
}
if (accountInfo) {
const parsedAccountInfo = JSON.parse(accountInfo)
headers = {
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json',
'Account-Id': parsedAccountInfo.id
}
headers['Account-Id'] = parsedAccountInfo.id
}
req.headers = headers
try {
Expand Down Expand Up @@ -189,6 +191,31 @@ export class PaymentMixin extends Mixins(ActionMixin) {
}
}

/** Build Staff Payment data. **/
buildStaffPayment () {
// Populate Staff Payment according to payment option
let headers = {}
switch (this.getStaffPayment.option) {
case StaffPaymentOptions.FAS:
headers['routingSlipNumber'] = this.getStaffPayment.routingSlipNumber
break

case StaffPaymentOptions.BCOL:
headers['bcolAccountNumber'] = this.getStaffPayment.bcolAccountNumber
headers['datNumber'] = this.getStaffPayment.datNumber
headers['folioNumber'] = this.getStaffPayment.folioNumber // this overrides original folio number
break

case StaffPaymentOptions.NO_FEE:
headers['waiveFees'] = true
break

case StaffPaymentOptions.NONE: // should never happen
break
}
return headers
}

/**
* Redirect user to Service BC Pay Portal.
* Set the redirect URL to specify OUR payment ID so we can
Expand Down