@oneblink/apps-react 13.5.1-beta.4 → 13.6.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.
Files changed (49) hide show
  1. package/dist/PaymentReceipt.js +25 -158
  2. package/dist/PaymentReceipt.js.map +1 -1
  3. package/dist/apps/approvals-service.d.ts +102 -1
  4. package/dist/apps/approvals-service.js +137 -1
  5. package/dist/apps/approvals-service.js.map +1 -1
  6. package/dist/apps/payment-service.d.ts +39 -0
  7. package/dist/apps/payment-service.js +67 -6
  8. package/dist/apps/payment-service.js.map +1 -1
  9. package/dist/apps/services/api/payment.d.ts +5 -1
  10. package/dist/apps/services/api/payment.js.map +1 -1
  11. package/dist/apps/services/fetch.d.ts +3 -1
  12. package/dist/apps/services/fetch.js +16 -4
  13. package/dist/apps/services/fetch.js.map +1 -1
  14. package/dist/apps/services/payment-handoff.d.ts +47 -0
  15. package/dist/apps/services/payment-handoff.js +79 -0
  16. package/dist/apps/services/payment-handoff.js.map +1 -0
  17. package/dist/apps/services/payment-providers/WestpacQuickStreamPaymentProvider.d.ts +35 -19
  18. package/dist/apps/services/payment-providers/WestpacQuickStreamPaymentProvider.js +41 -27
  19. package/dist/apps/services/payment-providers/WestpacQuickStreamPaymentProvider.js.map +1 -1
  20. package/dist/apps/services/payment-submission-result.d.ts +5 -0
  21. package/dist/apps/services/payment-submission-result.js +11 -0
  22. package/dist/apps/services/payment-submission-result.js.map +1 -0
  23. package/dist/apps/submission-service.js +2 -1
  24. package/dist/apps/submission-service.js.map +1 -1
  25. package/dist/components/ErrorSnackbar.js +7 -1
  26. package/dist/components/ErrorSnackbar.js.map +1 -1
  27. package/dist/components/payments/ApprovalStepPaymentReceipt.d.ts +67 -0
  28. package/dist/components/payments/ApprovalStepPaymentReceipt.js +86 -0
  29. package/dist/components/payments/ApprovalStepPaymentReceipt.js.map +1 -0
  30. package/dist/components/payments/PaymentForm.d.ts +6 -0
  31. package/dist/components/payments/PaymentForm.js +36 -35
  32. package/dist/components/payments/PaymentForm.js.map +1 -1
  33. package/dist/components/payments/SessionPaymentForm.d.ts +23 -0
  34. package/dist/components/payments/SessionPaymentForm.js +49 -0
  35. package/dist/components/payments/SessionPaymentForm.js.map +1 -0
  36. package/dist/components/payments/SessionPaymentReceipt.d.ts +15 -0
  37. package/dist/components/payments/SessionPaymentReceipt.js +149 -0
  38. package/dist/components/payments/SessionPaymentReceipt.js.map +1 -0
  39. package/dist/components/payments/WestpacQuickStreamPaymentForm.d.ts +7 -11
  40. package/dist/components/payments/WestpacQuickStreamPaymentForm.js +25 -31
  41. package/dist/components/payments/WestpacQuickStreamPaymentForm.js.map +1 -1
  42. package/dist/index.d.ts +2 -0
  43. package/dist/index.js +2 -0
  44. package/dist/index.js.map +1 -1
  45. package/dist/services/form-validation/getApproverEditableFormElementIds.js +3 -0
  46. package/dist/services/form-validation/getApproverEditableFormElementIds.js.map +1 -1
  47. package/dist/services/getFlowInstanceNodesWithMeta.js +22 -3
  48. package/dist/services/getFlowInstanceNodesWithMeta.js.map +1 -1
  49. package/package.json +3 -3
