@oneblink/apps-react 13.5.1-beta.3 → 14.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/apps/approvals-service.d.ts +13 -1
- package/dist/apps/approvals-service.js +22 -1
- package/dist/apps/approvals-service.js.map +1 -1
- package/dist/apps/payment-service.d.ts +22 -0
- package/dist/apps/payment-service.js +43 -0
- package/dist/apps/payment-service.js.map +1 -1
- package/dist/apps/services/api/payment.d.ts +5 -1
- package/dist/apps/services/api/payment.js.map +1 -1
- package/dist/apps/services/fetch.d.ts +3 -1
- package/dist/apps/services/fetch.js +16 -4
- package/dist/apps/services/fetch.js.map +1 -1
- package/dist/apps/services/payment-handoff.d.ts +47 -0
- package/dist/apps/services/payment-handoff.js +79 -0
- package/dist/apps/services/payment-handoff.js.map +1 -0
- package/dist/apps/services/payment-providers/WestpacQuickStreamPaymentProvider.d.ts +35 -19
- package/dist/apps/services/payment-providers/WestpacQuickStreamPaymentProvider.js +41 -27
- package/dist/apps/services/payment-providers/WestpacQuickStreamPaymentProvider.js.map +1 -1
- package/dist/apps/submission-service.js +2 -1
- package/dist/apps/submission-service.js.map +1 -1
- package/dist/components/payments/PaymentForm.d.ts +11 -6
- package/dist/components/payments/PaymentForm.js +10 -17
- package/dist/components/payments/PaymentForm.js.map +1 -1
- package/dist/components/payments/WestpacQuickStreamPaymentForm.d.ts +7 -11
- package/dist/components/payments/WestpacQuickStreamPaymentForm.js +25 -31
- package/dist/components/payments/WestpacQuickStreamPaymentForm.js.map +1 -1
- package/dist/services/form-validation/getApproverEditableFormElementIds.js +3 -0
- package/dist/services/form-validation/getApproverEditableFormElementIds.js.map +1 -1
- package/dist/services/getFlowInstanceNodesWithMeta.js +22 -3
- package/dist/services/getFlowInstanceNodesWithMeta.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SubmissionTypes, ApprovalTypes, FormTypes } from '@oneblink/types';
|
|
1
|
+
import { SubmissionTypes, ApprovalTypes, FormTypes, SubmissionEventTypes } from '@oneblink/types';
|
|
2
2
|
export { getFlowInstanceNodesWithMeta } from '../services/getFlowInstanceNodesWithMeta';
|
|
3
3
|
export type FormSubmissionApprovalsResponse = {
|
|
4
4
|
approvals: Array<{
|
|
@@ -14,6 +14,7 @@ export type FormApprovalFlowInstanceHistory = {
|
|
|
14
14
|
formSubmissionMetaEdits: SubmissionTypes.FormSubmissionMetaEdit[];
|
|
15
15
|
formSubmissionApprovals: ApprovalTypes.FormSubmissionApproval[];
|
|
16
16
|
successfulFormSubmissionPayment?: SubmissionTypes.FormSubmissionPayment;
|
|
17
|
+
formSubmissionPayments?: SubmissionTypes.FormSubmissionPayment[];
|
|
17
18
|
};
|
|
18
19
|
export type FormSubmissionApprovalResponse = {
|
|
19
20
|
formSubmissionMeta: SubmissionTypes.FormSubmissionMeta;
|
|
@@ -105,6 +106,17 @@ export declare function getFormSubmissionApproval(formSubmissionApprovalId: stri
|
|
|
105
106
|
* @param abortSignal
|
|
106
107
|
* @returns
|
|
107
108
|
*/
|
|
109
|
+
export declare const PAYMENT_IN_PROGRESS_CONFLICT = "PAYMENT_IN_PROGRESS";
|
|
110
|
+
export declare function createApprovalStepPayment(formSubmissionApprovalId: string, body: {
|
|
111
|
+
redirectUrl: string;
|
|
112
|
+
paymentFormUrl?: string;
|
|
113
|
+
}, abortSignal?: AbortSignal): Promise<{
|
|
114
|
+
hostedFormUrl: string;
|
|
115
|
+
amount: number;
|
|
116
|
+
paymentSubmissionEvent: SubmissionEventTypes.FormPaymentEvent;
|
|
117
|
+
customerReferenceNumber?: string;
|
|
118
|
+
}>;
|
|
119
|
+
export declare function skipApprovalStepPayment(formSubmissionApprovalId: string, abortSignal?: AbortSignal): Promise<ApprovalTypes.FormSubmissionApproval>;
|
|
108
120
|
export declare function updateFormSubmissionApproval(formSubmissionApproval: ApprovalTypes.FormSubmissionApproval, abortSignal?: AbortSignal): Promise<ApprovalTypes.FormSubmissionApproval>;
|
|
109
121
|
/**
|
|
110
122
|
* @deprecated Use "reopenFormApprovalFlowInstance()" instead
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import OneBlinkAppsError from './services/errors/oneBlinkAppsError';
|
|
2
2
|
import { isOffline } from './offline-service';
|
|
3
|
-
import { deleteRequest, getRequest, putRequest, searchRequest, postRequest, } from './services/fetch';
|
|
3
|
+
import { deleteRequest, getRequest, putRequest, searchRequest, postRequest, HTTPError, } from './services/fetch';
|
|
4
4
|
import tenants from './tenants';
|
|
5
5
|
import Sentry from './Sentry';
|
|
6
6
|
export { getFlowInstanceNodesWithMeta } from '../services/getFlowInstanceNodesWithMeta';
|
|
@@ -165,6 +165,27 @@ export async function getFormSubmissionApproval(formSubmissionApprovalId, abortS
|
|
|
165
165
|
* @param abortSignal
|
|
166
166
|
* @returns
|
|
167
167
|
*/
|
|
168
|
+
export const PAYMENT_IN_PROGRESS_CONFLICT = 'PAYMENT_IN_PROGRESS';
|
|
169
|
+
export async function createApprovalStepPayment(formSubmissionApprovalId, body, abortSignal) {
|
|
170
|
+
try {
|
|
171
|
+
return await postRequest(`${tenants.current.apiOrigin}/form-submission-approvals/${formSubmissionApprovalId}/payment`, body, abortSignal);
|
|
172
|
+
}
|
|
173
|
+
catch (error) {
|
|
174
|
+
if (error instanceof HTTPError &&
|
|
175
|
+
error.status === 409 &&
|
|
176
|
+
error.conflict === PAYMENT_IN_PROGRESS_CONFLICT) {
|
|
177
|
+
throw new OneBlinkAppsError('A payment is already in progress for this step. Finish or cancel that payment before starting another.', {
|
|
178
|
+
httpStatusCode: error.status,
|
|
179
|
+
conflict: PAYMENT_IN_PROGRESS_CONFLICT,
|
|
180
|
+
originalError: error,
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
throw error;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
export async function skipApprovalStepPayment(formSubmissionApprovalId, abortSignal) {
|
|
187
|
+
return await postRequest(`${tenants.current.apiOrigin}/form-submission-approvals/${formSubmissionApprovalId}/skip-payment`, {}, abortSignal);
|
|
188
|
+
}
|
|
168
189
|
export async function updateFormSubmissionApproval(formSubmissionApproval, abortSignal) {
|
|
169
190
|
try {
|
|
170
191
|
return await putRequest(`${tenants.current.apiOrigin}/form-submission-approvals/${formSubmissionApproval.id}`, formSubmissionApproval, abortSignal);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"approvals-service.js","sourceRoot":"","sources":["../../src/apps/approvals-service.ts"],"names":[],"mappings":"AACA,OAAO,iBAAiB,MAAM,qCAAqC,CAAA;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EACL,aAAa,EACb,UAAU,EACV,UAAU,EACV,aAAa,EACb,WAAW,GAEZ,MAAM,kBAAkB,CAAA;AACzB,OAAO,OAAO,MAAM,WAAW,CAAA;AAC/B,OAAO,MAAM,MAAM,UAAU,CAAA;AAC7B,OAAO,EAAE,4BAA4B,EAAE,MAAM,0CAA0C,CAAA;AA2CvF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC9C,UAAkB,EAClB,WAAyB;IAEzB,IAAI,CAAC;QACH,OAAO,MAAM,UAAU,CACrB,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,eAAe,UAAU,eAAe,EACpE,WAAW,CACZ,CAAA;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAA;QAC5B,OAAO,CAAC,KAAK,CAAC,4CAA4C,EAAE,GAAG,CAAC,CAAA;QAChE,MAAM,KAAK,GAAG,GAAgB,CAAA;QAC9B,IAAI,SAAS,EAAE,EAAE,CAAC;YAChB,MAAM,IAAI,iBAAiB,CACzB,4HAA4H,EAC5H;gBACE,aAAa,EAAE,KAAK;gBACpB,SAAS,EAAE,IAAI;aAChB,CACF,CAAA;QACH,CAAC;QACD,QA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;YACH,CAAC;YACD,KAAK,GAAG,CAAC;YACT,KAAK,GAAG,CAAC,CAAC,CAAC;gBACT,MAAM,IAAI,iBAAiB,CAAC,KAAK,CAAC,OAAO,EAAE;oBACzC,KAAK,EAAE,iBAAiB;oBACxB,cAAc,EAAE,KAAK,CAAC,MAAM;iBAC7B,CAAC,CAAA;YACJ,CAAC;YACD,OAAO,CAAC,CAAC,CAAC;gBACR,MAAM,IAAI,iBAAiB,CACzB,gFAAgF,EAChF;oBACE,aAAa,EAAE,KAAK;oBACpB,cAAc,EAAE,KAAK,CAAC,MAAM;iBAC7B,CACF,CAAA;YACH,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import { SubmissionTypes, ApprovalTypes, FormTypes } from '@oneblink/types'\nimport OneBlinkAppsError from './services/errors/oneBlinkAppsError'\nimport { isOffline } from './offline-service'\nimport {\n deleteRequest,\n getRequest,\n putRequest,\n searchRequest,\n postRequest,\n HTTPError,\n} from './services/fetch'\nimport tenants from './tenants'\nimport Sentry from './Sentry'\nexport { getFlowInstanceNodesWithMeta } from '../services/getFlowInstanceNodesWithMeta'\n\nexport type FormSubmissionApprovalsResponse = {\n approvals: Array<{\n formSubmissionApproval: ApprovalTypes.FormSubmissionApproval\n formApprovalFlowInstance: ApprovalTypes.FormApprovalFlowInstance\n formSubmissionMeta: SubmissionTypes.FormSubmissionMeta\n latestSuccessfulFormSubmissionPayment:\n | SubmissionTypes.FormSubmissionPayment\n | undefined\n }>\n}\n\nexport type FormApprovalFlowInstanceHistory = {\n formApprovalFlowInstance: ApprovalTypes.FormApprovalFlowInstance\n formSubmissionMeta: SubmissionTypes.FormSubmissionMeta\n formSubmissionMetaEdits: SubmissionTypes.FormSubmissionMetaEdit[]\n formSubmissionApprovals: ApprovalTypes.FormSubmissionApproval[]\n successfulFormSubmissionPayment?: SubmissionTypes.FormSubmissionPayment\n}\n\nexport type FormSubmissionApprovalResponse = {\n formSubmissionMeta: SubmissionTypes.FormSubmissionMeta\n formApprovalFlowInstance: ApprovalTypes.FormApprovalFlowInstance\n formSubmissionApproval: ApprovalTypes.FormSubmissionApproval\n form: FormTypes.Form\n successfulFormSubmissionPayment?: SubmissionTypes.FormSubmissionPayment\n history: FormApprovalFlowInstanceHistory[]\n}\n\nexport type FormSubmissionsAdministrationApprovalsResponse = {\n approvals: Array<\n FormApprovalFlowInstanceHistory & {\n history: Array<FormApprovalFlowInstanceHistory>\n }\n >\n meta: {\n limit: number\n offset: number\n nextOffset?: number\n }\n}\n\n/**\n * Get an Object containing FormSubmissionApprovals assigned to the current user\n * and the Form definitions in those approvals.\n *\n * #### Example\n *\n * ```js\n * const formsAppId = 1\n * const {\n * formSubmissionApprovals,\n * formApprovalFlowInstances,\n * forms,\n * formSubmissionMeta,\n * } = await approvalsService.getFormSubmissionApprovals(formAppId)\n * ```\n *\n * @param formsAppId\n * @param abortSignal\n * @returns\n */\nexport async function getFormSubmissionApprovals(\n formsAppId: number,\n abortSignal?: AbortSignal,\n): Promise<FormSubmissionApprovalsResponse> {\n try {\n return await getRequest<FormSubmissionApprovalsResponse>(\n `${tenants.current.apiOrigin}/forms-apps/${formsAppId}/my-approvals`,\n abortSignal,\n )\n } catch (err) {\n Sentry.captureException(err)\n console.error('Error retrieving form submission approvals', err)\n const error = err as HTTPError\n if (isOffline()) {\n throw new OneBlinkAppsError(\n 'You are currently offline and do not have a local copy of this app available, please connect to the internet and try again',\n {\n originalError: error,\n isOffline: true,\n },\n )\n }\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot view your pending approvals without first logging in. Please login and try again.',\n {\n originalError: error,\n requiresLogin: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access to this application. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n requiresAccessRequest: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 400:\n case 404: {\n throw new OneBlinkAppsError(error.message, {\n title: 'Invalid Request',\n httpStatusCode: error.status,\n })\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n }\n}\n\n/**\n * Get a single FormSubmissionApproval belonging to the given id.\n *\n * #### Example\n *\n * ```js\n * const formSubmissionApprovalId = 'd27966cc-128d-48a2-b681-6ad52012e113'\n * const {\n * formSubmissionApproval,\n * formApprovalFlowInstance,\n * formSubmissionMeta,\n * form,\n * history,\n * } = await approvalsService.getFormSubmissionApproval(\n * formSubmissionApprovalId,\n * )\n * ```\n *\n * @param formSubmissionApprovalId\n * @param abortSignal\n * @returns\n */\nexport async function getFormSubmissionApproval(\n formSubmissionApprovalId: string,\n abortSignal?: AbortSignal,\n): Promise<FormSubmissionApprovalResponse> {\n try {\n const result = await getRequest<FormSubmissionApprovalResponse>(\n `${tenants.current.apiOrigin}/form-submission-approvals/${formSubmissionApprovalId}`,\n abortSignal,\n )\n return result\n } catch (err) {\n Sentry.captureException(err)\n console.error('Error retrieving form submission approval', err)\n\n const error = err as HTTPError\n if (isOffline()) {\n throw new OneBlinkAppsError(\n 'You are currently offline and do not have a local copy of this app available, please connect to the internet and try again',\n {\n originalError: error,\n isOffline: true,\n },\n )\n }\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot action this pending submission without first logging in. Please login and try again.',\n {\n originalError: error,\n requiresLogin: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access to this application. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n requiresAccessRequest: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 400:\n case 404: {\n throw new OneBlinkAppsError(error.message, {\n title: 'Invalid Request',\n httpStatusCode: error.status,\n })\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n }\n}\n\n/**\n * Update a single FormSubmissionApproval assigned to the current user.\n *\n * #### Example\n *\n * ```js\n * const formSubmissionApproval = {\n * id: 'd27966cc-128d-48a2-b681-6ad52012e113',\n * status: 'APPROVED',\n * username: 'email@example.com',\n * formApprovalFlowInstanceId: 1,\n * notificationEmailAddress: 'email@example.com',\n * notes: 'Great work!!!',\n * internalNotes: 'It was not really that great...',\n * cannedResponseKey: 'my_canned_response_key',\n * createdAt: '2021-02-21T22:57:56.257Z',\n * updatedAt: '2021-02-21T22:57:56.257Z',\n * }\n * const updatedFormSubmissionApproval =\n * await approvalsService.updateFormSubmissionApproval(\n * formSubmissionApproval,\n * )\n * ```\n *\n * @param formSubmissionApproval\n * @param abortSignal\n * @returns\n */\nexport async function updateFormSubmissionApproval(\n formSubmissionApproval: ApprovalTypes.FormSubmissionApproval,\n abortSignal?: AbortSignal,\n): Promise<ApprovalTypes.FormSubmissionApproval> {\n try {\n return await putRequest<ApprovalTypes.FormSubmissionApproval>(\n `${tenants.current.apiOrigin}/form-submission-approvals/${formSubmissionApproval.id}`,\n formSubmissionApproval,\n abortSignal,\n )\n } catch (err) {\n Sentry.captureException(err)\n console.error('Error updating form submission approval', err)\n\n const error = err as HTTPError\n if (isOffline()) {\n throw new OneBlinkAppsError(\n 'You are currently offline, please connect to the internet and try again',\n {\n originalError: error,\n isOffline: true,\n },\n )\n }\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot action this pending submission without first logging in. Please login and try again.',\n {\n originalError: error,\n requiresLogin: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access to this application. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n requiresAccessRequest: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 400:\n case 404:\n case 409: {\n throw new OneBlinkAppsError(error.message, {\n title: 'Invalid Request',\n httpStatusCode: error.status,\n })\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n }\n}\n\n/**\n * @deprecated Use \"reopenFormApprovalFlowInstance()\" instead\n * @internal\n */\nexport const reopenFormSubmissionApproval = reopenFormApprovalFlowInstance\n\n/**\n * As an administrator, reopen a submission that has been approved or denied.\n *\n * #### Example\n *\n * ```js\n * await approvalsService.reopenFormApprovalFlowInstance({\n * formApprovalFlowInstanceId: 1,\n * notificationEmailAddress: 'email@example.com',\n * notes: 'Great work!!!',\n * internalNotes: 'It was not really that great...',\n * cannedResponseKey: 'my_canned_response_key',\n * })\n * ```\n *\n * @param options\n * @param abortSignal\n * @returns\n */\nexport async function reopenFormApprovalFlowInstance(\n {\n formApprovalFlowInstanceId,\n ...payload\n }: {\n formApprovalFlowInstanceId: number\n notificationEmailAddress: string\n notes: string\n internalNotes?: string\n cannedResponseKey?: string\n },\n abortSignal?: AbortSignal,\n): Promise<ApprovalTypes.FormSubmissionApproval> {\n console.log('Reopening form approval flow instance', {\n formApprovalFlowInstanceId,\n ...payload,\n })\n try {\n return await postRequest<ApprovalTypes.FormSubmissionApproval>(\n `${tenants.current.apiOrigin}/form-approval-flow-instances/${formApprovalFlowInstanceId}/reopen`,\n payload,\n abortSignal,\n )\n } catch (err) {\n console.error('Error reopening form approval flow instance', err)\n Sentry.captureException(err)\n\n const error = err as HTTPError\n if (isOffline()) {\n throw new OneBlinkAppsError(\n 'You are currently offline, please connect to the internet and try again',\n {\n originalError: error,\n isOffline: true,\n },\n )\n }\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot reopen this approval without first logging in. Please login and try again.',\n {\n originalError: error,\n requiresLogin: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access to this approval. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n requiresAccessRequest: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 400:\n case 404:\n case 409: {\n throw new OneBlinkAppsError(error.message, {\n title: 'Invalid Request',\n httpStatusCode: error.status,\n })\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n }\n}\n\n/**\n * As an administrator, close a submission that has been approved.\n *\n * #### Example\n *\n * ```js\n * await approvalsService.closeFormApprovalFlowInstance({\n * formApprovalFlowInstanceId: 1,\n * notificationEmailAddress: ['email@example.com'],\n * notes: 'Great work!!!',\n * internalNotes: 'It was not really that great...',\n * cannedResponseKey: 'my_canned_response_key',\n * })\n * ```\n *\n * @param options\n * @param abortSignal\n * @returns\n */\nexport async function closeFormApprovalFlowInstance(\n {\n formApprovalFlowInstanceId,\n ...payload\n }: {\n formApprovalFlowInstanceId: number\n notificationEmailAddress?: string[]\n notes?: string\n internalNotes?: string\n cannedResponseKey?: string\n },\n abortSignal?: AbortSignal,\n): Promise<ApprovalTypes.FormSubmissionApproval> {\n console.log('Closing form approval flow instance', {\n formApprovalFlowInstanceId,\n ...payload,\n })\n try {\n return await postRequest<ApprovalTypes.FormSubmissionApproval>(\n `${tenants.current.apiOrigin}/form-approval-flow-instances/${formApprovalFlowInstanceId}/close`,\n payload,\n abortSignal,\n )\n } catch (err) {\n console.log('Error closing form approval flow instance', err)\n Sentry.captureException(err)\n\n const error = err as HTTPError\n if (isOffline()) {\n throw new OneBlinkAppsError(\n 'You are currently offline, please connect to the internet and try again',\n {\n originalError: error,\n isOffline: true,\n },\n )\n }\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot close this approval without first logging in. Please login and try again.',\n {\n originalError: error,\n requiresLogin: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access to this approval. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n requiresAccessRequest: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 400:\n case 404:\n case 409: {\n throw new OneBlinkAppsError(error.message, {\n title: 'Invalid Request',\n httpStatusCode: error.status,\n })\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n }\n}\n\nexport type FormApprovalFlowResponse = {\n forms: FormTypes.Form[]\n}\n\nexport async function getFormApprovalFlows(\n formsAppId: number,\n abortSignal?: AbortSignal,\n): Promise<FormApprovalFlowResponse> {\n try {\n return await getRequest<FormApprovalFlowResponse>(\n `${tenants.current.apiOrigin}/forms-apps/${formsAppId}/form-approval-flows`,\n abortSignal,\n )\n } catch (err) {\n Sentry.captureException(err)\n console.error('Error retrieving form approval flows', err)\n\n const error = err as HTTPError\n if (isOffline()) {\n throw new OneBlinkAppsError(\n 'You are currently offline, please connect to the internet and try again',\n {\n originalError: error,\n isOffline: true,\n },\n )\n }\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot access form approval flows without first logging in. Please login and try again.',\n {\n originalError: error,\n requiresLogin: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access to this application. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n requiresAccessRequest: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 400:\n case 404: {\n throw new OneBlinkAppsError(error.message, {\n title: 'Invalid Request',\n httpStatusCode: error.status,\n })\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n }\n}\n\n/**\n * Get an Object containing approvals for the app regardless of approval groups\n * and meta for paging. Must be an Approvals Administrator.\n *\n * #### Example\n *\n * ```js\n * const formsAppId = 1\n * const limit = 50\n * const offset = 0\n * const { approvals, meta } =\n * await approvalsService.getFormSubmissionAdministrationApprovals({\n * formAppId,\n * limit,\n * offset,\n * })\n * ```\n *\n * @param options\n * @param abortSignal\n * @returns\n */\nexport async function getFormSubmissionAdministrationApprovals(\n {\n formsAppId,\n ...rest\n }: {\n formsAppId: number\n formId?: number\n externalId?: string\n submissionId?: string\n formApprovalFlowInstanceId?: number\n submittedAfterDateTime?: string\n submittedBeforeDateTime?: string\n limit: number\n offset: number\n statuses?: string[]\n updatedAfterDateTime?: string\n updatedBeforeDateTime?: string\n lastUpdatedBy?: string[]\n submissionTitle?: string\n },\n abortSignal?: AbortSignal,\n): Promise<FormSubmissionsAdministrationApprovalsResponse> {\n try {\n return await searchRequest<FormSubmissionsAdministrationApprovalsResponse>(\n `${tenants.current.apiOrigin}/forms-apps/${formsAppId}/approvals`,\n {\n ...rest,\n },\n abortSignal,\n )\n } catch (err) {\n Sentry.captureException(err)\n console.error(\n 'Error retrieving administrator form submission approvals',\n err,\n )\n\n const error = err as HTTPError\n if (isOffline()) {\n throw new OneBlinkAppsError(\n 'You are currently offline and do not have a local copy of this app available, please connect to the internet and try again',\n {\n originalError: error,\n isOffline: true,\n },\n )\n }\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot view approvals without first logging in. Please login and try again.',\n {\n originalError: error,\n requiresLogin: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access to this application. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n requiresAccessRequest: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 400:\n case 404: {\n throw new OneBlinkAppsError(error.message, {\n title: 'Invalid Request',\n httpStatusCode: error.status,\n })\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n }\n}\n\nexport type FormApprovalUsernamesResponse = {\n usernames: Array<{ username: string }>\n}\n/**\n * Get an array containing usernames that have updated approvals in the within\n * the formsAppId associated with the passed `formsAppId`. Must be an Approvals\n * Administrator.\n *\n * #### Example\n *\n * ```js\n * const formsAppId = 1\n * const { usernames } =\n * await approvalsService.getFormApprovalUsernames(formsAppId)\n * ```\n *\n * @param formsAppId\n * @param abortSignal\n * @returns\n */\nexport async function getFormApprovalUsernames(\n formsAppId: number,\n abortSignal?: AbortSignal,\n): Promise<FormApprovalUsernamesResponse> {\n try {\n return await getRequest<FormApprovalUsernamesResponse>(\n `${tenants.current.apiOrigin}/forms-apps/${formsAppId}/approvals/usernames`,\n abortSignal,\n )\n } catch (err) {\n Sentry.captureException(err)\n console.error('Error retrieving form approval usernames', err)\n\n const error = err as HTTPError\n if (isOffline()) {\n throw new OneBlinkAppsError(\n 'You are currently offline, please connect to the internet and try again',\n {\n originalError: error,\n isOffline: true,\n },\n )\n }\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot access form approval usernames without first logging in. Please login and try again.',\n {\n originalError: error,\n requiresLogin: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access to this application. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n requiresAccessRequest: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 400:\n case 404: {\n throw new OneBlinkAppsError(error.message, {\n title: 'Invalid Request',\n httpStatusCode: error.status,\n })\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n }\n}\n\n/**\n * Create an additional note for a form submission approval.\n *\n * #### Example\n *\n * ```js\n * const formSubmissionApprovalId = 'd96ff812-f263-4a66-868d-e259a1fe4157'\n * const newFormSubmissionApprovalNote = {\n * note: 'this is my note',\n * }\n * const createdFormSubmissionApprovalNote =\n * await approvalsService.createApprovalAdditionalNote({\n * formSubmissionApprovalId,\n * newFormSubmissionApprovalNote,\n * })\n * ```\n *\n * @param options\n * @returns\n */\nexport async function createApprovalAdditionalNote({\n formSubmissionApprovalId,\n newFormSubmissionApprovalNote,\n abortSignal,\n}: {\n formSubmissionApprovalId: string\n newFormSubmissionApprovalNote: ApprovalTypes.NewFormSubmissionApprovalNote\n abortSignal?: AbortSignal\n}): Promise<ApprovalTypes.FormSubmissionApprovalNote> {\n try {\n return await postRequest<ApprovalTypes.FormSubmissionApprovalNote>(\n `${tenants.current.apiOrigin}/form-submission-approvals/${formSubmissionApprovalId}/additional-notes`,\n newFormSubmissionApprovalNote,\n abortSignal,\n )\n } catch (err) {\n console.error('Error creating form submission approval note', err)\n if (abortSignal?.aborted) {\n throw err\n }\n\n Sentry.captureException(err)\n\n const error = err as HTTPError\n if (isOffline()) {\n throw new OneBlinkAppsError(\n 'You are currently offline, please connect to the internet and try again',\n {\n originalError: error,\n isOffline: true,\n },\n )\n }\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot create additional notes without first logging in. Please login and try again.',\n {\n originalError: error,\n requiresLogin: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access to this application. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n requiresAccessRequest: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 400:\n case 404: {\n throw new OneBlinkAppsError(error.message, {\n title: 'Invalid Request',\n httpStatusCode: error.status,\n })\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n }\n}\n\n/**\n * Update an additional note for a form submission approval.\n *\n * #### Example\n *\n * ```js\n * const formSubmissionApprovalId = 'd96ff812-f263-4a66-868d-e259a1fe4157'\n * const formSubmissionApprovalNote = {\n * id: '1e84dee3-0dc0-4abe-b2cf-d15d62fd9d0b',\n * note: 'this is my note',\n * createdAt: '2022-06-24T03:16:34.696Z',\n * createdBy: {\n * username: 'user@domain.com',\n * },\n * updatedAt: '2022-06-24T03:16:34.696Z',\n * lastUpdatedBy: {\n * username: 'user@domain.com',\n * },\n * }\n * const updatedFormSubmissionApprovalNote =\n * await approvalsService.updateApprovalAdditionalNote({\n * formSubmissionApprovalId,\n * formSubmissionApprovalNote,\n * })\n * ```\n *\n * @param options\n * @returns\n */\nexport async function updateApprovalAdditionalNote({\n formSubmissionApprovalId,\n formSubmissionApprovalNote,\n abortSignal,\n}: {\n formSubmissionApprovalId: string\n formSubmissionApprovalNote: ApprovalTypes.FormSubmissionApprovalNote\n abortSignal?: AbortSignal\n}): Promise<ApprovalTypes.FormSubmissionApprovalNote> {\n try {\n return await putRequest<ApprovalTypes.FormSubmissionApprovalNote>(\n `${tenants.current.apiOrigin}/form-submission-approvals/${formSubmissionApprovalId}/additional-notes/${formSubmissionApprovalNote.id}`,\n formSubmissionApprovalNote,\n abortSignal,\n )\n } catch (err) {\n console.error('Error updating form submission approval note', err)\n if (abortSignal?.aborted) {\n throw err\n }\n\n Sentry.captureException(err)\n\n const error = err as HTTPError\n if (isOffline()) {\n throw new OneBlinkAppsError(\n 'You are currently offline, please connect to the internet and try again',\n {\n originalError: error,\n isOffline: true,\n },\n )\n }\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot update additional notes without first logging in. Please login and try again.',\n {\n originalError: error,\n requiresLogin: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access to this application. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n requiresAccessRequest: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 400:\n case 404: {\n throw new OneBlinkAppsError(error.message, {\n title: 'Invalid Request',\n httpStatusCode: error.status,\n })\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n }\n}\n\n/**\n * Delete an additional note for a form submission approval.\n *\n * #### Example\n *\n * ```js\n * const formSubmissionApprovalId = 'd96ff812-f263-4a66-868d-e259a1fe4157'\n * const formSubmissionApprovalNoteId = '1e84dee3-0dc0-4abe-b2cf-d15d62fd9d0b',\n * const updatedFormSubmissionApprovalNote =\n * await approvalsService.deleteApprovalAdditionalNote({\n * formSubmissionApprovalId,\n * formSubmissionApprovalNoteId,\n * })\n * ```\n *\n * @param options\n * @returns\n */\nexport async function deleteApprovalAdditionalNote({\n formSubmissionApprovalId,\n formSubmissionApprovalNoteId,\n abortSignal,\n}: {\n formSubmissionApprovalId: string\n formSubmissionApprovalNoteId: string\n abortSignal?: AbortSignal\n}): Promise<void> {\n try {\n return await deleteRequest(\n `${tenants.current.apiOrigin}/form-submission-approvals/${formSubmissionApprovalId}/additional-notes/${formSubmissionApprovalNoteId}`,\n abortSignal,\n )\n } catch (err) {\n console.error('Error updating form submission approval note', err)\n if (abortSignal?.aborted) {\n throw err\n }\n\n Sentry.captureException(err)\n\n const error = err as HTTPError\n if (isOffline()) {\n throw new OneBlinkAppsError(\n 'You are currently offline, please connect to the internet and try again',\n {\n originalError: error,\n isOffline: true,\n },\n )\n }\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot delete additional notes without first logging in. Please login and try again.',\n {\n originalError: error,\n requiresLogin: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access to this application. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n requiresAccessRequest: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 400:\n case 404: {\n throw new OneBlinkAppsError(error.message, {\n title: 'Invalid Request',\n httpStatusCode: error.status,\n })\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n }\n}\n\n/**\n * Get the status of a single FormSubmissionApproval for the given id.\n *\n * #### Example\n *\n * ```js\n * const formSubmissionApprovalId = 'd27966cc-128d-48a2-b681-6ad52012e113'\n * const { status } =\n * await approvalsService.getFormSubmissionApprovalStatus(\n * formSubmissionApprovalId,\n * )\n * ```\n *\n * @param formSubmissionApprovalId\n * @param abortSignal\n * @returns\n */\nexport async function getFormSubmissionApprovalStatus(\n formSubmissionApprovalId: string,\n abortSignal?: AbortSignal,\n): Promise<{ status: ApprovalTypes.NewFormSubmissionApproval['status'] }> {\n try {\n const result = await getRequest<{\n status: ApprovalTypes.NewFormSubmissionApproval['status']\n }>(\n `${tenants.current.apiOrigin}/form-submission-approvals/${formSubmissionApprovalId}/status`,\n abortSignal,\n )\n return result\n } catch (err) {\n Sentry.captureException(err)\n console.error('Error retrieving form submission approval status', err)\n\n const error = err as HTTPError\n if (isOffline()) {\n throw new OneBlinkAppsError(\n 'You are currently offline and do not have a local copy of this app available, please connect to the internet and try again',\n {\n originalError: error,\n isOffline: true,\n },\n )\n }\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot action this pending submission without first logging in. Please login and try again.',\n {\n originalError: error,\n requiresLogin: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access to this application. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n requiresAccessRequest: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 400:\n case 404: {\n throw new OneBlinkAppsError(error.message, {\n title: 'Invalid Request',\n httpStatusCode: error.status,\n })\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"approvals-service.js","sourceRoot":"","sources":["../../src/apps/approvals-service.ts"],"names":[],"mappings":"AAMA,OAAO,iBAAiB,MAAM,qCAAqC,CAAA;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EACL,aAAa,EACb,UAAU,EACV,UAAU,EACV,aAAa,EACb,WAAW,EACX,SAAS,GACV,MAAM,kBAAkB,CAAA;AACzB,OAAO,OAAO,MAAM,WAAW,CAAA;AAC/B,OAAO,MAAM,MAAM,UAAU,CAAA;AAC7B,OAAO,EAAE,4BAA4B,EAAE,MAAM,0CA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B,CACF,CAAA;YACH,CAAC;YACD,KAAK,GAAG,CAAC,CAAC,CAAC;gBACT,MAAM,IAAI,iBAAiB,CACzB,oHAAoH,EACpH;oBACE,aAAa,EAAE,KAAK;oBACpB,qBAAqB,EAAE,IAAI;oBAC3B,cAAc,EAAE,KAAK,CAAC,MAAM;iBAC7B,CACF,CAAA;YACH,CAAC;YACD,KAAK,GAAG,CAAC;YACT,KAAK,GAAG,CAAC,CAAC,CAAC;gBACT,MAAM,IAAI,iBAAiB,CAAC,KAAK,CAAC,OAAO,EAAE;oBACzC,KAAK,EAAE,iBAAiB;oBACxB,cAAc,EAAE,KAAK,CAAC,MAAM;iBAC7B,CAAC,CAAA;YACJ,CAAC;YACD,OAAO,CAAC,CAAC,CAAC;gBACR,MAAM,IAAI,iBAAiB,CACzB,gFAAgF,EAChF;oBACE,aAAa,EAAE,KAAK;oBACpB,cAAc,EAAE,KAAK,CAAC,MAAM;iBAC7B,CACF,CAAA;YACH,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import {\n SubmissionTypes,\n ApprovalTypes,\n FormTypes,\n SubmissionEventTypes,\n} from '@oneblink/types'\nimport OneBlinkAppsError from './services/errors/oneBlinkAppsError'\nimport { isOffline } from './offline-service'\nimport {\n deleteRequest,\n getRequest,\n putRequest,\n searchRequest,\n postRequest,\n HTTPError,\n} from './services/fetch'\nimport tenants from './tenants'\nimport Sentry from './Sentry'\nexport { getFlowInstanceNodesWithMeta } from '../services/getFlowInstanceNodesWithMeta'\n\nexport type FormSubmissionApprovalsResponse = {\n approvals: Array<{\n formSubmissionApproval: ApprovalTypes.FormSubmissionApproval\n formApprovalFlowInstance: ApprovalTypes.FormApprovalFlowInstance\n formSubmissionMeta: SubmissionTypes.FormSubmissionMeta\n latestSuccessfulFormSubmissionPayment:\n | SubmissionTypes.FormSubmissionPayment\n | undefined\n }>\n}\n\nexport type FormApprovalFlowInstanceHistory = {\n formApprovalFlowInstance: ApprovalTypes.FormApprovalFlowInstance\n formSubmissionMeta: SubmissionTypes.FormSubmissionMeta\n formSubmissionMetaEdits: SubmissionTypes.FormSubmissionMetaEdit[]\n formSubmissionApprovals: ApprovalTypes.FormSubmissionApproval[]\n successfulFormSubmissionPayment?: SubmissionTypes.FormSubmissionPayment\n formSubmissionPayments?: SubmissionTypes.FormSubmissionPayment[]\n}\n\nexport type FormSubmissionApprovalResponse = {\n formSubmissionMeta: SubmissionTypes.FormSubmissionMeta\n formApprovalFlowInstance: ApprovalTypes.FormApprovalFlowInstance\n formSubmissionApproval: ApprovalTypes.FormSubmissionApproval\n form: FormTypes.Form\n successfulFormSubmissionPayment?: SubmissionTypes.FormSubmissionPayment\n history: FormApprovalFlowInstanceHistory[]\n}\n\nexport type FormSubmissionsAdministrationApprovalsResponse = {\n approvals: Array<\n FormApprovalFlowInstanceHistory & {\n history: Array<FormApprovalFlowInstanceHistory>\n }\n >\n meta: {\n limit: number\n offset: number\n nextOffset?: number\n }\n}\n\n/**\n * Get an Object containing FormSubmissionApprovals assigned to the current user\n * and the Form definitions in those approvals.\n *\n * #### Example\n *\n * ```js\n * const formsAppId = 1\n * const {\n * formSubmissionApprovals,\n * formApprovalFlowInstances,\n * forms,\n * formSubmissionMeta,\n * } = await approvalsService.getFormSubmissionApprovals(formAppId)\n * ```\n *\n * @param formsAppId\n * @param abortSignal\n * @returns\n */\nexport async function getFormSubmissionApprovals(\n formsAppId: number,\n abortSignal?: AbortSignal,\n): Promise<FormSubmissionApprovalsResponse> {\n try {\n return await getRequest<FormSubmissionApprovalsResponse>(\n `${tenants.current.apiOrigin}/forms-apps/${formsAppId}/my-approvals`,\n abortSignal,\n )\n } catch (err) {\n Sentry.captureException(err)\n console.error('Error retrieving form submission approvals', err)\n const error = err as HTTPError\n if (isOffline()) {\n throw new OneBlinkAppsError(\n 'You are currently offline and do not have a local copy of this app available, please connect to the internet and try again',\n {\n originalError: error,\n isOffline: true,\n },\n )\n }\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot view your pending approvals without first logging in. Please login and try again.',\n {\n originalError: error,\n requiresLogin: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access to this application. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n requiresAccessRequest: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 400:\n case 404: {\n throw new OneBlinkAppsError(error.message, {\n title: 'Invalid Request',\n httpStatusCode: error.status,\n })\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n }\n}\n\n/**\n * Get a single FormSubmissionApproval belonging to the given id.\n *\n * #### Example\n *\n * ```js\n * const formSubmissionApprovalId = 'd27966cc-128d-48a2-b681-6ad52012e113'\n * const {\n * formSubmissionApproval,\n * formApprovalFlowInstance,\n * formSubmissionMeta,\n * form,\n * history,\n * } = await approvalsService.getFormSubmissionApproval(\n * formSubmissionApprovalId,\n * )\n * ```\n *\n * @param formSubmissionApprovalId\n * @param abortSignal\n * @returns\n */\nexport async function getFormSubmissionApproval(\n formSubmissionApprovalId: string,\n abortSignal?: AbortSignal,\n): Promise<FormSubmissionApprovalResponse> {\n try {\n const result = await getRequest<FormSubmissionApprovalResponse>(\n `${tenants.current.apiOrigin}/form-submission-approvals/${formSubmissionApprovalId}`,\n abortSignal,\n )\n return result\n } catch (err) {\n Sentry.captureException(err)\n console.error('Error retrieving form submission approval', err)\n\n const error = err as HTTPError\n if (isOffline()) {\n throw new OneBlinkAppsError(\n 'You are currently offline and do not have a local copy of this app available, please connect to the internet and try again',\n {\n originalError: error,\n isOffline: true,\n },\n )\n }\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot action this pending submission without first logging in. Please login and try again.',\n {\n originalError: error,\n requiresLogin: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access to this application. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n requiresAccessRequest: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 400:\n case 404: {\n throw new OneBlinkAppsError(error.message, {\n title: 'Invalid Request',\n httpStatusCode: error.status,\n })\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n }\n}\n\n/**\n * Update a single FormSubmissionApproval assigned to the current user.\n *\n * #### Example\n *\n * ```js\n * const formSubmissionApproval = {\n * id: 'd27966cc-128d-48a2-b681-6ad52012e113',\n * status: 'APPROVED',\n * username: 'email@example.com',\n * formApprovalFlowInstanceId: 1,\n * notificationEmailAddress: 'email@example.com',\n * notes: 'Great work!!!',\n * internalNotes: 'It was not really that great...',\n * cannedResponseKey: 'my_canned_response_key',\n * createdAt: '2021-02-21T22:57:56.257Z',\n * updatedAt: '2021-02-21T22:57:56.257Z',\n * }\n * const updatedFormSubmissionApproval =\n * await approvalsService.updateFormSubmissionApproval(\n * formSubmissionApproval,\n * )\n * ```\n *\n * @param formSubmissionApproval\n * @param abortSignal\n * @returns\n */\nexport const PAYMENT_IN_PROGRESS_CONFLICT = 'PAYMENT_IN_PROGRESS'\n\nexport async function createApprovalStepPayment(\n formSubmissionApprovalId: string,\n body: {\n redirectUrl: string\n paymentFormUrl?: string\n },\n abortSignal?: AbortSignal,\n): Promise<{\n hostedFormUrl: string\n amount: number\n paymentSubmissionEvent: SubmissionEventTypes.FormPaymentEvent\n customerReferenceNumber?: string\n}> {\n try {\n return await postRequest(\n `${tenants.current.apiOrigin}/form-submission-approvals/${formSubmissionApprovalId}/payment`,\n body,\n abortSignal,\n )\n } catch (error) {\n if (\n error instanceof HTTPError &&\n error.status === 409 &&\n error.conflict === PAYMENT_IN_PROGRESS_CONFLICT\n ) {\n throw new OneBlinkAppsError(\n 'A payment is already in progress for this step. Finish or cancel that payment before starting another.',\n {\n httpStatusCode: error.status,\n conflict: PAYMENT_IN_PROGRESS_CONFLICT,\n originalError: error,\n },\n )\n }\n throw error\n }\n}\n\nexport async function skipApprovalStepPayment(\n formSubmissionApprovalId: string,\n abortSignal?: AbortSignal,\n): Promise<ApprovalTypes.FormSubmissionApproval> {\n return await postRequest(\n `${tenants.current.apiOrigin}/form-submission-approvals/${formSubmissionApprovalId}/skip-payment`,\n {},\n abortSignal,\n )\n}\n\nexport async function updateFormSubmissionApproval(\n formSubmissionApproval: ApprovalTypes.FormSubmissionApproval,\n abortSignal?: AbortSignal,\n): Promise<ApprovalTypes.FormSubmissionApproval> {\n try {\n return await putRequest<ApprovalTypes.FormSubmissionApproval>(\n `${tenants.current.apiOrigin}/form-submission-approvals/${formSubmissionApproval.id}`,\n formSubmissionApproval,\n abortSignal,\n )\n } catch (err) {\n Sentry.captureException(err)\n console.error('Error updating form submission approval', err)\n\n const error = err as HTTPError\n if (isOffline()) {\n throw new OneBlinkAppsError(\n 'You are currently offline, please connect to the internet and try again',\n {\n originalError: error,\n isOffline: true,\n },\n )\n }\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot action this pending submission without first logging in. Please login and try again.',\n {\n originalError: error,\n requiresLogin: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access to this application. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n requiresAccessRequest: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 400:\n case 404:\n case 409: {\n throw new OneBlinkAppsError(error.message, {\n title: 'Invalid Request',\n httpStatusCode: error.status,\n })\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n }\n}\n\n/**\n * @deprecated Use \"reopenFormApprovalFlowInstance()\" instead\n * @internal\n */\nexport const reopenFormSubmissionApproval = reopenFormApprovalFlowInstance\n\n/**\n * As an administrator, reopen a submission that has been approved or denied.\n *\n * #### Example\n *\n * ```js\n * await approvalsService.reopenFormApprovalFlowInstance({\n * formApprovalFlowInstanceId: 1,\n * notificationEmailAddress: 'email@example.com',\n * notes: 'Great work!!!',\n * internalNotes: 'It was not really that great...',\n * cannedResponseKey: 'my_canned_response_key',\n * })\n * ```\n *\n * @param options\n * @param abortSignal\n * @returns\n */\nexport async function reopenFormApprovalFlowInstance(\n {\n formApprovalFlowInstanceId,\n ...payload\n }: {\n formApprovalFlowInstanceId: number\n notificationEmailAddress: string\n notes: string\n internalNotes?: string\n cannedResponseKey?: string\n },\n abortSignal?: AbortSignal,\n): Promise<ApprovalTypes.FormSubmissionApproval> {\n console.log('Reopening form approval flow instance', {\n formApprovalFlowInstanceId,\n ...payload,\n })\n try {\n return await postRequest<ApprovalTypes.FormSubmissionApproval>(\n `${tenants.current.apiOrigin}/form-approval-flow-instances/${formApprovalFlowInstanceId}/reopen`,\n payload,\n abortSignal,\n )\n } catch (err) {\n console.error('Error reopening form approval flow instance', err)\n Sentry.captureException(err)\n\n const error = err as HTTPError\n if (isOffline()) {\n throw new OneBlinkAppsError(\n 'You are currently offline, please connect to the internet and try again',\n {\n originalError: error,\n isOffline: true,\n },\n )\n }\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot reopen this approval without first logging in. Please login and try again.',\n {\n originalError: error,\n requiresLogin: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access to this approval. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n requiresAccessRequest: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 400:\n case 404:\n case 409: {\n throw new OneBlinkAppsError(error.message, {\n title: 'Invalid Request',\n httpStatusCode: error.status,\n })\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n }\n}\n\n/**\n * As an administrator, close a submission that has been approved.\n *\n * #### Example\n *\n * ```js\n * await approvalsService.closeFormApprovalFlowInstance({\n * formApprovalFlowInstanceId: 1,\n * notificationEmailAddress: ['email@example.com'],\n * notes: 'Great work!!!',\n * internalNotes: 'It was not really that great...',\n * cannedResponseKey: 'my_canned_response_key',\n * })\n * ```\n *\n * @param options\n * @param abortSignal\n * @returns\n */\nexport async function closeFormApprovalFlowInstance(\n {\n formApprovalFlowInstanceId,\n ...payload\n }: {\n formApprovalFlowInstanceId: number\n notificationEmailAddress?: string[]\n notes?: string\n internalNotes?: string\n cannedResponseKey?: string\n },\n abortSignal?: AbortSignal,\n): Promise<ApprovalTypes.FormSubmissionApproval> {\n console.log('Closing form approval flow instance', {\n formApprovalFlowInstanceId,\n ...payload,\n })\n try {\n return await postRequest<ApprovalTypes.FormSubmissionApproval>(\n `${tenants.current.apiOrigin}/form-approval-flow-instances/${formApprovalFlowInstanceId}/close`,\n payload,\n abortSignal,\n )\n } catch (err) {\n console.log('Error closing form approval flow instance', err)\n Sentry.captureException(err)\n\n const error = err as HTTPError\n if (isOffline()) {\n throw new OneBlinkAppsError(\n 'You are currently offline, please connect to the internet and try again',\n {\n originalError: error,\n isOffline: true,\n },\n )\n }\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot close this approval without first logging in. Please login and try again.',\n {\n originalError: error,\n requiresLogin: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access to this approval. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n requiresAccessRequest: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 400:\n case 404:\n case 409: {\n throw new OneBlinkAppsError(error.message, {\n title: 'Invalid Request',\n httpStatusCode: error.status,\n })\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n }\n}\n\nexport type FormApprovalFlowResponse = {\n forms: FormTypes.Form[]\n}\n\nexport async function getFormApprovalFlows(\n formsAppId: number,\n abortSignal?: AbortSignal,\n): Promise<FormApprovalFlowResponse> {\n try {\n return await getRequest<FormApprovalFlowResponse>(\n `${tenants.current.apiOrigin}/forms-apps/${formsAppId}/form-approval-flows`,\n abortSignal,\n )\n } catch (err) {\n Sentry.captureException(err)\n console.error('Error retrieving form approval flows', err)\n\n const error = err as HTTPError\n if (isOffline()) {\n throw new OneBlinkAppsError(\n 'You are currently offline, please connect to the internet and try again',\n {\n originalError: error,\n isOffline: true,\n },\n )\n }\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot access form approval flows without first logging in. Please login and try again.',\n {\n originalError: error,\n requiresLogin: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access to this application. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n requiresAccessRequest: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 400:\n case 404: {\n throw new OneBlinkAppsError(error.message, {\n title: 'Invalid Request',\n httpStatusCode: error.status,\n })\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n }\n}\n\n/**\n * Get an Object containing approvals for the app regardless of approval groups\n * and meta for paging. Must be an Approvals Administrator.\n *\n * #### Example\n *\n * ```js\n * const formsAppId = 1\n * const limit = 50\n * const offset = 0\n * const { approvals, meta } =\n * await approvalsService.getFormSubmissionAdministrationApprovals({\n * formAppId,\n * limit,\n * offset,\n * })\n * ```\n *\n * @param options\n * @param abortSignal\n * @returns\n */\nexport async function getFormSubmissionAdministrationApprovals(\n {\n formsAppId,\n ...rest\n }: {\n formsAppId: number\n formId?: number\n externalId?: string\n submissionId?: string\n formApprovalFlowInstanceId?: number\n submittedAfterDateTime?: string\n submittedBeforeDateTime?: string\n limit: number\n offset: number\n statuses?: string[]\n updatedAfterDateTime?: string\n updatedBeforeDateTime?: string\n lastUpdatedBy?: string[]\n submissionTitle?: string\n },\n abortSignal?: AbortSignal,\n): Promise<FormSubmissionsAdministrationApprovalsResponse> {\n try {\n return await searchRequest<FormSubmissionsAdministrationApprovalsResponse>(\n `${tenants.current.apiOrigin}/forms-apps/${formsAppId}/approvals`,\n {\n ...rest,\n },\n abortSignal,\n )\n } catch (err) {\n Sentry.captureException(err)\n console.error(\n 'Error retrieving administrator form submission approvals',\n err,\n )\n\n const error = err as HTTPError\n if (isOffline()) {\n throw new OneBlinkAppsError(\n 'You are currently offline and do not have a local copy of this app available, please connect to the internet and try again',\n {\n originalError: error,\n isOffline: true,\n },\n )\n }\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot view approvals without first logging in. Please login and try again.',\n {\n originalError: error,\n requiresLogin: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access to this application. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n requiresAccessRequest: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 400:\n case 404: {\n throw new OneBlinkAppsError(error.message, {\n title: 'Invalid Request',\n httpStatusCode: error.status,\n })\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n }\n}\n\nexport type FormApprovalUsernamesResponse = {\n usernames: Array<{ username: string }>\n}\n/**\n * Get an array containing usernames that have updated approvals in the within\n * the formsAppId associated with the passed `formsAppId`. Must be an Approvals\n * Administrator.\n *\n * #### Example\n *\n * ```js\n * const formsAppId = 1\n * const { usernames } =\n * await approvalsService.getFormApprovalUsernames(formsAppId)\n * ```\n *\n * @param formsAppId\n * @param abortSignal\n * @returns\n */\nexport async function getFormApprovalUsernames(\n formsAppId: number,\n abortSignal?: AbortSignal,\n): Promise<FormApprovalUsernamesResponse> {\n try {\n return await getRequest<FormApprovalUsernamesResponse>(\n `${tenants.current.apiOrigin}/forms-apps/${formsAppId}/approvals/usernames`,\n abortSignal,\n )\n } catch (err) {\n Sentry.captureException(err)\n console.error('Error retrieving form approval usernames', err)\n\n const error = err as HTTPError\n if (isOffline()) {\n throw new OneBlinkAppsError(\n 'You are currently offline, please connect to the internet and try again',\n {\n originalError: error,\n isOffline: true,\n },\n )\n }\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot access form approval usernames without first logging in. Please login and try again.',\n {\n originalError: error,\n requiresLogin: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access to this application. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n requiresAccessRequest: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 400:\n case 404: {\n throw new OneBlinkAppsError(error.message, {\n title: 'Invalid Request',\n httpStatusCode: error.status,\n })\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n }\n}\n\n/**\n * Create an additional note for a form submission approval.\n *\n * #### Example\n *\n * ```js\n * const formSubmissionApprovalId = 'd96ff812-f263-4a66-868d-e259a1fe4157'\n * const newFormSubmissionApprovalNote = {\n * note: 'this is my note',\n * }\n * const createdFormSubmissionApprovalNote =\n * await approvalsService.createApprovalAdditionalNote({\n * formSubmissionApprovalId,\n * newFormSubmissionApprovalNote,\n * })\n * ```\n *\n * @param options\n * @returns\n */\nexport async function createApprovalAdditionalNote({\n formSubmissionApprovalId,\n newFormSubmissionApprovalNote,\n abortSignal,\n}: {\n formSubmissionApprovalId: string\n newFormSubmissionApprovalNote: ApprovalTypes.NewFormSubmissionApprovalNote\n abortSignal?: AbortSignal\n}): Promise<ApprovalTypes.FormSubmissionApprovalNote> {\n try {\n return await postRequest<ApprovalTypes.FormSubmissionApprovalNote>(\n `${tenants.current.apiOrigin}/form-submission-approvals/${formSubmissionApprovalId}/additional-notes`,\n newFormSubmissionApprovalNote,\n abortSignal,\n )\n } catch (err) {\n console.error('Error creating form submission approval note', err)\n if (abortSignal?.aborted) {\n throw err\n }\n\n Sentry.captureException(err)\n\n const error = err as HTTPError\n if (isOffline()) {\n throw new OneBlinkAppsError(\n 'You are currently offline, please connect to the internet and try again',\n {\n originalError: error,\n isOffline: true,\n },\n )\n }\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot create additional notes without first logging in. Please login and try again.',\n {\n originalError: error,\n requiresLogin: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access to this application. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n requiresAccessRequest: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 400:\n case 404: {\n throw new OneBlinkAppsError(error.message, {\n title: 'Invalid Request',\n httpStatusCode: error.status,\n })\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n }\n}\n\n/**\n * Update an additional note for a form submission approval.\n *\n * #### Example\n *\n * ```js\n * const formSubmissionApprovalId = 'd96ff812-f263-4a66-868d-e259a1fe4157'\n * const formSubmissionApprovalNote = {\n * id: '1e84dee3-0dc0-4abe-b2cf-d15d62fd9d0b',\n * note: 'this is my note',\n * createdAt: '2022-06-24T03:16:34.696Z',\n * createdBy: {\n * username: 'user@domain.com',\n * },\n * updatedAt: '2022-06-24T03:16:34.696Z',\n * lastUpdatedBy: {\n * username: 'user@domain.com',\n * },\n * }\n * const updatedFormSubmissionApprovalNote =\n * await approvalsService.updateApprovalAdditionalNote({\n * formSubmissionApprovalId,\n * formSubmissionApprovalNote,\n * })\n * ```\n *\n * @param options\n * @returns\n */\nexport async function updateApprovalAdditionalNote({\n formSubmissionApprovalId,\n formSubmissionApprovalNote,\n abortSignal,\n}: {\n formSubmissionApprovalId: string\n formSubmissionApprovalNote: ApprovalTypes.FormSubmissionApprovalNote\n abortSignal?: AbortSignal\n}): Promise<ApprovalTypes.FormSubmissionApprovalNote> {\n try {\n return await putRequest<ApprovalTypes.FormSubmissionApprovalNote>(\n `${tenants.current.apiOrigin}/form-submission-approvals/${formSubmissionApprovalId}/additional-notes/${formSubmissionApprovalNote.id}`,\n formSubmissionApprovalNote,\n abortSignal,\n )\n } catch (err) {\n console.error('Error updating form submission approval note', err)\n if (abortSignal?.aborted) {\n throw err\n }\n\n Sentry.captureException(err)\n\n const error = err as HTTPError\n if (isOffline()) {\n throw new OneBlinkAppsError(\n 'You are currently offline, please connect to the internet and try again',\n {\n originalError: error,\n isOffline: true,\n },\n )\n }\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot update additional notes without first logging in. Please login and try again.',\n {\n originalError: error,\n requiresLogin: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access to this application. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n requiresAccessRequest: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 400:\n case 404: {\n throw new OneBlinkAppsError(error.message, {\n title: 'Invalid Request',\n httpStatusCode: error.status,\n })\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n }\n}\n\n/**\n * Delete an additional note for a form submission approval.\n *\n * #### Example\n *\n * ```js\n * const formSubmissionApprovalId = 'd96ff812-f263-4a66-868d-e259a1fe4157'\n * const formSubmissionApprovalNoteId = '1e84dee3-0dc0-4abe-b2cf-d15d62fd9d0b',\n * const updatedFormSubmissionApprovalNote =\n * await approvalsService.deleteApprovalAdditionalNote({\n * formSubmissionApprovalId,\n * formSubmissionApprovalNoteId,\n * })\n * ```\n *\n * @param options\n * @returns\n */\nexport async function deleteApprovalAdditionalNote({\n formSubmissionApprovalId,\n formSubmissionApprovalNoteId,\n abortSignal,\n}: {\n formSubmissionApprovalId: string\n formSubmissionApprovalNoteId: string\n abortSignal?: AbortSignal\n}): Promise<void> {\n try {\n return await deleteRequest(\n `${tenants.current.apiOrigin}/form-submission-approvals/${formSubmissionApprovalId}/additional-notes/${formSubmissionApprovalNoteId}`,\n abortSignal,\n )\n } catch (err) {\n console.error('Error updating form submission approval note', err)\n if (abortSignal?.aborted) {\n throw err\n }\n\n Sentry.captureException(err)\n\n const error = err as HTTPError\n if (isOffline()) {\n throw new OneBlinkAppsError(\n 'You are currently offline, please connect to the internet and try again',\n {\n originalError: error,\n isOffline: true,\n },\n )\n }\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot delete additional notes without first logging in. Please login and try again.',\n {\n originalError: error,\n requiresLogin: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access to this application. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n requiresAccessRequest: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 400:\n case 404: {\n throw new OneBlinkAppsError(error.message, {\n title: 'Invalid Request',\n httpStatusCode: error.status,\n })\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n }\n}\n\n/**\n * Get the status of a single FormSubmissionApproval for the given id.\n *\n * #### Example\n *\n * ```js\n * const formSubmissionApprovalId = 'd27966cc-128d-48a2-b681-6ad52012e113'\n * const { status } =\n * await approvalsService.getFormSubmissionApprovalStatus(\n * formSubmissionApprovalId,\n * )\n * ```\n *\n * @param formSubmissionApprovalId\n * @param abortSignal\n * @returns\n */\nexport async function getFormSubmissionApprovalStatus(\n formSubmissionApprovalId: string,\n abortSignal?: AbortSignal,\n): Promise<{ status: ApprovalTypes.NewFormSubmissionApproval['status'] }> {\n try {\n const result = await getRequest<{\n status: ApprovalTypes.NewFormSubmissionApproval['status']\n }>(\n `${tenants.current.apiOrigin}/form-submission-approvals/${formSubmissionApprovalId}/status`,\n abortSignal,\n )\n return result\n } catch (err) {\n Sentry.captureException(err)\n console.error('Error retrieving form submission approval status', err)\n\n const error = err as HTTPError\n if (isOffline()) {\n throw new OneBlinkAppsError(\n 'You are currently offline and do not have a local copy of this app available, please connect to the internet and try again',\n {\n originalError: error,\n isOffline: true,\n },\n )\n }\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot action this pending submission without first logging in. Please login and try again.',\n {\n originalError: error,\n requiresLogin: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access to this application. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n requiresAccessRequest: true,\n httpStatusCode: error.status,\n },\n )\n }\n case 400:\n case 404: {\n throw new OneBlinkAppsError(error.message, {\n title: 'Invalid Request',\n httpStatusCode: error.status,\n })\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n }\n}\n"]}
|
|
@@ -3,7 +3,29 @@ import { SubmissionEventTypes, SubmissionTypes } from '@oneblink/types';
|
|
|
3
3
|
import { FormSubmission, FormSubmissionResult } from './types/submissions';
|
|
4
4
|
import { HandlePaymentResult, PaymentReceiptItem } from './types/payments';
|
|
5
5
|
import * as westpacQuickStream from './services/payment-providers/WestpacQuickStreamPaymentProvider';
|
|
6
|
+
import { getPaymentFormSession, getPaymentHandoff, paymentProviderRendersInApp, type InAppPaymentType, type PaymentFormSession } from './services/payment-handoff';
|
|
6
7
|
export { HandlePaymentResult, PaymentReceiptItem, westpacQuickStream };
|
|
8
|
+
export { paymentProviderRendersInApp, getPaymentHandoff, getPaymentFormSession };
|
|
9
|
+
export type { InAppPaymentType, PaymentFormSession };
|
|
10
|
+
/**
|
|
11
|
+
* Get the receipt URL for a completed in-app payment. The receipt page verifies
|
|
12
|
+
* the transaction from the query parameters on this URL.
|
|
13
|
+
*
|
|
14
|
+
* @param options
|
|
15
|
+
* @returns
|
|
16
|
+
*/
|
|
17
|
+
export declare function getCompletedPaymentReceiptUrl(options: {
|
|
18
|
+
formSubmissionResult: FormSubmissionResult;
|
|
19
|
+
formSubmissionPayment: SubmissionTypes.FormSubmissionPayment;
|
|
20
|
+
}): string;
|
|
21
|
+
/**
|
|
22
|
+
* Get the receipt URL for a cancelled in-app payment.
|
|
23
|
+
*
|
|
24
|
+
* @param formSubmissionResult
|
|
25
|
+
* @param formSubmissionPaymentId
|
|
26
|
+
* @returns
|
|
27
|
+
*/
|
|
28
|
+
export declare function getCancelledPaymentReceiptUrl(formSubmissionResult: FormSubmissionResult, formSubmissionPaymentId: string): string;
|
|
7
29
|
/**
|
|
8
30
|
* Pass in query string parameters after a redirect back to your app after a
|
|
9
31
|
* payment is processed. This function will handle all payment submission events
|
|
@@ -7,9 +7,52 @@ import CPPayPaymentProvider from './services/payment-providers/CPPayPaymentProvi
|
|
|
7
7
|
import NSWGovPayPaymentProvider from './services/payment-providers/NSWGovPayPaymentProvider';
|
|
8
8
|
import WestpacQuickStreamPaymentProvider, * as westpacQuickStream from './services/payment-providers/WestpacQuickStreamPaymentProvider';
|
|
9
9
|
import { addDaysToDate, endOfDay, parseDayOnlyDate, startOfDay, replaceSubmissionFormatters, } from './localisation-service';
|
|
10
|
+
import { getPaymentFormSession, getPaymentHandoff, paymentProviderRendersInApp, } from './services/payment-handoff';
|
|
10
11
|
import { getSchedulingBooking, removeSchedulingBooking, } from './services/schedulingHandlers';
|
|
11
12
|
const KEY = 'PAYMENT_SUBMISSION_RESULT';
|
|
12
13
|
export { westpacQuickStream };
|
|
14
|
+
export { paymentProviderRendersInApp, getPaymentHandoff, getPaymentFormSession };
|
|
15
|
+
/**
|
|
16
|
+
* Receipt URLs for providers whose payment form is rendered by the app. Add a
|
|
17
|
+
* new in-app provider here so hosts of that form can redirect to a receipt
|
|
18
|
+
* without knowing which provider took the payment.
|
|
19
|
+
*/
|
|
20
|
+
function getInAppPaymentReceipts(formSubmissionResult) {
|
|
21
|
+
var _a;
|
|
22
|
+
const paymentType = (_a = formSubmissionResult.payment) === null || _a === void 0 ? void 0 : _a.submissionEvent.type;
|
|
23
|
+
if (!paymentType || !paymentProviderRendersInApp(paymentType)) {
|
|
24
|
+
throw new OneBlinkAppsError('It looks like you are attempting to view a receipt for an unsupported payment.');
|
|
25
|
+
}
|
|
26
|
+
switch (paymentType) {
|
|
27
|
+
case 'WESTPAC_QUICK_STREAM': {
|
|
28
|
+
return westpacQuickStream;
|
|
29
|
+
}
|
|
30
|
+
default: {
|
|
31
|
+
const unsupportedPaymentType = paymentType;
|
|
32
|
+
throw new OneBlinkAppsError(`It looks like you are attempting to view a receipt for an unsupported payment (${unsupportedPaymentType}).`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Get the receipt URL for a completed in-app payment. The receipt page verifies
|
|
38
|
+
* the transaction from the query parameters on this URL.
|
|
39
|
+
*
|
|
40
|
+
* @param options
|
|
41
|
+
* @returns
|
|
42
|
+
*/
|
|
43
|
+
export function getCompletedPaymentReceiptUrl(options) {
|
|
44
|
+
return getInAppPaymentReceipts(options.formSubmissionResult).getCompletedPaymentReceiptUrl(options);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Get the receipt URL for a cancelled in-app payment.
|
|
48
|
+
*
|
|
49
|
+
* @param formSubmissionResult
|
|
50
|
+
* @param formSubmissionPaymentId
|
|
51
|
+
* @returns
|
|
52
|
+
*/
|
|
53
|
+
export function getCancelledPaymentReceiptUrl(formSubmissionResult, formSubmissionPaymentId) {
|
|
54
|
+
return getInAppPaymentReceipts(formSubmissionResult).getCancelledPaymentReceiptUrl(formSubmissionResult, formSubmissionPaymentId);
|
|
55
|
+
}
|
|
13
56
|
function getPaymentProvider(formSubmissionResult, paymentSubmissionEvent) {
|
|
14
57
|
switch (paymentSubmissionEvent.type) {
|
|
15
58
|
case 'BPOINT': {
|
|
@@ -1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vB,UAAU,EAAE,IAAI;QAChB,OAAO;KACR,CAAC,CAAA;IAEF,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,8BAA8B;;IAIlD,MAAM,oBAAoB,GACxB,MAAM,YAAY,CAAC,kBAAkB,CAA8B,GAAG,CAAC,CAAA;IAEzE,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAC1B,MAAM,IAAI,iBAAiB,CACzB,oFAAoF,CACrF,CAAA;IACH,CAAC;IACD,IAAI,CAAC,CAAA,MAAA,oBAAoB,CAAC,OAAO,0CAAE,eAAe,CAAA,EAAE,CAAC;QACnD,MAAM,IAAI,iBAAiB,CACzB,yFAAyF,CAC1F,CAAA;IACH,CAAC;IAED,OAAO;QACL,oBAAoB;QACpB,sBAAsB,EAAE,MAAA,oBAAoB,CAAC,OAAO,0CAAE,eAAe;KACtE,CAAA;AACH,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,0CAA0C,CACxD,qBAA4D;IAE5D,OAAO,cAAc,CAAC,0CAA0C,CAC9D,qBAAqB,EACrB,2BAA2B,CAC5B,CAAA;AACH,CAAC","sourcesContent":["import { paymentService } from '@oneblink/sdk-core'\nimport OneBlinkAppsError from './services/errors/oneBlinkAppsError'\nimport { createPaymentConfiguration } from './services/api/payment'\nimport utilsService from './services/utils'\nimport { SubmissionEventTypes, SubmissionTypes } from '@oneblink/types'\nimport { FormSubmission, FormSubmissionResult } from './types/submissions'\nimport {\n HandlePaymentResult,\n PaymentProvider,\n PaymentReceiptItem,\n} from './types/payments'\nimport BPOINTPaymentProvider from './services/payment-providers/BPOINTPaymentProvider'\nimport CPPayPaymentProvider from './services/payment-providers/CPPayPaymentProvider'\nimport NSWGovPayPaymentProvider from './services/payment-providers/NSWGovPayPaymentProvider'\nimport WestpacQuickStreamPaymentProvider, * as westpacQuickStream from './services/payment-providers/WestpacQuickStreamPaymentProvider'\nimport {\n addDaysToDate,\n endOfDay,\n parseDayOnlyDate,\n startOfDay,\n replaceSubmissionFormatters,\n} from './localisation-service'\nimport {\n getSchedulingBooking,\n removeSchedulingBooking,\n} from './services/schedulingHandlers'\n\nconst KEY = 'PAYMENT_SUBMISSION_RESULT'\n\nexport { HandlePaymentResult, PaymentReceiptItem, westpacQuickStream }\n\nfunction getPaymentProvider(\n formSubmissionResult: FormSubmissionResult,\n paymentSubmissionEvent: SubmissionEventTypes.FormPaymentEvent,\n): PaymentProvider<SubmissionEventTypes.FormPaymentEvent> {\n switch (paymentSubmissionEvent.type) {\n case 'BPOINT': {\n return new BPOINTPaymentProvider(\n paymentSubmissionEvent,\n formSubmissionResult,\n )\n }\n case 'CP_PAY': {\n return new CPPayPaymentProvider(\n paymentSubmissionEvent,\n formSubmissionResult,\n )\n }\n case 'NSW_GOV_PAY': {\n return new NSWGovPayPaymentProvider(\n paymentSubmissionEvent,\n formSubmissionResult,\n )\n }\n case 'WESTPAC_QUICK_STREAM': {\n return new WestpacQuickStreamPaymentProvider(\n paymentSubmissionEvent,\n formSubmissionResult,\n )\n }\n }\n}\n\n/**\n * Pass in query string parameters after a redirect back to your app after a\n * payment is processed. This function will handle all payment submission events\n * supported by OneBlink. Will return a Transaction and the submission result\n * that was returned from `handlePaymentSubmissionEvent()` before redirecting to\n * `payment.hostedFormUrl`.\n *\n * #### Example\n *\n * ```js\n * import queryString from 'query-string'\n *\n * const query = queryString.parse(window.location.search)\n * const { transaction, submissionResult } =\n * await paymentService.handlePaymentQuerystring(query)\n * ```\n *\n * @param query\n * @returns\n */\nexport async function handlePaymentQuerystring(\n query: Record<string, unknown>,\n): Promise<HandlePaymentResult> {\n const submissionResult =\n await utilsService.getLocalForageItem<FormSubmissionResult | null>(KEY)\n // If the current transaction does not match the submission\n // we will display message to user indicating\n // they are looking for the wrong transaction receipt.\n if (!submissionResult) {\n throw new OneBlinkAppsError(\n 'It looks like you are attempting to view a receipt for an unknown payment.',\n )\n }\n if (!submissionResult.payment || !submissionResult.payment.submissionEvent) {\n throw new OneBlinkAppsError(\n 'It looks like you are attempting to view a receipt for a misconfigured payment.',\n )\n }\n const paymentProvider = getPaymentProvider(\n submissionResult,\n submissionResult.payment.submissionEvent,\n )\n if (!paymentProvider) {\n throw new OneBlinkAppsError(\n 'It looks like you are attempting to view a receipt for an unsupported payment.',\n )\n }\n\n const verifiedPaymentTransaction =\n await paymentProvider.verifyPaymentTransaction(query)\n\n const schedulingBooking = await getSchedulingBooking(\n verifiedPaymentTransaction.submissionResult.submissionId,\n )\n if (schedulingBooking && verifiedPaymentTransaction.transaction.isSuccess) {\n await removeSchedulingBooking(schedulingBooking.submissionId)\n }\n\n return {\n ...verifiedPaymentTransaction,\n schedulingBooking,\n }\n}\n\nexport function checkForPaymentSubmissionEvent(\n formSubmission: FormSubmission,\n submissionTimestamp: string,\n): SubmissionEventTypes.FormPaymentEvent | undefined {\n const result = paymentService.checkForPaymentEvent({\n definition: formSubmission.definition,\n submission: formSubmission.submission,\n submissionTimestamp,\n parseDayOnlyDate,\n addDaysToDate,\n startOfDay,\n endOfDay,\n })\n if (result) {\n console.log('Form has a payment submission event with amount', result)\n return result.paymentSubmissionEvent\n }\n return undefined\n}\n\n/**\n * Handle a submission result with a payment submission event. Will throw an\n * error if a transaction has already been made using this submission result.\n * Will return `undefined` if the submission does not have an amount. Will\n * return the submission result passed in with a `payment` property if the\n * submission requires processing.\n *\n * #### Example\n *\n * ```js\n * const formSubmissionResult = {\n * submissionId: '89c6e98e-f56f-45fc-84fe-c4fc62331d34',\n * submissionTimestamp: '2020-07-29T01:03:26.573Z'\n * formsAppId: 1,\n * submission: {\n * form: 'data',\n * goes: 'here',\n * amount: 1.50,\n * }\n * definition: OneBlinkForm,\n * payment: null,\n * }\n * const paymentSubmissionEvent = {\n * type: 'CP_PAY',\n * configuration: {\n * elementId: '12663efc-4c6a-4e72-8505-559edfe3e92e',\n * gatewayId: '6658c5c4-e0db-483b-8af7-6a6464fe772c',\n * },\n * }\n * const paymentReceiptUrl = `${window.location.origin}/payment-receipt`\n * const paymentSubmissionResult = await paymentService.handlePaymentSubmissionEvent({\n * formSubmissionResult,\n * paymentSubmissionEvent,\n * paymentReceiptUrl,\n * })\n * if (paymentSubmissionResult) {\n * window.location.href = paymentSubmissionResult.payment.hostedFormUrl\n * }\n * ```\n *\n * @param options\n * @returns\n */\nexport async function handlePaymentSubmissionEvent({\n formSubmissionResult,\n paymentReceiptUrl,\n paymentFormUrl,\n}: {\n formSubmissionResult: FormSubmissionResult\n paymentReceiptUrl: string\n paymentFormUrl: string | undefined\n}): Promise<FormSubmissionResult['payment']> {\n if (!formSubmissionResult.submissionId) {\n throw new OneBlinkAppsError(\n 'It looks like you are attempting to make a payment for an unknown submission.',\n )\n }\n const paymentConfiguration = await createPaymentConfiguration(\n formSubmissionResult.submissionId,\n { redirectUrl: paymentReceiptUrl, paymentFormUrl },\n )\n\n if (!paymentConfiguration) {\n await utilsService.setLocalForageItem(KEY, {\n ...formSubmissionResult,\n scheduling: null,\n payment: null,\n })\n return null\n }\n\n const payment = {\n submissionEvent: paymentConfiguration.paymentSubmissionEvent,\n paymentReceiptUrl,\n hostedFormUrl: paymentConfiguration.hostedFormUrl,\n paymentFormUrl,\n amount: paymentConfiguration.amount,\n }\n console.log('Created Payment configuration to start transaction', payment)\n\n await utilsService.setLocalForageItem(KEY, {\n ...formSubmissionResult,\n scheduling: null,\n payment,\n })\n\n return payment\n}\n\nexport async function getFormSubmissionResultPayment(): Promise<{\n formSubmissionResult: FormSubmissionResult\n paymentSubmissionEvent: SubmissionEventTypes.FormPaymentEvent\n}> {\n const formSubmissionResult =\n await utilsService.getLocalForageItem<FormSubmissionResult | null>(KEY)\n\n if (!formSubmissionResult) {\n throw new OneBlinkAppsError(\n 'It looks like you are attempting to complete a transaction for an unknown payment.',\n )\n }\n if (!formSubmissionResult.payment?.submissionEvent) {\n throw new OneBlinkAppsError(\n 'It looks like you are attempting to complete a transaction for a misconfigured payment.',\n )\n }\n\n return {\n formSubmissionResult,\n paymentSubmissionEvent: formSubmissionResult.payment?.submissionEvent,\n }\n}\n\n/**\n * Retrieve an array of detail items from a form submission payment.\n *\n * #### Example\n *\n * ```js\n * const detailItems =\n * paymentService.getDisplayDetailsFromFormSubmissionPayment(\n * formSubmissionPayment,\n * )\n * ```\n *\n * @param formSubmissionPayment\n * @returns\n */\nexport function getDisplayDetailsFromFormSubmissionPayment(\n formSubmissionPayment: SubmissionTypes.FormSubmissionPayment,\n) {\n return paymentService.getDisplayDetailsFromFormSubmissionPayment(\n formSubmissionPayment,\n replaceSubmissionFormatters,\n )\n}\n"]}
|
|
1
|
+
{"version":3,"file":"payment-service.js","sourceRoot":"","sources":["../../src/apps/payment-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,iBAAiB,MAAM,qCAAqC,CAAA;AACnE,OAAO,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAA;AACnE,OAAO,YAAY,MAAM,kBAAkB,CAAA;AAQ3C,OAAO,qBAAqB,MAAM,oDAAoD,CAAA;AACtF,OAAO,oBAAoB,MAAM,mDAAmD,CAAA;AACpF,OAAO,wBAAwB,MAAM,uDAAuD,CAAA;AAC5F,OAAO,iCAAiC,EAAE,KAAK,kBAAkB,MAAM,gEAAgE,CAAA;AACvI,OAAO,EACL,aAAa,EACb,QAAQ,EACR,gBAAgB,EAChB,UAAU,EACV,2BAA2B,GAC5B,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,2BAA2B,GAG5B,MAAM,4BAA4B,CAAA;AACnC,OAAO,EACL,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,+BAA+B,CAAA;AAEtC,MAAM,GAAG,GAAG,2BAA2B,CAAA;AAEvC,OAAO,EAA2C,kBAAkB,EAAE,CAAA;AACtE,OAAO,EAAE,2BAA2B,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,CAAA;AAGhF;;;;GAIG;AACH,SAAS,uBAA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;KACpC,CAAA;IACD,OAAO,CAAC,GAAG,CAAC,oDAAoD,EAAE,OAAO,CAAC,CAAA;IAE1E,MAAM,YAAY,CAAC,kBAAkB,CAAC,GAAG,EAAE;QACzC,GAAG,oBAAoB;QACvB,UAAU,EAAE,IAAI;QAChB,OAAO;KACR,CAAC,CAAA;IAEF,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,8BAA8B;;IAIlD,MAAM,oBAAoB,GACxB,MAAM,YAAY,CAAC,kBAAkB,CAA8B,GAAG,CAAC,CAAA;IAEzE,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAC1B,MAAM,IAAI,iBAAiB,CACzB,oFAAoF,CACrF,CAAA;IACH,CAAC;IACD,IAAI,CAAC,CAAA,MAAA,oBAAoB,CAAC,OAAO,0CAAE,eAAe,CAAA,EAAE,CAAC;QACnD,MAAM,IAAI,iBAAiB,CACzB,yFAAyF,CAC1F,CAAA;IACH,CAAC;IAED,OAAO;QACL,oBAAoB;QACpB,sBAAsB,EAAE,MAAA,oBAAoB,CAAC,OAAO,0CAAE,eAAe;KACtE,CAAA;AACH,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,0CAA0C,CACxD,qBAA4D;IAE5D,OAAO,cAAc,CAAC,0CAA0C,CAC9D,qBAAqB,EACrB,2BAA2B,CAC5B,CAAA;AACH,CAAC","sourcesContent":["import { paymentService } from '@oneblink/sdk-core'\nimport OneBlinkAppsError from './services/errors/oneBlinkAppsError'\nimport { createPaymentConfiguration } from './services/api/payment'\nimport utilsService from './services/utils'\nimport { SubmissionEventTypes, SubmissionTypes } from '@oneblink/types'\nimport { FormSubmission, FormSubmissionResult } from './types/submissions'\nimport {\n HandlePaymentResult,\n PaymentProvider,\n PaymentReceiptItem,\n} from './types/payments'\nimport BPOINTPaymentProvider from './services/payment-providers/BPOINTPaymentProvider'\nimport CPPayPaymentProvider from './services/payment-providers/CPPayPaymentProvider'\nimport NSWGovPayPaymentProvider from './services/payment-providers/NSWGovPayPaymentProvider'\nimport WestpacQuickStreamPaymentProvider, * as westpacQuickStream from './services/payment-providers/WestpacQuickStreamPaymentProvider'\nimport {\n addDaysToDate,\n endOfDay,\n parseDayOnlyDate,\n startOfDay,\n replaceSubmissionFormatters,\n} from './localisation-service'\nimport {\n getPaymentFormSession,\n getPaymentHandoff,\n paymentProviderRendersInApp,\n type InAppPaymentType,\n type PaymentFormSession,\n} from './services/payment-handoff'\nimport {\n getSchedulingBooking,\n removeSchedulingBooking,\n} from './services/schedulingHandlers'\n\nconst KEY = 'PAYMENT_SUBMISSION_RESULT'\n\nexport { HandlePaymentResult, PaymentReceiptItem, westpacQuickStream }\nexport { paymentProviderRendersInApp, getPaymentHandoff, getPaymentFormSession }\nexport type { InAppPaymentType, PaymentFormSession }\n\n/**\n * Receipt URLs for providers whose payment form is rendered by the app. Add a\n * new in-app provider here so hosts of that form can redirect to a receipt\n * without knowing which provider took the payment.\n */\nfunction getInAppPaymentReceipts(formSubmissionResult: FormSubmissionResult) {\n const paymentType = formSubmissionResult.payment?.submissionEvent.type\n if (!paymentType || !paymentProviderRendersInApp(paymentType)) {\n throw new OneBlinkAppsError(\n 'It looks like you are attempting to view a receipt for an unsupported payment.',\n )\n }\n\n switch (paymentType) {\n case 'WESTPAC_QUICK_STREAM': {\n return westpacQuickStream\n }\n default: {\n const unsupportedPaymentType: never = paymentType\n throw new OneBlinkAppsError(\n `It looks like you are attempting to view a receipt for an unsupported payment (${unsupportedPaymentType}).`,\n )\n }\n }\n}\n\n/**\n * Get the receipt URL for a completed in-app payment. The receipt page verifies\n * the transaction from the query parameters on this URL.\n *\n * @param options\n * @returns\n */\nexport function getCompletedPaymentReceiptUrl(options: {\n formSubmissionResult: FormSubmissionResult\n formSubmissionPayment: SubmissionTypes.FormSubmissionPayment\n}): string {\n return getInAppPaymentReceipts(\n options.formSubmissionResult,\n ).getCompletedPaymentReceiptUrl(options)\n}\n\n/**\n * Get the receipt URL for a cancelled in-app payment.\n *\n * @param formSubmissionResult\n * @param formSubmissionPaymentId\n * @returns\n */\nexport function getCancelledPaymentReceiptUrl(\n formSubmissionResult: FormSubmissionResult,\n formSubmissionPaymentId: string,\n): string {\n return getInAppPaymentReceipts(\n formSubmissionResult,\n ).getCancelledPaymentReceiptUrl(formSubmissionResult, formSubmissionPaymentId)\n}\n\nfunction getPaymentProvider(\n formSubmissionResult: FormSubmissionResult,\n paymentSubmissionEvent: SubmissionEventTypes.FormPaymentEvent,\n): PaymentProvider<SubmissionEventTypes.FormPaymentEvent> {\n switch (paymentSubmissionEvent.type) {\n case 'BPOINT': {\n return new BPOINTPaymentProvider(\n paymentSubmissionEvent,\n formSubmissionResult,\n )\n }\n case 'CP_PAY': {\n return new CPPayPaymentProvider(\n paymentSubmissionEvent,\n formSubmissionResult,\n )\n }\n case 'NSW_GOV_PAY': {\n return new NSWGovPayPaymentProvider(\n paymentSubmissionEvent,\n formSubmissionResult,\n )\n }\n case 'WESTPAC_QUICK_STREAM': {\n return new WestpacQuickStreamPaymentProvider(\n paymentSubmissionEvent,\n formSubmissionResult,\n )\n }\n }\n}\n\n/**\n * Pass in query string parameters after a redirect back to your app after a\n * payment is processed. This function will handle all payment submission events\n * supported by OneBlink. Will return a Transaction and the submission result\n * that was returned from `handlePaymentSubmissionEvent()` before redirecting to\n * `payment.hostedFormUrl`.\n *\n * #### Example\n *\n * ```js\n * import queryString from 'query-string'\n *\n * const query = queryString.parse(window.location.search)\n * const { transaction, submissionResult } =\n * await paymentService.handlePaymentQuerystring(query)\n * ```\n *\n * @param query\n * @returns\n */\nexport async function handlePaymentQuerystring(\n query: Record<string, unknown>,\n): Promise<HandlePaymentResult> {\n const submissionResult =\n await utilsService.getLocalForageItem<FormSubmissionResult | null>(KEY)\n // If the current transaction does not match the submission\n // we will display message to user indicating\n // they are looking for the wrong transaction receipt.\n if (!submissionResult) {\n throw new OneBlinkAppsError(\n 'It looks like you are attempting to view a receipt for an unknown payment.',\n )\n }\n if (!submissionResult.payment || !submissionResult.payment.submissionEvent) {\n throw new OneBlinkAppsError(\n 'It looks like you are attempting to view a receipt for a misconfigured payment.',\n )\n }\n const paymentProvider = getPaymentProvider(\n submissionResult,\n submissionResult.payment.submissionEvent,\n )\n if (!paymentProvider) {\n throw new OneBlinkAppsError(\n 'It looks like you are attempting to view a receipt for an unsupported payment.',\n )\n }\n\n const verifiedPaymentTransaction =\n await paymentProvider.verifyPaymentTransaction(query)\n\n const schedulingBooking = await getSchedulingBooking(\n verifiedPaymentTransaction.submissionResult.submissionId,\n )\n if (schedulingBooking && verifiedPaymentTransaction.transaction.isSuccess) {\n await removeSchedulingBooking(schedulingBooking.submissionId)\n }\n\n return {\n ...verifiedPaymentTransaction,\n schedulingBooking,\n }\n}\n\nexport function checkForPaymentSubmissionEvent(\n formSubmission: FormSubmission,\n submissionTimestamp: string,\n): SubmissionEventTypes.FormPaymentEvent | undefined {\n const result = paymentService.checkForPaymentEvent({\n definition: formSubmission.definition,\n submission: formSubmission.submission,\n submissionTimestamp,\n parseDayOnlyDate,\n addDaysToDate,\n startOfDay,\n endOfDay,\n })\n if (result) {\n console.log('Form has a payment submission event with amount', result)\n return result.paymentSubmissionEvent\n }\n return undefined\n}\n\n/**\n * Handle a submission result with a payment submission event. Will throw an\n * error if a transaction has already been made using this submission result.\n * Will return `undefined` if the submission does not have an amount. Will\n * return the submission result passed in with a `payment` property if the\n * submission requires processing.\n *\n * #### Example\n *\n * ```js\n * const formSubmissionResult = {\n * submissionId: '89c6e98e-f56f-45fc-84fe-c4fc62331d34',\n * submissionTimestamp: '2020-07-29T01:03:26.573Z'\n * formsAppId: 1,\n * submission: {\n * form: 'data',\n * goes: 'here',\n * amount: 1.50,\n * }\n * definition: OneBlinkForm,\n * payment: null,\n * }\n * const paymentSubmissionEvent = {\n * type: 'CP_PAY',\n * configuration: {\n * elementId: '12663efc-4c6a-4e72-8505-559edfe3e92e',\n * gatewayId: '6658c5c4-e0db-483b-8af7-6a6464fe772c',\n * },\n * }\n * const paymentReceiptUrl = `${window.location.origin}/payment-receipt`\n * const paymentSubmissionResult = await paymentService.handlePaymentSubmissionEvent({\n * formSubmissionResult,\n * paymentSubmissionEvent,\n * paymentReceiptUrl,\n * })\n * if (paymentSubmissionResult) {\n * window.location.href = paymentSubmissionResult.payment.hostedFormUrl\n * }\n * ```\n *\n * @param options\n * @returns\n */\nexport async function handlePaymentSubmissionEvent({\n formSubmissionResult,\n paymentReceiptUrl,\n paymentFormUrl,\n}: {\n formSubmissionResult: FormSubmissionResult\n paymentReceiptUrl: string\n paymentFormUrl: string | undefined\n}): Promise<FormSubmissionResult['payment']> {\n if (!formSubmissionResult.submissionId) {\n throw new OneBlinkAppsError(\n 'It looks like you are attempting to make a payment for an unknown submission.',\n )\n }\n const paymentConfiguration = await createPaymentConfiguration(\n formSubmissionResult.submissionId,\n { redirectUrl: paymentReceiptUrl, paymentFormUrl },\n )\n\n if (!paymentConfiguration) {\n await utilsService.setLocalForageItem(KEY, {\n ...formSubmissionResult,\n scheduling: null,\n payment: null,\n })\n return null\n }\n\n const payment = {\n submissionEvent: paymentConfiguration.paymentSubmissionEvent,\n paymentReceiptUrl,\n hostedFormUrl: paymentConfiguration.hostedFormUrl,\n paymentFormUrl,\n amount: paymentConfiguration.amount,\n }\n console.log('Created Payment configuration to start transaction', payment)\n\n await utilsService.setLocalForageItem(KEY, {\n ...formSubmissionResult,\n scheduling: null,\n payment,\n })\n\n return payment\n}\n\nexport async function getFormSubmissionResultPayment(): Promise<{\n formSubmissionResult: FormSubmissionResult\n paymentSubmissionEvent: SubmissionEventTypes.FormPaymentEvent\n}> {\n const formSubmissionResult =\n await utilsService.getLocalForageItem<FormSubmissionResult | null>(KEY)\n\n if (!formSubmissionResult) {\n throw new OneBlinkAppsError(\n 'It looks like you are attempting to complete a transaction for an unknown payment.',\n )\n }\n if (!formSubmissionResult.payment?.submissionEvent) {\n throw new OneBlinkAppsError(\n 'It looks like you are attempting to complete a transaction for a misconfigured payment.',\n )\n }\n\n return {\n formSubmissionResult,\n paymentSubmissionEvent: formSubmissionResult.payment?.submissionEvent,\n }\n}\n\n/**\n * Retrieve an array of detail items from a form submission payment.\n *\n * #### Example\n *\n * ```js\n * const detailItems =\n * paymentService.getDisplayDetailsFromFormSubmissionPayment(\n * formSubmissionPayment,\n * )\n * ```\n *\n * @param formSubmissionPayment\n * @returns\n */\nexport function getDisplayDetailsFromFormSubmissionPayment(\n formSubmissionPayment: SubmissionTypes.FormSubmissionPayment,\n) {\n return paymentService.getDisplayDetailsFromFormSubmissionPayment(\n formSubmissionPayment,\n replaceSubmissionFormatters,\n )\n}\n"]}
|
|
@@ -9,7 +9,11 @@ declare function completeWestpacQuickStreamTransaction(formId: number, payload:
|
|
|
9
9
|
integrationEnvironmentId: string;
|
|
10
10
|
customerReferenceNumber: string;
|
|
11
11
|
principalAmount: number;
|
|
12
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Required for payments started from a form submission. Not used for
|
|
14
|
+
* approval payments.
|
|
15
|
+
*/
|
|
16
|
+
recaptcha?: NonNullable<NewFormSubmission['recaptchas']>[number];
|
|
13
17
|
}, abortSignal?: AbortSignal): Promise<{
|
|
14
18
|
formSubmissionPayment: SubmissionTypes.FormSubmissionPayment;
|
|
15
19
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payment.js","sourceRoot":"","sources":["../../../../src/apps/services/api/payment.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAC5E,OAAO,iBAAiB,MAAM,6BAA6B,CAAA;AAC3D,OAAO,OAAO,MAAM,eAAe,CAAA;AACnC,OAAO,MAAM,MAAM,cAAc,CAAA;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAGjD,KAAK,UAAU,iCAAiC,CAC9C,IAAY,EACZ,EACE,wBAAwB,GAGzB,EACD,WAAyB;IAEzB,MAAM,GAAG,GAAG,IAA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iBAAiB,CACzB,gFAAgF,EAChF;oBACE,aAAa,EAAE,KAAK;oBACpB,cAAc,EAAE,KAAK,CAAC,MAAM;iBAC7B,CACF,CAAA;YACH,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AAED,OAAO,EACL,2BAA2B,EAC3B,wBAAwB,EACxB,iCAAiC,EACjC,qCAAqC,EACrC,+BAA+B,EAC/B,0BAA0B,GAC3B,CAAA","sourcesContent":["import { SubmissionEventTypes, SubmissionTypes } from '@oneblink/types'\nimport { HTTPError, deleteRequest, getRequest, postRequest } from '../fetch'\nimport OneBlinkAppsError from '../errors/oneBlinkAppsError'\nimport tenants from '../../tenants'\nimport Sentry from '../../Sentry'\nimport { isOffline } from '../../offline-service'\nimport { NewFormSubmission } from '../../submission-service'\n\nasync function getCustomFormPaymentConfiguration<T>(\n path: string,\n {\n integrationEnvironmentId,\n }: {\n integrationEnvironmentId: string\n },\n abortSignal?: AbortSignal,\n) {\n const url = new URL(path, tenants.current.apiOrigin)\n url.searchParams.append('integrationEnvironmentId', integrationEnvironmentId)\n\n console.log('Attempting to get payment configuration', url.href)\n\n try {\n return await getRequest<T>(url.href, abortSignal)\n } catch (err) {\n const error = err as HTTPError\n Sentry.captureException(error)\n console.warn(\n 'Error occurred while attempting to retrieve configuration for payment',\n error,\n )\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot retrieve payment configuration until you have logged in. Please login and try again.',\n {\n originalError: error,\n httpStatusCode: error.status,\n requiresLogin: true,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access retrieve payment configuration. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n httpStatusCode: error.status,\n requiresAccessRequest: true,\n },\n )\n }\n case 400:\n case 404: {\n throw new OneBlinkAppsError(\n 'We could not find the payment configuration. Please contact your administrator to ensure your application configuration has been completed successfully.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n }\n}\n\nasync function completeWestpacQuickStreamTransaction(\n formId: number,\n payload: {\n formSubmissionPaymentId: string\n singleUseTokenId: string\n integrationEnvironmentId: string\n customerReferenceNumber: string\n principalAmount: number\n recaptcha: NonNullable<NewFormSubmission['recaptchas']>[number]\n },\n abortSignal?: AbortSignal,\n) {\n const url = `${tenants.current.apiOrigin}/forms/${formId}/westpac-quick-stream-transaction`\n console.log('Attempting to complete Westpac QuickStream transaction', url)\n try {\n return await postRequest<{\n formSubmissionPayment: SubmissionTypes.FormSubmissionPayment\n }>(url, payload, abortSignal)\n } catch (err) {\n const error = err as HTTPError\n Sentry.captureException(error)\n console.warn(\n 'Error occurred while attempting to generate configuration for payment',\n error,\n )\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot complete transactions until you have logged in. Please login and try again.',\n {\n originalError: error,\n httpStatusCode: error.status,\n requiresLogin: true,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access complete transactions. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n httpStatusCode: error.status,\n requiresAccessRequest: true,\n },\n )\n }\n case 400:\n case 404: {\n throw new OneBlinkAppsError(\n 'We could not find the configuration required to complete a transaction. Please contact your administrator to ensure your application configuration has been completed successfully.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n }\n}\n\nasync function cancelWestpacQuickStreamPayment(\n formId: number,\n formSubmissionPaymentId: string,\n abortSignal?: AbortSignal,\n) {\n try {\n const url = `${tenants.current.apiOrigin}/forms/${formId}/westpac-quick-stream-payment/${formSubmissionPaymentId}`\n console.log('Attempting to cancel Westpac QuickStream payment', url)\n return await deleteRequest(url, abortSignal)\n } catch (error) {\n Sentry.captureException(error)\n\n const httpError = error as HTTPError\n if (isOffline()) {\n throw new OneBlinkAppsError(\n 'You are currently offline, please connect to the internet to continue',\n {\n originalError: httpError,\n isOffline: true,\n },\n )\n }\n switch (httpError.status) {\n case 400:\n case 404: {\n throw new OneBlinkAppsError(\n 'We could not find the form you are looking for. Please contact support if the problem persists.',\n {\n originalError: httpError,\n title: 'Unknown Form',\n httpStatusCode: httpError.status,\n },\n )\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: httpError,\n httpStatusCode: httpError.status,\n },\n )\n }\n }\n }\n}\n\nasync function createPaymentConfiguration(\n submissionId: string,\n payload: { redirectUrl: string; paymentFormUrl: string | undefined },\n) {\n const url = `${tenants.current.apiOrigin}/form-submission-meta/${submissionId}/payment`\n console.log('Attempting to get payment configuration', url)\n return await postRequest<\n | {\n hostedFormUrl: string\n paymentSubmissionEvent: SubmissionEventTypes.FormPaymentEvent\n amount: number\n }\n | undefined\n >(url, payload).catch((error) => {\n Sentry.captureException(error)\n console.warn(\n 'Error occurred while attempting to generate configuration for payment',\n error,\n )\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot make payments until you have logged in. Please login and try again.',\n {\n originalError: error,\n httpStatusCode: error.status,\n requiresLogin: true,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access make payments. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n httpStatusCode: error.status,\n requiresAccessRequest: true,\n },\n )\n }\n case 400:\n case 404: {\n throw new OneBlinkAppsError(\n 'We could not find the configuration required to make a payment. Please contact your administrator to ensure your application configuration has been completed successfully.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n })\n}\n\nconst verifyPaymentTransaction = <T>(\n path: string,\n payload: unknown,\n): Promise<T> => {\n const url = `${tenants.current.apiOrigin}${path}`\n console.log('Attempting to verify payment transaction', url)\n return postRequest<T>(url, payload).catch((error) => {\n Sentry.captureException(error)\n console.warn(\n 'Error occurred while attempting to verify a transaction',\n error,\n )\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot verify a transaction until you have logged in. Please login and try again.',\n {\n originalError: error,\n httpStatusCode: error.status,\n requiresLogin: true,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access to verify your transactions. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n httpStatusCode: error.status,\n requiresAccessRequest: true,\n },\n )\n }\n case 400:\n case 404: {\n throw new OneBlinkAppsError(\n 'We could not find the configuration required to verify your transaction. Please contact your administrator to ensure your application configuration has been completed successfully.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n })\n}\n\nconst acknowledgeCPPayTransaction = async (\n formId: number,\n payload: unknown,\n): Promise<void> => {\n const url = `${tenants.current.apiOrigin}/forms/${formId}/cp-pay-acknowledge`\n console.log('Attempting to acknowledge CP Pay transaction', url)\n await postRequest(url, payload).catch((error) => {\n Sentry.captureException(error)\n console.warn(\n 'Error occurred while attempting to acknowledge a CP Pay transaction',\n error,\n )\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot acknowledge a transaction until you have logged in. Please login and try again.',\n {\n originalError: error,\n httpStatusCode: error.status,\n requiresLogin: true,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access to acknowledge your transactions. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n httpStatusCode: error.status,\n requiresAccessRequest: true,\n },\n )\n }\n case 400:\n case 404: {\n throw new OneBlinkAppsError(\n 'We could not find the configuration required to acknowledge your transaction. Please contact your administrator to ensure your application configuration has been completed successfully.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n })\n}\n\nexport {\n acknowledgeCPPayTransaction,\n verifyPaymentTransaction,\n getCustomFormPaymentConfiguration,\n completeWestpacQuickStreamTransaction,\n cancelWestpacQuickStreamPayment,\n createPaymentConfiguration,\n}\n"]}
|
|
1
|
+
{"version":3,"file":"payment.js","sourceRoot":"","sources":["../../../../src/apps/services/api/payment.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAC5E,OAAO,iBAAiB,MAAM,6BAA6B,CAAA;AAC3D,OAAO,OAAO,MAAM,eAAe,CAAA;AACnC,OAAO,MAAM,MAAM,cAAc,CAAA;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAGjD,KAAK,UAAU,iCAAiC,CAC9C,IAAY,EACZ,EACE,wBAAwB,GAGzB,EACD,WAAyB;IAEzB,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;IACpD,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,0BAA0B,EAAE,wBAAwB,CAAC,CAAA;IAE7E,OAAO,CAAC,GAAG,CAAC,yCAAyC,EAAE,GAAG,CAAC,IAAI,CAAC,CAAA;IAEhE,IAAI,CAAC;QACH,OAAO,MAAM,UAAU,CAAI,GAAG,CAAC,IAAI,EAAE,WAAW,CAAC,CAAA;IACnD,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,KAAK,GAAG,GAAgB,CAAA;QAC9B,MAAM,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAA;QAC9B,OAAO,CAAC,IAAI,CACV,uEAAuE,EACvE,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B,OAAO,CAAC,IAAI,CACV,qEAAqE,EACrE,KAAK,CACN,CAAA;QACD,QAAQ,KAAK,CAAC,MAAM,EAAE,CAAC;YACrB,KAAK,GAAG,CAAC,CAAC,CAAC;gBACT,MAAM,IAAI,iBAAiB,CACzB,4FAA4F,EAC5F;oBACE,aAAa,EAAE,KAAK;oBACpB,cAAc,EAAE,KAAK,CAAC,MAAM;oBAC5B,aAAa,EAAE,IAAI;iBACpB,CACF,CAAA;YACH,CAAC;YACD,KAAK,GAAG,CAAC,CAAC,CAAC;gBACT,MAAM,IAAI,iBAAiB,CACzB,iIAAiI,EACjI;oBACE,aAAa,EAAE,KAAK;oBACpB,cAAc,EAAE,KAAK,CAAC,MAAM;oBAC5B,qBAAqB,EAAE,IAAI;iBAC5B,CACF,CAAA;YACH,CAAC;YACD,KAAK,GAAG,CAAC;YACT,KAAK,GAAG,CAAC,CAAC,CAAC;gBACT,MAAM,IAAI,iBAAiB,CACzB,2LAA2L,EAC3L;oBACE,aAAa,EAAE,KAAK;oBACpB,cAAc,EAAE,KAAK,CAAC,MAAM;iBAC7B,CACF,CAAA;YACH,CAAC;YACD,OAAO,CAAC,CAAC,CAAC;gBACR,MAAM,IAAI,iBAAiB,CACzB,gFAAgF,EAChF;oBACE,aAAa,EAAE,KAAK;oBACpB,cAAc,EAAE,KAAK,CAAC,MAAM;iBAC7B,CACF,CAAA;YACH,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AAED,OAAO,EACL,2BAA2B,EAC3B,wBAAwB,EACxB,iCAAiC,EACjC,qCAAqC,EACrC,+BAA+B,EAC/B,0BAA0B,GAC3B,CAAA","sourcesContent":["import { SubmissionEventTypes, SubmissionTypes } from '@oneblink/types'\nimport { HTTPError, deleteRequest, getRequest, postRequest } from '../fetch'\nimport OneBlinkAppsError from '../errors/oneBlinkAppsError'\nimport tenants from '../../tenants'\nimport Sentry from '../../Sentry'\nimport { isOffline } from '../../offline-service'\nimport { NewFormSubmission } from '../../submission-service'\n\nasync function getCustomFormPaymentConfiguration<T>(\n path: string,\n {\n integrationEnvironmentId,\n }: {\n integrationEnvironmentId: string\n },\n abortSignal?: AbortSignal,\n) {\n const url = new URL(path, tenants.current.apiOrigin)\n url.searchParams.append('integrationEnvironmentId', integrationEnvironmentId)\n\n console.log('Attempting to get payment configuration', url.href)\n\n try {\n return await getRequest<T>(url.href, abortSignal)\n } catch (err) {\n const error = err as HTTPError\n Sentry.captureException(error)\n console.warn(\n 'Error occurred while attempting to retrieve configuration for payment',\n error,\n )\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot retrieve payment configuration until you have logged in. Please login and try again.',\n {\n originalError: error,\n httpStatusCode: error.status,\n requiresLogin: true,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access retrieve payment configuration. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n httpStatusCode: error.status,\n requiresAccessRequest: true,\n },\n )\n }\n case 400:\n case 404: {\n throw new OneBlinkAppsError(\n 'We could not find the payment configuration. Please contact your administrator to ensure your application configuration has been completed successfully.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n }\n}\n\nasync function completeWestpacQuickStreamTransaction(\n formId: number,\n payload: {\n formSubmissionPaymentId: string\n singleUseTokenId: string\n integrationEnvironmentId: string\n customerReferenceNumber: string\n principalAmount: number\n /**\n * Required for payments started from a form submission. Not used for\n * approval payments.\n */\n recaptcha?: NonNullable<NewFormSubmission['recaptchas']>[number]\n },\n abortSignal?: AbortSignal,\n) {\n const url = `${tenants.current.apiOrigin}/forms/${formId}/westpac-quick-stream-transaction`\n console.log('Attempting to complete Westpac QuickStream transaction', url)\n try {\n return await postRequest<{\n formSubmissionPayment: SubmissionTypes.FormSubmissionPayment\n }>(url, payload, abortSignal)\n } catch (err) {\n const error = err as HTTPError\n Sentry.captureException(error)\n console.warn(\n 'Error occurred while attempting to generate configuration for payment',\n error,\n )\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot complete transactions until you have logged in. Please login and try again.',\n {\n originalError: error,\n httpStatusCode: error.status,\n requiresLogin: true,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access complete transactions. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n httpStatusCode: error.status,\n requiresAccessRequest: true,\n },\n )\n }\n case 400:\n case 404: {\n throw new OneBlinkAppsError(\n 'We could not find the configuration required to complete a transaction. Please contact your administrator to ensure your application configuration has been completed successfully.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n }\n}\n\nasync function cancelWestpacQuickStreamPayment(\n formId: number,\n formSubmissionPaymentId: string,\n abortSignal?: AbortSignal,\n) {\n try {\n const url = `${tenants.current.apiOrigin}/forms/${formId}/westpac-quick-stream-payment/${formSubmissionPaymentId}`\n console.log('Attempting to cancel Westpac QuickStream payment', url)\n return await deleteRequest(url, abortSignal)\n } catch (error) {\n Sentry.captureException(error)\n\n const httpError = error as HTTPError\n if (isOffline()) {\n throw new OneBlinkAppsError(\n 'You are currently offline, please connect to the internet to continue',\n {\n originalError: httpError,\n isOffline: true,\n },\n )\n }\n switch (httpError.status) {\n case 400:\n case 404: {\n throw new OneBlinkAppsError(\n 'We could not find the form you are looking for. Please contact support if the problem persists.',\n {\n originalError: httpError,\n title: 'Unknown Form',\n httpStatusCode: httpError.status,\n },\n )\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: httpError,\n httpStatusCode: httpError.status,\n },\n )\n }\n }\n }\n}\n\nasync function createPaymentConfiguration(\n submissionId: string,\n payload: { redirectUrl: string; paymentFormUrl: string | undefined },\n) {\n const url = `${tenants.current.apiOrigin}/form-submission-meta/${submissionId}/payment`\n console.log('Attempting to get payment configuration', url)\n return await postRequest<\n | {\n hostedFormUrl: string\n paymentSubmissionEvent: SubmissionEventTypes.FormPaymentEvent\n amount: number\n }\n | undefined\n >(url, payload).catch((error) => {\n Sentry.captureException(error)\n console.warn(\n 'Error occurred while attempting to generate configuration for payment',\n error,\n )\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot make payments until you have logged in. Please login and try again.',\n {\n originalError: error,\n httpStatusCode: error.status,\n requiresLogin: true,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access make payments. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n httpStatusCode: error.status,\n requiresAccessRequest: true,\n },\n )\n }\n case 400:\n case 404: {\n throw new OneBlinkAppsError(\n 'We could not find the configuration required to make a payment. Please contact your administrator to ensure your application configuration has been completed successfully.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n })\n}\n\nconst verifyPaymentTransaction = <T>(\n path: string,\n payload: unknown,\n): Promise<T> => {\n const url = `${tenants.current.apiOrigin}${path}`\n console.log('Attempting to verify payment transaction', url)\n return postRequest<T>(url, payload).catch((error) => {\n Sentry.captureException(error)\n console.warn(\n 'Error occurred while attempting to verify a transaction',\n error,\n )\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot verify a transaction until you have logged in. Please login and try again.',\n {\n originalError: error,\n httpStatusCode: error.status,\n requiresLogin: true,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access to verify your transactions. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n httpStatusCode: error.status,\n requiresAccessRequest: true,\n },\n )\n }\n case 400:\n case 404: {\n throw new OneBlinkAppsError(\n 'We could not find the configuration required to verify your transaction. Please contact your administrator to ensure your application configuration has been completed successfully.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n })\n}\n\nconst acknowledgeCPPayTransaction = async (\n formId: number,\n payload: unknown,\n): Promise<void> => {\n const url = `${tenants.current.apiOrigin}/forms/${formId}/cp-pay-acknowledge`\n console.log('Attempting to acknowledge CP Pay transaction', url)\n await postRequest(url, payload).catch((error) => {\n Sentry.captureException(error)\n console.warn(\n 'Error occurred while attempting to acknowledge a CP Pay transaction',\n error,\n )\n switch (error.status) {\n case 401: {\n throw new OneBlinkAppsError(\n 'You cannot acknowledge a transaction until you have logged in. Please login and try again.',\n {\n originalError: error,\n httpStatusCode: error.status,\n requiresLogin: true,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access to acknowledge your transactions. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n httpStatusCode: error.status,\n requiresAccessRequest: true,\n },\n )\n }\n case 400:\n case 404: {\n throw new OneBlinkAppsError(\n 'We could not find the configuration required to acknowledge your transaction. Please contact your administrator to ensure your application configuration has been completed successfully.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n })\n}\n\nexport {\n acknowledgeCPPayTransaction,\n verifyPaymentTransaction,\n getCustomFormPaymentConfiguration,\n completeWestpacQuickStreamTransaction,\n cancelWestpacQuickStreamPayment,\n createPaymentConfiguration,\n}\n"]}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export declare function generateHeaders(): Promise<Record<string, string>>;
|
|
2
2
|
export declare class HTTPError extends Error {
|
|
3
3
|
status: number;
|
|
4
|
-
|
|
4
|
+
/** Machine-readable conflict from the API error payload, when present. */
|
|
5
|
+
conflict?: string;
|
|
6
|
+
constructor(statusCode: number, message: string, conflict?: string);
|
|
5
7
|
}
|
|
6
8
|
export declare const fetchWithError: typeof fetch;
|
|
7
9
|
export declare function fetchJSON<T>(url: string, options?: RequestInit): Promise<T>;
|