@@ -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,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,CAAC;QACD,QAAQ,KAAK,CAAC,MAAM,EAAE,CAAC;YACrB,KAAK,GAAG,CAAC,CAAC,CAAC;gBACT,MAAM,IAAI,iBAAiB,CACzB,iGAAiG,EACjG;oBACE,aAAa,EAAE,KAAK;oBACpB,aAAa,EAAE,IAAI;oBACnB,cAAc,EAAE,KAAK,CAAC,MAAM;iBAC7B,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 { 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,+BAA+B,EAAE,MAAM,sCAAsC,CAAA;AACtF,OAAO,EAAE,4BAA4B,EAAE,MAAM,0CAA0C,CAAA;AA8CvF;;;;;;;;;;;;;;;;;;;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,QAAQ,KAAK,CAAC,MAAM,EAAE,CAAC;YACrB,KAAK,GAAG,CAAC,CAAC,CAAC;gBACT,MAAM,IAAI,iBAAiB,CACzB,8FAA8F,EAC9F;oBACE,aAAa,EAAE,KAAK;oBAC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;oBACE,aAAa,EAAE,KAAK;oBACpB,aAAa,EAAE,IAAI;oBACnB,cAAc,EAAE,KAAK,CAAC,MAAM;iBAC7B,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'\nimport { rememberPaymentSubmissionResult } from './services/payment-submission-result'\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 /** True while this approval has a checkout that has not finished. */\n paymentInProgress?: boolean\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 approvalStepPayments?: 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 * Conflict code on the error thrown when an approval step already has a\n * checkout in progress.\n *\n * #### Example\n *\n * ```js\n * import {\n * approvalsService,\n * OneBlinkAppsError,\n * } from '@oneblink/apps-react'\n *\n * try {\n * await approvalsService.createApprovalStepPayment(\n * formSubmissionApprovalId,\n * {\n * redirectUrl,\n * paymentFormUrl,\n * form,\n * submissionId,\n * },\n * )\n * } catch (error) {\n * if (\n * error instanceof OneBlinkAppsError &&\n * error.conflict === approvalsService.PAYMENT_IN_PROGRESS_CONFLICT\n * ) {\n * console.log('A payment is already in progress')\n * }\n * }\n * ```\n */\nexport const PAYMENT_IN_PROGRESS_CONFLICT = 'PAYMENT_IN_PROGRESS'\n\n/**\n * Create a payment for an approval step. Returns the details needed to send the\n * user to the payment provider. When the provider redirects to `redirectUrl`,\n * the receipt for this payment can be displayed. Throws an `OneBlinkAppsError`\n * with `conflict` set to `PAYMENT_IN_PROGRESS_CONFLICT` when a checkout for\n * this step is already in progress.\n *\n * #### Example\n *\n * ```js\n * const payment = await approvalsService.createApprovalStepPayment(\n * 'd27966cc-128d-48a2-b681-6ad52012e113',\n * {\n * redirectUrl:\n * 'https://approvals.example/approvals/d27966cc-128d-48a2-b681-6ad52012e113/payment-receipt',\n * paymentFormUrl:\n * 'https://approvals.example/approvals/d27966cc-128d-48a2-b681-6ad52012e113/payment',\n * form,\n * submissionId: '89c6e98e-f56f-45fc-84fe-c4fc62331d34',\n * },\n * )\n * ```\n *\n * @param formSubmissionApprovalId\n * @param options\n * @param options.redirectUrl The URL the payment provider redirects to when the\n * payment finishes.\n * @param options.paymentFormUrl The in-app payment page. Required for providers\n * that render their payment form in the app.\n * @param options.form The form definition for this approval.\n * @param options.submissionId The submission this approval belongs to.\n * @param options.replacePendingPayment Cancel a checkout that is already in\n * progress so this payment can start. Leave unset to reject that checkout.\n * @param abortSignal\n * @returns\n */\nexport async function createApprovalStepPayment(\n formSubmissionApprovalId: string,\n options: {\n redirectUrl: string\n paymentFormUrl?: string\n form: FormTypes.Form\n submissionId: string\n replacePendingPayment?: boolean\n },\n abortSignal?: AbortSignal,\n): Promise<{\n hostedFormUrl: string\n amount: number\n paymentSubmissionEvent: SubmissionEventTypes.FormPaymentEvent\n customerReferenceNumber?: string\n}> {\n const {\n redirectUrl,\n paymentFormUrl,\n form,\n submissionId,\n replacePendingPayment,\n } = options\n let result: {\n hostedFormUrl: string\n amount: number\n paymentSubmissionEvent: SubmissionEventTypes.FormPaymentEvent\n customerReferenceNumber?: string\n }\n try {\n result = await postRequest(\n `${tenants.current.apiOrigin}/form-submission-approvals/${formSubmissionApprovalId}/payment`,\n {\n redirectUrl,\n paymentFormUrl,\n replacePendingPayment,\n },\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 await rememberPaymentSubmissionResult({\n submission: {},\n // The post-submission receipt is written for the original submitter.\n // This result has no submission to fill its injectables.\n definition: {\n ...form,\n postSubmissionReceipt: undefined,\n },\n preFillFormDataId: null,\n submissionId,\n submissionTimestamp: new Date().toISOString(),\n payment: {\n amount: result.amount,\n paymentReceiptUrl: redirectUrl,\n paymentFormUrl,\n hostedFormUrl: result.hostedFormUrl,\n submissionEvent: result.paymentSubmissionEvent,\n },\n scheduling: null,\n isInPendingQueue: false,\n isOffline: false,\n isUploadingAttachments: false,\n })\n\n return result\n}\n\n/**\n * Skip the payment for an approval step and continue the approval flow.\n *\n * #### Example\n *\n * ```js\n * const formSubmissionApproval =\n * await approvalsService.skipApprovalStepPayment(\n * 'd27966cc-128d-48a2-b681-6ad52012e113',\n * )\n * ```\n *\n * @param formSubmissionApprovalId\n * @param abortSignal\n * @returns\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\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"]}
@@ -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
@@ -94,3 +116,20 @@ export declare function getFormSubmissionResultPayment(): Promise<{
94
116
  * @returns
95
117
  */
96
118
  export declare function getDisplayDetailsFromFormSubmissionPayment(formSubmissionPayment: SubmissionTypes.FormSubmissionPayment): paymentService.PaymentDisplayDetailsResult | undefined;
119
+ /**
120
+ * Retrieve the failure message and provider response fields for a form
121
+ * submission payment. Returns an empty array unless the payment failed.
122
+ *
123
+ * #### Example
124
+ *
125
+ * ```js
126
+ * const failureDetails =
127
+ * paymentService.getFailureDetailsFromFormSubmissionPayment(
128
+ * formSubmissionPayment,
129
+ * )
130
+ * ```
131
+ *
132
+ * @param formSubmissionPayment
133
+ * @returns
134
+ */
135
+ export declare function getFailureDetailsFromFormSubmissionPayment(formSubmissionPayment: SubmissionTypes.FormSubmissionPayment): paymentService.PaymentFailureDetail[];
@@ -1,15 +1,57 @@
1
1
  import { paymentService } from '@oneblink/sdk-core';
2
2
  import OneBlinkAppsError from './services/errors/oneBlinkAppsError';
3
3
  import { createPaymentConfiguration } from './services/api/payment';
4
- import utilsService from './services/utils';
5
4
  import BPOINTPaymentProvider from './services/payment-providers/BPOINTPaymentProvider';
6
5
  import CPPayPaymentProvider from './services/payment-providers/CPPayPaymentProvider';
7
6
  import NSWGovPayPaymentProvider from './services/payment-providers/NSWGovPayPaymentProvider';
8
7
  import WestpacQuickStreamPaymentProvider, * as westpacQuickStream from './services/payment-providers/WestpacQuickStreamPaymentProvider';
9
8
  import { addDaysToDate, endOfDay, parseDayOnlyDate, startOfDay, replaceSubmissionFormatters, } from './localisation-service';
9
+ import { getPaymentFormSession, getPaymentHandoff, paymentProviderRendersInApp, } from './services/payment-handoff';
10
10
  import { getSchedulingBooking, removeSchedulingBooking, } from './services/schedulingHandlers';
11
- const KEY = 'PAYMENT_SUBMISSION_RESULT';
11
+ import { retrieveFormSubmissionResult, rememberPaymentSubmissionResult, } from './services/payment-submission-result';
12
12
  export { westpacQuickStream };
13
+ export { paymentProviderRendersInApp, getPaymentHandoff, getPaymentFormSession };
14
+ /**
15
+ * Receipt URLs for providers whose payment form is rendered by the app. Add a
16
+ * new in-app provider here so hosts of that form can redirect to a receipt
17
+ * without knowing which provider took the payment.
18
+ */
19
+ function getInAppPaymentReceipts(formSubmissionResult) {
20
+ var _a;
21
+ const paymentType = (_a = formSubmissionResult.payment) === null || _a === void 0 ? void 0 : _a.submissionEvent.type;
22
+ if (!paymentType || !paymentProviderRendersInApp(paymentType)) {
23
+ throw new OneBlinkAppsError('It looks like you are attempting to view a receipt for an unsupported payment.');
24
+ }
25
+ switch (paymentType) {
26
+ case 'WESTPAC_QUICK_STREAM': {
27
+ return westpacQuickStream;
28
+ }
29
+ default: {
30
+ const unsupportedPaymentType = paymentType;
31
+ throw new OneBlinkAppsError(`It looks like you are attempting to view a receipt for an unsupported payment (${unsupportedPaymentType}).`);
32
+ }
33
+ }
34
+ }
35
+ /**
36
+ * Get the receipt URL for a completed in-app payment. The receipt page verifies
37
+ * the transaction from the query parameters on this URL.
38
+ *
39
+ * @param options
40
+ * @returns
41
+ */
42
+ export function getCompletedPaymentReceiptUrl(options) {
43
+ return getInAppPaymentReceipts(options.formSubmissionResult).getCompletedPaymentReceiptUrl(options);
44
+ }
45
+ /**
46
+ * Get the receipt URL for a cancelled in-app payment.
47
+ *
48
+ * @param formSubmissionResult
49
+ * @param formSubmissionPaymentId
50
+ * @returns
51
+ */
52
+ export function getCancelledPaymentReceiptUrl(formSubmissionResult, formSubmissionPaymentId) {
53
+ return getInAppPaymentReceipts(formSubmissionResult).getCancelledPaymentReceiptUrl(formSubmissionResult, formSubmissionPaymentId);
54
+ }
13
55
  function getPaymentProvider(formSubmissionResult, paymentSubmissionEvent) {
14
56
  switch (paymentSubmissionEvent.type) {
15
57
  case 'BPOINT': {
@@ -47,7 +89,7 @@ function getPaymentProvider(formSubmissionResult, paymentSubmissionEvent) {
47
89
  * @returns
48
90
  */
49
91
  export async function handlePaymentQuerystring(query) {
50
- const submissionResult = await utilsService.getLocalForageItem(KEY);
92
+ const submissionResult = await retrieveFormSubmissionResult();
51
93
  // If the current transaction does not match the submission
52
94
  // we will display message to user indicating
53
95
  // they are looking for the wrong transaction receipt.
@@ -136,7 +178,7 @@ export async function handlePaymentSubmissionEvent({ formSubmissionResult, payme
136
178
  }
137
179
  const paymentConfiguration = await createPaymentConfiguration(formSubmissionResult.submissionId, { redirectUrl: paymentReceiptUrl, paymentFormUrl });
138
180
  if (!paymentConfiguration) {
139
- await utilsService.setLocalForageItem(KEY, {
181
+ await rememberPaymentSubmissionResult({
140
182
  ...formSubmissionResult,
141
183
  scheduling: null,
142
184
  payment: null,
@@ -151,7 +193,7 @@ export async function handlePaymentSubmissionEvent({ formSubmissionResult, payme
151
193
  amount: paymentConfiguration.amount,
152
194
  };
153
195
  console.log('Created Payment configuration to start transaction', payment);
154
- await utilsService.setLocalForageItem(KEY, {
196
+ await rememberPaymentSubmissionResult({
155
197
  ...formSubmissionResult,
156
198
  scheduling: null,
157
199
  payment,
@@ -160,7 +202,7 @@ export async function handlePaymentSubmissionEvent({ formSubmissionResult, payme
160
202
  }
161
203
  export async function getFormSubmissionResultPayment() {
162
204
  var _a, _b;
163
- const formSubmissionResult = await utilsService.getLocalForageItem(KEY);
205
+ const formSubmissionResult = await retrieveFormSubmissionResult();
164
206
  if (!formSubmissionResult) {
165
207
  throw new OneBlinkAppsError('It looks like you are attempting to complete a transaction for an unknown payment.');
166
208
  }
@@ -190,4 +232,23 @@ export async function getFormSubmissionResultPayment() {
190
232
  export function getDisplayDetailsFromFormSubmissionPayment(formSubmissionPayment) {
191
233
  return paymentService.getDisplayDetailsFromFormSubmissionPayment(formSubmissionPayment, replaceSubmissionFormatters);
192
234
  }
235
+ /**
236
+ * Retrieve the failure message and provider response fields for a form
237
+ * submission payment. Returns an empty array unless the payment failed.
238
+ *
239
+ * #### Example
240
+ *
241
+ * ```js
242
+ * const failureDetails =
243
+ * paymentService.getFailureDetailsFromFormSubmissionPayment(
244
+ * formSubmissionPayment,
245
+ * )
246
+ * ```
247
+ *
248
+ * @param formSubmissionPayment
249
+ * @returns
250
+ */
251
+ export function getFailureDetailsFromFormSubmissionPayment(formSubmissionPayment) {
252
+ return paymentService.getFailureDetailsFromFormSubmissionPayment(formSubmissionPayment);
253
+ }
193
254
  //# sourceMappingURL=payment-service.js.map
@@ -1 +1 @@
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,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,+BAA+B,CAAA;AAEtC,MAAM,GAAG,GAAG,2BAA2B,CAAA;AAEvC,OAAO,EAA2C,kBAAkB,EAAE,CAAA;AAEtE,SAAS,kBAAkB,CACzB,oBAA0C,EAC1C,sBAA6D;IAE7D,QAAQ,sBAAsB,CAAC,IAAI,EAAE,CAAC;QACpC,KAAK,QAAQ,CAAC,CAAC,CAAC;YACd,OAAO,IAAI,qBAAqB,CAC9B,sBAAsB,EACtB,oBAAoB,CACrB,CAAA;QACH,CAAC;QACD,KAAK,QAAQ,CAAC,CAAC,CAAC;YACd,OAAO,IAAI,oBAAoB,CAC7B,sBAAsB,EACtB,oBAAoB,CACrB,CAAA;QACH,CAAC;QACD,KAAK,aAAa,CAAC,CAAC,CAAC;YACnB,OAAO,IAAI,wBAAwB,CACjC,sBAAsB,EACtB,oBAAoB,CACrB,CAAA;QACH,CAAC;QACD,KAAK,sBAAsB,CAAC,CAAC,CAAC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B,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 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;AAQnE,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;AACtC,OAAO,EACL,4BAA4B,EAC5B,+BAA+B,GAChC,MAAM,sCAAsC,CAAA;AAE7C,OAAO,EAA2C,kBAAkB,EAAE,CAAA;AACtE,OAAO,EAAE,2BAA2B,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,CAAA;AAGhF;;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CAAC,GAAG,CAAC,oDAAoD,EAAE,OAAO,CAAC,CAAA;IAE1E,MAAM,+BAA+B,CAAC;QACpC,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,GAAG,MAAM,4BAA4B,EAAE,CAAA;IAEjE,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;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,0CAA0C,CACxD,qBAA4D;IAE5D,OAAO,cAAc,CAAC,0CAA0C,CAC9D,qBAAqB,CACtB,CAAA;AACH,CAAC","sourcesContent":["import { paymentService } from '@oneblink/sdk-core'\nimport OneBlinkAppsError from './services/errors/oneBlinkAppsError'\nimport { createPaymentConfiguration } from './services/api/payment'\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'\nimport {\n retrieveFormSubmissionResult,\n rememberPaymentSubmissionResult,\n} from './services/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 = await retrieveFormSubmissionResult()\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 rememberPaymentSubmissionResult({\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 rememberPaymentSubmissionResult({\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 = await retrieveFormSubmissionResult()\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\n/**\n * Retrieve the failure message and provider response fields for a form\n * submission payment. Returns an empty array unless the payment failed.\n *\n * #### Example\n *\n * ```js\n * const failureDetails =\n * paymentService.getFailureDetailsFromFormSubmissionPayment(\n * formSubmissionPayment,\n * )\n * ```\n *\n * @param formSubmissionPayment\n * @returns\n */\nexport function getFailureDetailsFromFormSubmissionPayment(\n formSubmissionPayment: SubmissionTypes.FormSubmissionPayment,\n) {\n return paymentService.getFailureDetailsFromFormSubmissionPayment(\n formSubmissionPayment,\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
- recaptcha: NonNullable<NewFormSubmission['recaptchas']>[number];
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;AAC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C5B,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 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;I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iC,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"]}