@oneblink/sdk-core 10.0.0 → 10.1.0-beta.2

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 (33) hide show
  1. package/dist/calculationService.d.ts +144 -0
  2. package/dist/calculationService.js +297 -0
  3. package/dist/calculationService.js.map +1 -0
  4. package/dist/conditionalLogicService/evaluateConditionalSubmissionTimestampPredicate.js +1 -1
  5. package/dist/conditionalLogicService/evaluateConditionalSubmissionTimestampPredicate.js.map +1 -1
  6. package/dist/conditionalLogicService/types.d.ts +5 -0
  7. package/dist/conditionalLogicService/types.js +5 -1
  8. package/dist/conditionalLogicService/types.js.map +1 -1
  9. package/dist/index.d.ts +10 -0
  10. package/dist/index.js +10 -0
  11. package/dist/index.js.map +1 -1
  12. package/dist/paymentService/getPaymentProvider.d.ts +9 -0
  13. package/dist/paymentService/getPaymentProvider.js +20 -0
  14. package/dist/paymentService/getPaymentProvider.js.map +1 -0
  15. package/dist/paymentService/providers/bpoint.d.ts +7 -0
  16. package/dist/paymentService/providers/bpoint.js +76 -0
  17. package/dist/paymentService/providers/bpoint.js.map +1 -0
  18. package/dist/paymentService/providers/cpPay.d.ts +7 -0
  19. package/dist/paymentService/providers/cpPay.js +119 -0
  20. package/dist/paymentService/providers/cpPay.js.map +1 -0
  21. package/dist/paymentService/providers/nswGovPay.d.ts +7 -0
  22. package/dist/paymentService/providers/nswGovPay.js +90 -0
  23. package/dist/paymentService/providers/nswGovPay.js.map +1 -0
  24. package/dist/paymentService/providers/westpacQuickStream.d.ts +7 -0
  25. package/dist/paymentService/providers/westpacQuickStream.js +64 -0
  26. package/dist/paymentService/providers/westpacQuickStream.js.map +1 -0
  27. package/dist/paymentService/types.d.ts +25 -0
  28. package/dist/paymentService/types.js +2 -0
  29. package/dist/paymentService/types.js.map +1 -0
  30. package/dist/paymentService.d.ts +19 -15
  31. package/dist/paymentService.js +61 -296
  32. package/dist/paymentService.js.map +1 -1
  33. package/package.json +4 -1
@@ -0,0 +1,20 @@
1
+ import bpointPaymentProvider from './providers/bpoint.js';
2
+ import cpPayPaymentProvider from './providers/cpPay.js';
3
+ import nswGovPayPaymentProvider from './providers/nswGovPay.js';
4
+ import westpacQuickStreamPaymentProvider from './providers/westpacQuickStream.js';
5
+ const paymentProvidersMap = {
6
+ BPOINT: bpointPaymentProvider,
7
+ CP_PAY: cpPayPaymentProvider,
8
+ NSW_GOV_PAY: nswGovPayPaymentProvider,
9
+ WESTPAC_QUICK_STREAM: westpacQuickStreamPaymentProvider,
10
+ };
11
+ /**
12
+ * Resolve the pure payment provider implementation for a payment type.
13
+ *
14
+ * @param type
15
+ * @returns
16
+ */
17
+ export default function getPaymentProvider(type) {
18
+ return paymentProvidersMap[type];
19
+ }
20
+ //# sourceMappingURL=getPaymentProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getPaymentProvider.js","sourceRoot":"","sources":["../../src/paymentService/getPaymentProvider.ts"],"names":[],"mappings":"AAEA,OAAO,qBAAqB,MAAM,uBAAuB,CAAA;AACzD,OAAO,oBAAoB,MAAM,sBAAsB,CAAA;AACvD,OAAO,wBAAwB,MAAM,0BAA0B,CAAA;AAC/D,OAAO,iCAAiC,MAAM,mCAAmC,CAAA;AAEjF,MAAM,mBAAmB,GAGrB;IACF,MAAM,EAAE,qBAAqB;IAC7B,MAAM,EAAE,oBAAoB;IAC5B,WAAW,EAAE,wBAAwB;IACrC,oBAAoB,EAAE,iCAAiC;CACxD,CAAA;AAED;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CACxC,IAAmD;IAEnD,OAAO,mBAAmB,CAAC,IAAI,CAAC,CAAA;AAClC,CAAC","sourcesContent":["import { SubmissionTypes } from '@oneblink/types'\r\nimport { PaymentProvider } from './types.js'\r\nimport bpointPaymentProvider from './providers/bpoint.js'\r\nimport cpPayPaymentProvider from './providers/cpPay.js'\r\nimport nswGovPayPaymentProvider from './providers/nswGovPay.js'\r\nimport westpacQuickStreamPaymentProvider from './providers/westpacQuickStream.js'\r\n\r\nconst paymentProvidersMap: Record<\r\n SubmissionTypes.FormSubmissionPayment['type'],\r\n PaymentProvider<SubmissionTypes.FormSubmissionPayment>\r\n> = {\r\n BPOINT: bpointPaymentProvider,\r\n CP_PAY: cpPayPaymentProvider,\r\n NSW_GOV_PAY: nswGovPayPaymentProvider,\r\n WESTPAC_QUICK_STREAM: westpacQuickStreamPaymentProvider,\r\n}\r\n\r\n/**\r\n * Resolve the pure payment provider implementation for a payment type.\r\n *\r\n * @param type\r\n * @returns\r\n */\r\nexport default function getPaymentProvider(\r\n type: SubmissionTypes.FormSubmissionPayment['type'],\r\n): PaymentProvider<SubmissionTypes.FormSubmissionPayment> {\r\n return paymentProvidersMap[type]\r\n}\r\n"]}
@@ -0,0 +1,7 @@
1
+ import { SubmissionTypes } from '@oneblink/types';
2
+ import { PaymentProvider } from '../types.js';
3
+ type BPOINTFormSubmissionPayment = Extract<SubmissionTypes.FormSubmissionPayment, {
4
+ type: 'BPOINT';
5
+ }>;
6
+ declare const bpointPaymentProvider: PaymentProvider<BPOINTFormSubmissionPayment>;
7
+ export default bpointPaymentProvider;
@@ -0,0 +1,76 @@
1
+ function getFormStorePayment(formSubmissionPayment) {
2
+ const providerTransactionId = formSubmissionPayment.paymentTransaction?.TxnNumber;
3
+ const providerReceiptNumber = formSubmissionPayment.paymentTransaction?.ReceiptNumber;
4
+ return {
5
+ status: formSubmissionPayment.status,
6
+ ...(providerTransactionId ? { providerTransactionId } : {}),
7
+ ...(providerReceiptNumber ? { providerReceiptNumber } : {}),
8
+ };
9
+ }
10
+ function getDisplayDetails(formSubmissionPayment, { formatCurrency, formatDateTime, }) {
11
+ const { paymentTransaction } = formSubmissionPayment;
12
+ if (!paymentTransaction) {
13
+ return;
14
+ }
15
+ const amountValue = paymentTransaction.Amount / 100;
16
+ const amount = {
17
+ value: amountValue,
18
+ formatted: formatCurrency(amountValue),
19
+ };
20
+ return {
21
+ amount,
22
+ paymentDisplayDetails: [
23
+ {
24
+ key: 'BPOINT_RECEIPT_NUMBER',
25
+ label: 'Receipt Number',
26
+ value: paymentTransaction.ReceiptNumber,
27
+ },
28
+ {
29
+ key: 'BPOINT_CRN1',
30
+ label: 'CRN 1',
31
+ value: paymentTransaction.Crn1,
32
+ },
33
+ {
34
+ key: 'BPOINT_CRN2',
35
+ label: 'CRN 2',
36
+ value: paymentTransaction.Crn2,
37
+ },
38
+ {
39
+ key: 'BPOINT_CRN3',
40
+ label: 'CRN 3',
41
+ value: paymentTransaction.Crn3,
42
+ },
43
+ {
44
+ key: 'BPOINT_BILLER_CODE',
45
+ label: 'Biller Code',
46
+ value: paymentTransaction.BillerCode,
47
+ },
48
+ {
49
+ key: 'BPOINT_CREDIT_CARD_MASK',
50
+ label: 'Card Number',
51
+ value: paymentTransaction.CardDetails.MaskedCardNumber,
52
+ },
53
+ {
54
+ key: 'BPOINT_AMOUNT',
55
+ label: 'Amount',
56
+ value: amount.formatted,
57
+ },
58
+ {
59
+ key: 'BPOINT_SURCHARGE_AMOUNT',
60
+ label: 'Surcharge Amount',
61
+ value: formatCurrency(paymentTransaction.AmountSurcharge / 100),
62
+ },
63
+ {
64
+ key: 'BPOINT_PROCESSED_DATE_TIME',
65
+ label: 'Processed Date Time',
66
+ value: formatDateTime(paymentTransaction.ProcessedDateTime),
67
+ },
68
+ ],
69
+ };
70
+ }
71
+ const bpointPaymentProvider = {
72
+ getFormStorePayment,
73
+ getDisplayDetails,
74
+ };
75
+ export default bpointPaymentProvider;
76
+ //# sourceMappingURL=bpoint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bpoint.js","sourceRoot":"","sources":["../../../src/paymentService/providers/bpoint.ts"],"names":[],"mappings":"AAaA,SAAS,mBAAmB,CAC1B,qBAAkD;IAElD,MAAM,qBAAqB,GACzB,qBAAqB,CAAC,kBAAkB,EAAE,SAAS,CAAA;IACrD,MAAM,qBAAqB,GACzB,qBAAqB,CAAC,kBAAkB,EAAE,aAAa,CA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K,EAAE,kBAAkB,CAAC,WAAW,CAAC,gBAAgB;aACvD;YACD;gBACE,GAAG,EAAE,eAAe;gBACpB,KAAK,EAAE,QAAQ;gBACf,KAAK,EAAE,MAAM,CAAC,SAAS;aACxB;YACD;gBACE,GAAG,EAAE,yBAAyB;gBAC9B,KAAK,EAAE,kBAAkB;gBACzB,KAAK,EAAE,cAAc,CAAC,kBAAkB,CAAC,eAAe,GAAG,GAAG,CAAC;aAChE;YACD;gBACE,GAAG,EAAE,4BAA4B;gBACjC,KAAK,EAAE,qBAAqB;gBAC5B,KAAK,EAAE,cAAc,CAAC,kBAAkB,CAAC,iBAAiB,CAAC;aAC5D;SACF;KACF,CAAA;AACH,CAAC;AAED,MAAM,qBAAqB,GAAiD;IAC1E,mBAAmB;IACnB,iBAAiB;CAClB,CAAA;AAED,eAAe,qBAAqB,CAAA","sourcesContent":["import { SubmissionTypes } from '@oneblink/types'\r\nimport {\r\n FormStorePayment,\r\n PaymentDisplayDetailsResult,\r\n PaymentDisplayFormatters,\r\n PaymentProvider,\r\n} from '../types.js'\r\n\r\ntype BPOINTFormSubmissionPayment = Extract<\r\n SubmissionTypes.FormSubmissionPayment,\r\n { type: 'BPOINT' }\r\n>\r\n\r\nfunction getFormStorePayment(\r\n formSubmissionPayment: BPOINTFormSubmissionPayment,\r\n): FormStorePayment {\r\n const providerTransactionId =\r\n formSubmissionPayment.paymentTransaction?.TxnNumber\r\n const providerReceiptNumber =\r\n formSubmissionPayment.paymentTransaction?.ReceiptNumber\r\n\r\n return {\r\n status: formSubmissionPayment.status,\r\n ...(providerTransactionId ? { providerTransactionId } : {}),\r\n ...(providerReceiptNumber ? { providerReceiptNumber } : {}),\r\n }\r\n}\r\n\r\nfunction getDisplayDetails(\r\n formSubmissionPayment: BPOINTFormSubmissionPayment,\r\n {\r\n formatCurrency,\r\n formatDateTime,\r\n }: PaymentDisplayFormatters,\r\n): PaymentDisplayDetailsResult | undefined {\r\n const { paymentTransaction } = formSubmissionPayment\r\n if (!paymentTransaction) {\r\n return\r\n }\r\n const amountValue = paymentTransaction.Amount / 100\r\n const amount = {\r\n value: amountValue,\r\n formatted: formatCurrency(amountValue),\r\n }\r\n return {\r\n amount,\r\n paymentDisplayDetails: [\r\n {\r\n key: 'BPOINT_RECEIPT_NUMBER',\r\n label: 'Receipt Number',\r\n value: paymentTransaction.ReceiptNumber,\r\n },\r\n {\r\n key: 'BPOINT_CRN1',\r\n label: 'CRN 1',\r\n value: paymentTransaction.Crn1,\r\n },\r\n {\r\n key: 'BPOINT_CRN2',\r\n label: 'CRN 2',\r\n value: paymentTransaction.Crn2,\r\n },\r\n {\r\n key: 'BPOINT_CRN3',\r\n label: 'CRN 3',\r\n value: paymentTransaction.Crn3,\r\n },\r\n {\r\n key: 'BPOINT_BILLER_CODE',\r\n label: 'Biller Code',\r\n value: paymentTransaction.BillerCode,\r\n },\r\n {\r\n key: 'BPOINT_CREDIT_CARD_MASK',\r\n label: 'Card Number',\r\n value: paymentTransaction.CardDetails.MaskedCardNumber,\r\n },\r\n {\r\n key: 'BPOINT_AMOUNT',\r\n label: 'Amount',\r\n value: amount.formatted,\r\n },\r\n {\r\n key: 'BPOINT_SURCHARGE_AMOUNT',\r\n label: 'Surcharge Amount',\r\n value: formatCurrency(paymentTransaction.AmountSurcharge / 100),\r\n },\r\n {\r\n key: 'BPOINT_PROCESSED_DATE_TIME',\r\n label: 'Processed Date Time',\r\n value: formatDateTime(paymentTransaction.ProcessedDateTime),\r\n },\r\n ],\r\n }\r\n}\r\n\r\nconst bpointPaymentProvider: PaymentProvider<BPOINTFormSubmissionPayment> = {\r\n getFormStorePayment,\r\n getDisplayDetails,\r\n}\r\n\r\nexport default bpointPaymentProvider\r\n"]}
@@ -0,0 +1,7 @@
1
+ import { SubmissionTypes } from '@oneblink/types';
2
+ import { PaymentProvider } from '../types.js';
3
+ type CPPayFormSubmissionPayment = Extract<SubmissionTypes.FormSubmissionPayment, {
4
+ type: 'CP_PAY';
5
+ }>;
6
+ declare const cpPayPaymentProvider: PaymentProvider<CPPayFormSubmissionPayment>;
7
+ export default cpPayPaymentProvider;
@@ -0,0 +1,119 @@
1
+ function getFormStorePayment(formSubmissionPayment) {
2
+ const paymentTransaction = formSubmissionPayment.paymentTransaction;
3
+ const providerTransactionId = !paymentTransaction
4
+ ? undefined
5
+ : paymentTransaction.cpPayVersion === 'v2'
6
+ ? paymentTransaction.result.id
7
+ : paymentTransaction.transactionId;
8
+ const providerReceiptNumber = !paymentTransaction
9
+ ? undefined
10
+ : paymentTransaction.cpPayVersion === 'v2'
11
+ ? (paymentTransaction.result.externalReferenceId ?? undefined)
12
+ : (paymentTransaction.orderNumber ?? undefined);
13
+ return {
14
+ status: formSubmissionPayment.status,
15
+ ...(providerTransactionId ? { providerTransactionId } : {}),
16
+ ...(providerReceiptNumber ? { providerReceiptNumber } : {}),
17
+ };
18
+ }
19
+ function getDisplayDetails(formSubmissionPayment, { formatCurrency, formatDateTime }) {
20
+ const { paymentTransaction } = formSubmissionPayment;
21
+ if (!paymentTransaction) {
22
+ return;
23
+ }
24
+ const determineDetails = () => {
25
+ switch (paymentTransaction.cpPayVersion) {
26
+ case 'v2': {
27
+ return {
28
+ transactionId: paymentTransaction.result.id,
29
+ orderNumber: paymentTransaction.result.externalReferenceId ?? undefined,
30
+ paymentType: paymentTransaction.result.paymentType,
31
+ creditCardMask: paymentTransaction.result.lastFour
32
+ ? `xxxx xxxx xxxx ${paymentTransaction.result.lastFour}`
33
+ : undefined,
34
+ amount: paymentTransaction.result.amount !== undefined
35
+ ? {
36
+ value: paymentTransaction.result.amount,
37
+ formatted: formatCurrency(paymentTransaction.result.amount),
38
+ }
39
+ : {
40
+ value: NaN,
41
+ formatted: 'Unknown',
42
+ },
43
+ createdDateTime: paymentTransaction.result.createdOnUtc,
44
+ };
45
+ }
46
+ default: {
47
+ return {
48
+ transactionId: paymentTransaction.transactionId,
49
+ orderNumber: paymentTransaction.orderNumber ?? undefined,
50
+ paymentType: paymentTransaction.paymentTypeId === 1
51
+ ? 'Credit/Debit Card'
52
+ : paymentTransaction.paymentTypeId === 2
53
+ ? 'ACH'
54
+ : undefined,
55
+ creditCardMask: paymentTransaction.lastFour
56
+ ? `xxxx xxxx xxxx ${paymentTransaction.lastFour}`
57
+ : undefined,
58
+ amount: {
59
+ value: paymentTransaction.amount,
60
+ formatted: formatCurrency(paymentTransaction.amount),
61
+ },
62
+ createdDateTime: paymentTransaction.createdAt,
63
+ };
64
+ }
65
+ }
66
+ };
67
+ const { transactionId, orderNumber, paymentType, creditCardMask, amount, createdDateTime, } = determineDetails();
68
+ const paymentDisplayDetails = [];
69
+ if (transactionId) {
70
+ paymentDisplayDetails.push({
71
+ key: 'CP_PAY_TRANSACTION_ID',
72
+ label: 'Transaction Id',
73
+ value: transactionId,
74
+ });
75
+ }
76
+ if (orderNumber) {
77
+ paymentDisplayDetails.push({
78
+ key: 'CP_PAY_ORDER_NUMBER',
79
+ label: 'Order Number',
80
+ value: orderNumber,
81
+ });
82
+ }
83
+ if (paymentType) {
84
+ paymentDisplayDetails.push({
85
+ key: 'CP_PAY_PAYMENT_TYPE',
86
+ label: 'Payment Type',
87
+ value: paymentType,
88
+ });
89
+ }
90
+ if (creditCardMask) {
91
+ paymentDisplayDetails.push({
92
+ key: 'CP_PAY_CREDIT_CARD_MASK',
93
+ label: 'Card Number',
94
+ value: creditCardMask,
95
+ });
96
+ }
97
+ paymentDisplayDetails.push({
98
+ key: 'CP_PAY_AMOUNT',
99
+ label: 'Amount',
100
+ value: amount.formatted,
101
+ });
102
+ if (createdDateTime) {
103
+ paymentDisplayDetails.push({
104
+ key: 'CP_PAY_CREATED_DATE_TIME',
105
+ label: 'Created At',
106
+ value: formatDateTime(createdDateTime),
107
+ });
108
+ }
109
+ return {
110
+ amount,
111
+ paymentDisplayDetails,
112
+ };
113
+ }
114
+ const cpPayPaymentProvider = {
115
+ getFormStorePayment,
116
+ getDisplayDetails,
117
+ };
118
+ export default cpPayPaymentProvider;
119
+ //# sourceMappingURL=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,CAAC,CAAA;IACJ,CAAC;IAED,OAAO;QACL,MAAM;QACN,qBAAqB;KACtB,CAAA;AACH,CAAC;AAED,MAAM,oBAAoB,GAAgD;IACxE,mBAAmB;IACnB,iBAAiB;CAClB,CAAA;AAED,eAAe,oBAAoB,CAAA","sourcesContent":["import { SubmissionTypes } from '@oneblink/types'\r\nimport {\r\n FormStorePayment,\r\n PaymentDisplayDetail,\r\n PaymentDisplayDetailsResult,\r\n PaymentDisplayFormatters,\r\n PaymentProvider,\r\n} from '../types.js'\r\n\r\ntype CPPayFormSubmissionPayment = Extract<\r\n SubmissionTypes.FormSubmissionPayment,\r\n { type: 'CP_PAY' }\r\n>\r\n\r\nfunction getFormStorePayment(\r\n formSubmissionPayment: CPPayFormSubmissionPayment,\r\n): FormStorePayment {\r\n const paymentTransaction = formSubmissionPayment.paymentTransaction\r\n const providerTransactionId = !paymentTransaction\r\n ? undefined\r\n : paymentTransaction.cpPayVersion === 'v2'\r\n ? paymentTransaction.result.id\r\n : paymentTransaction.transactionId\r\n const providerReceiptNumber = !paymentTransaction\r\n ? undefined\r\n : paymentTransaction.cpPayVersion === 'v2'\r\n ? (paymentTransaction.result.externalReferenceId ?? undefined)\r\n : (paymentTransaction.orderNumber ?? undefined)\r\n\r\n return {\r\n status: formSubmissionPayment.status,\r\n ...(providerTransactionId ? { providerTransactionId } : {}),\r\n ...(providerReceiptNumber ? { providerReceiptNumber } : {}),\r\n }\r\n}\r\n\r\nfunction getDisplayDetails(\r\n formSubmissionPayment: CPPayFormSubmissionPayment,\r\n { formatCurrency, formatDateTime }: PaymentDisplayFormatters,\r\n): PaymentDisplayDetailsResult | undefined {\r\n const { paymentTransaction } = formSubmissionPayment\r\n if (!paymentTransaction) {\r\n return\r\n }\r\n\r\n const determineDetails = () => {\r\n switch (paymentTransaction.cpPayVersion) {\r\n case 'v2': {\r\n return {\r\n transactionId: paymentTransaction.result.id,\r\n orderNumber:\r\n paymentTransaction.result.externalReferenceId ?? undefined,\r\n paymentType: paymentTransaction.result.paymentType,\r\n creditCardMask: paymentTransaction.result.lastFour\r\n ? `xxxx xxxx xxxx ${paymentTransaction.result.lastFour}`\r\n : undefined,\r\n amount:\r\n paymentTransaction.result.amount !== undefined\r\n ? {\r\n value: paymentTransaction.result.amount,\r\n formatted: formatCurrency(paymentTransaction.result.amount),\r\n }\r\n : {\r\n value: NaN,\r\n formatted: 'Unknown',\r\n },\r\n createdDateTime: paymentTransaction.result.createdOnUtc,\r\n }\r\n }\r\n default: {\r\n return {\r\n transactionId: paymentTransaction.transactionId,\r\n orderNumber: paymentTransaction.orderNumber ?? undefined,\r\n paymentType:\r\n paymentTransaction.paymentTypeId === 1\r\n ? 'Credit/Debit Card'\r\n : paymentTransaction.paymentTypeId === 2\r\n ? 'ACH'\r\n : undefined,\r\n creditCardMask: paymentTransaction.lastFour\r\n ? `xxxx xxxx xxxx ${paymentTransaction.lastFour}`\r\n : undefined,\r\n amount: {\r\n value: paymentTransaction.amount,\r\n formatted: formatCurrency(paymentTransaction.amount),\r\n },\r\n createdDateTime: paymentTransaction.createdAt,\r\n }\r\n }\r\n }\r\n }\r\n\r\n const {\r\n transactionId,\r\n orderNumber,\r\n paymentType,\r\n creditCardMask,\r\n amount,\r\n createdDateTime,\r\n } = determineDetails()\r\n const paymentDisplayDetails: PaymentDisplayDetail[] = []\r\n if (transactionId) {\r\n paymentDisplayDetails.push({\r\n key: 'CP_PAY_TRANSACTION_ID',\r\n label: 'Transaction Id',\r\n value: transactionId,\r\n })\r\n }\r\n if (orderNumber) {\r\n paymentDisplayDetails.push({\r\n key: 'CP_PAY_ORDER_NUMBER',\r\n label: 'Order Number',\r\n value: orderNumber,\r\n })\r\n }\r\n if (paymentType) {\r\n paymentDisplayDetails.push({\r\n key: 'CP_PAY_PAYMENT_TYPE',\r\n label: 'Payment Type',\r\n value: paymentType,\r\n })\r\n }\r\n if (creditCardMask) {\r\n paymentDisplayDetails.push({\r\n key: 'CP_PAY_CREDIT_CARD_MASK',\r\n label: 'Card Number',\r\n value: creditCardMask,\r\n })\r\n }\r\n paymentDisplayDetails.push({\r\n key: 'CP_PAY_AMOUNT',\r\n label: 'Amount',\r\n value: amount.formatted,\r\n })\r\n if (createdDateTime) {\r\n paymentDisplayDetails.push({\r\n key: 'CP_PAY_CREATED_DATE_TIME',\r\n label: 'Created At',\r\n value: formatDateTime(createdDateTime),\r\n })\r\n }\r\n\r\n return {\r\n amount,\r\n paymentDisplayDetails,\r\n }\r\n}\r\n\r\nconst cpPayPaymentProvider: PaymentProvider<CPPayFormSubmissionPayment> = {\r\n getFormStorePayment,\r\n getDisplayDetails,\r\n}\r\n\r\nexport default cpPayPaymentProvider\r\n"]}
@@ -0,0 +1,7 @@
1
+ import { SubmissionTypes } from '@oneblink/types';
2
+ import { PaymentProvider } from '../types.js';
3
+ type NSWGovPayFormSubmissionPayment = Extract<SubmissionTypes.FormSubmissionPayment, {
4
+ type: 'NSW_GOV_PAY';
5
+ }>;
6
+ declare const nswGovPayPaymentProvider: PaymentProvider<NSWGovPayFormSubmissionPayment>;
7
+ export default nswGovPayPaymentProvider;
@@ -0,0 +1,90 @@
1
+ function getFormStorePayment(formSubmissionPayment) {
2
+ const providerTransactionId = formSubmissionPayment.paymentTransaction?.nswGovPayPaymentReference;
3
+ const providerReceiptNumber = formSubmissionPayment.paymentTransaction?.agencyCompletionPayment
4
+ ?.paymentCompletionReference;
5
+ return {
6
+ status: formSubmissionPayment.status,
7
+ ...(providerTransactionId ? { providerTransactionId } : {}),
8
+ ...(providerReceiptNumber ? { providerReceiptNumber } : {}),
9
+ };
10
+ }
11
+ function getDisplayDetails(formSubmissionPayment, { formatCurrency, formatDateTime, }) {
12
+ const { paymentTransaction } = formSubmissionPayment;
13
+ if (!paymentTransaction || !paymentTransaction.agencyCompletionPayment) {
14
+ return;
15
+ }
16
+ const amount = {
17
+ value: paymentTransaction.agencyCompletionPayment.amount,
18
+ formatted: formatCurrency(paymentTransaction.agencyCompletionPayment.amount),
19
+ };
20
+ return {
21
+ amount,
22
+ paymentDisplayDetails: [
23
+ {
24
+ key: 'NSW_GOV_PAY_COMPLETION_REFERENCE',
25
+ label: 'Completion Reference',
26
+ value: paymentTransaction.agencyCompletionPayment.paymentCompletionReference,
27
+ },
28
+ {
29
+ key: 'NSW_GOV_PAY_PAYMENT_REFERENCE',
30
+ label: 'Payment Reference',
31
+ value: paymentTransaction.agencyCompletionPayment.paymentReference,
32
+ },
33
+ {
34
+ key: 'NSW_GOV_PAY_BANK_REFERENCE',
35
+ label: 'Bank Reference',
36
+ value: paymentTransaction.agencyCompletionPayment.bankReference,
37
+ },
38
+ {
39
+ key: 'NSW_GOV_PAY_PAYMENT_METHOD',
40
+ label: 'Payment Method',
41
+ value: paymentTransaction.agencyCompletionPayment.paymentMethod,
42
+ },
43
+ ...(paymentTransaction.agencyCompletionPayment.paymentMethod === 'BPAY' &&
44
+ paymentTransaction.agencyCompletionPayment.bPay?.billerCode
45
+ ? [
46
+ {
47
+ key: 'NSW_GOV_PAY_BPAY_BILLER_CODE',
48
+ label: 'BPay Biller Code',
49
+ value: paymentTransaction.agencyCompletionPayment.bPay.billerCode,
50
+ },
51
+ ]
52
+ : []),
53
+ ...(paymentTransaction.agencyCompletionPayment.paymentMethod === 'CARD'
54
+ ? [
55
+ {
56
+ key: 'NSW_GOV_PAY_CREDIT_CARD_NUMBER',
57
+ label: 'Card Number',
58
+ value: `xxxx xxxx xxxx ${paymentTransaction.agencyCompletionPayment.card?.last4Digits}`,
59
+ },
60
+ ]
61
+ : []),
62
+ {
63
+ key: 'NSW_GOV_PAY_AMOUNT',
64
+ label: 'Amount',
65
+ value: amount.formatted,
66
+ },
67
+ {
68
+ key: 'NSW_GOV_PAY_SURCHARGE_AMOUNT',
69
+ label: 'Surcharge Amount',
70
+ value: formatCurrency(paymentTransaction.agencyCompletionPayment.surcharge),
71
+ },
72
+ {
73
+ key: 'NSW_GOV_PAY_SURCHARGE_GST',
74
+ label: 'Surcharge GST',
75
+ value: formatCurrency(paymentTransaction.agencyCompletionPayment.surchargeGst),
76
+ },
77
+ {
78
+ key: 'NSW_GOV_PAY_CREATED_DATE_TIME',
79
+ label: 'Created Date Time',
80
+ value: formatDateTime(formSubmissionPayment.createdAt),
81
+ },
82
+ ],
83
+ };
84
+ }
85
+ const nswGovPayPaymentProvider = {
86
+ getFormStorePayment,
87
+ getDisplayDetails,
88
+ };
89
+ export default nswGovPayPaymentProvider;
90
+ //# sourceMappingURL=nswGovPay.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nswGovPay.js","sourceRoot":"","sources":["../../../src/paymentService/providers/nswGovPay.ts"],"names":[],"mappings":"AAaA,SAAS,mBAAmB,CAC1B,qBAAqD;IAErD,MAAM,qBAAqB,GACzB,qBAAqB,CAAC,kBAAkB,EAAE,yBAAyB,CAAA;IACrE,MAAM,qBAAqB,GACzB,qBAAqB,CAAC,kBAAkB,EAAE,uBAAuB;QAC/D,EAAE,0BAA0B,CAAA;IAEhC,OAAO;QACL,MAAM,EAAE,qBAAqB,CAAC,MAAM;QACpC,GAAG,CAAC,qBAAqB,CAAC,CAAC,CAAC,EAAE,qBAAqB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3D,GAAG,CAAC,qBAAqB,CAAC,CAAC,CAAC,EAAE,qBAAqB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC5D,CAAA;AACH,CAAC;AAED,SAAS,iBAAiB,CACxB,qBAAqD,EACrD,EACE,cAAc,EACd,cAAc,GACW;IAE3B,MAAM,EAAE,kBAAkB,EAAE,GAAG,qBAAqB,CAAA;IACpD,IAAI,CAAC,kBAAkB,IAAI,CAAC,kBAAkB,CAAC,uBAAuB,EAAE,CAAC;QACvE,OAAM;IACR,CAAC;IAED,MAAM,MAAM,GAAG;QACb,KAAK,EAAE,kBAAkB,CAAC,uBAAuB,CAAC,MAAM;QACxD,SAAS,EAAE,cAAc,CACvB,kBAAkB,CAAC,uBAAuB,CAAC,MAAM,CAClD;KACF,CAAA;IACD,O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AAK,EAAE,kBAAkB;gBACzB,KAAK,EAAE,cAAc,CACnB,kBAAkB,CAAC,uBAAuB,CAAC,SAAS,CACrD;aACF;YACD;gBACE,GAAG,EAAE,2BAA2B;gBAChC,KAAK,EAAE,eAAe;gBACtB,KAAK,EAAE,cAAc,CACnB,kBAAkB,CAAC,uBAAuB,CAAC,YAAY,CACxD;aACF;YACD;gBACE,GAAG,EAAE,+BAA+B;gBACpC,KAAK,EAAE,mBAAmB;gBAC1B,KAAK,EAAE,cAAc,CAAC,qBAAqB,CAAC,SAAS,CAAC;aACvD;SACF;KACF,CAAA;AACH,CAAC;AAED,MAAM,wBAAwB,GAC5B;IACE,mBAAmB;IACnB,iBAAiB;CAClB,CAAA;AAEH,eAAe,wBAAwB,CAAA","sourcesContent":["import { SubmissionTypes } from '@oneblink/types'\r\nimport {\r\n FormStorePayment,\r\n PaymentDisplayDetailsResult,\r\n PaymentDisplayFormatters,\r\n PaymentProvider,\r\n} from '../types.js'\r\n\r\ntype NSWGovPayFormSubmissionPayment = Extract<\r\n SubmissionTypes.FormSubmissionPayment,\r\n { type: 'NSW_GOV_PAY' }\r\n>\r\n\r\nfunction getFormStorePayment(\r\n formSubmissionPayment: NSWGovPayFormSubmissionPayment,\r\n): FormStorePayment {\r\n const providerTransactionId =\r\n formSubmissionPayment.paymentTransaction?.nswGovPayPaymentReference\r\n const providerReceiptNumber =\r\n formSubmissionPayment.paymentTransaction?.agencyCompletionPayment\r\n ?.paymentCompletionReference\r\n\r\n return {\r\n status: formSubmissionPayment.status,\r\n ...(providerTransactionId ? { providerTransactionId } : {}),\r\n ...(providerReceiptNumber ? { providerReceiptNumber } : {}),\r\n }\r\n}\r\n\r\nfunction getDisplayDetails(\r\n formSubmissionPayment: NSWGovPayFormSubmissionPayment,\r\n {\r\n formatCurrency,\r\n formatDateTime,\r\n }: PaymentDisplayFormatters,\r\n): PaymentDisplayDetailsResult | undefined {\r\n const { paymentTransaction } = formSubmissionPayment\r\n if (!paymentTransaction || !paymentTransaction.agencyCompletionPayment) {\r\n return\r\n }\r\n\r\n const amount = {\r\n value: paymentTransaction.agencyCompletionPayment.amount,\r\n formatted: formatCurrency(\r\n paymentTransaction.agencyCompletionPayment.amount,\r\n ),\r\n }\r\n return {\r\n amount,\r\n paymentDisplayDetails: [\r\n {\r\n key: 'NSW_GOV_PAY_COMPLETION_REFERENCE',\r\n label: 'Completion Reference',\r\n value:\r\n paymentTransaction.agencyCompletionPayment.paymentCompletionReference,\r\n },\r\n {\r\n key: 'NSW_GOV_PAY_PAYMENT_REFERENCE',\r\n label: 'Payment Reference',\r\n value: paymentTransaction.agencyCompletionPayment.paymentReference,\r\n },\r\n {\r\n key: 'NSW_GOV_PAY_BANK_REFERENCE',\r\n label: 'Bank Reference',\r\n value: paymentTransaction.agencyCompletionPayment.bankReference,\r\n },\r\n {\r\n key: 'NSW_GOV_PAY_PAYMENT_METHOD',\r\n label: 'Payment Method',\r\n value: paymentTransaction.agencyCompletionPayment.paymentMethod,\r\n },\r\n ...(paymentTransaction.agencyCompletionPayment.paymentMethod === 'BPAY' &&\r\n paymentTransaction.agencyCompletionPayment.bPay?.billerCode\r\n ? [\r\n {\r\n key: 'NSW_GOV_PAY_BPAY_BILLER_CODE' as const,\r\n label: 'BPay Biller Code',\r\n value:\r\n paymentTransaction.agencyCompletionPayment.bPay.billerCode,\r\n },\r\n ]\r\n : []),\r\n ...(paymentTransaction.agencyCompletionPayment.paymentMethod === 'CARD'\r\n ? [\r\n {\r\n key: 'NSW_GOV_PAY_CREDIT_CARD_NUMBER' as const,\r\n label: 'Card Number',\r\n value: `xxxx xxxx xxxx ${paymentTransaction.agencyCompletionPayment.card?.last4Digits}`,\r\n },\r\n ]\r\n : []),\r\n {\r\n key: 'NSW_GOV_PAY_AMOUNT',\r\n label: 'Amount',\r\n value: amount.formatted,\r\n },\r\n {\r\n key: 'NSW_GOV_PAY_SURCHARGE_AMOUNT',\r\n label: 'Surcharge Amount',\r\n value: formatCurrency(\r\n paymentTransaction.agencyCompletionPayment.surcharge,\r\n ),\r\n },\r\n {\r\n key: 'NSW_GOV_PAY_SURCHARGE_GST',\r\n label: 'Surcharge GST',\r\n value: formatCurrency(\r\n paymentTransaction.agencyCompletionPayment.surchargeGst,\r\n ),\r\n },\r\n {\r\n key: 'NSW_GOV_PAY_CREATED_DATE_TIME',\r\n label: 'Created Date Time',\r\n value: formatDateTime(formSubmissionPayment.createdAt),\r\n },\r\n ],\r\n }\r\n}\r\n\r\nconst nswGovPayPaymentProvider: PaymentProvider<NSWGovPayFormSubmissionPayment> =\r\n {\r\n getFormStorePayment,\r\n getDisplayDetails,\r\n }\r\n\r\nexport default nswGovPayPaymentProvider\r\n"]}
@@ -0,0 +1,7 @@
1
+ import { SubmissionTypes } from '@oneblink/types';
2
+ import { PaymentProvider } from '../types.js';
3
+ type WestpacQuickStreamFormSubmissionPayment = Extract<SubmissionTypes.FormSubmissionPayment, {
4
+ type: 'WESTPAC_QUICK_STREAM';
5
+ }>;
6
+ declare const westpacQuickStreamPaymentProvider: PaymentProvider<WestpacQuickStreamFormSubmissionPayment>;
7
+ export default westpacQuickStreamPaymentProvider;
@@ -0,0 +1,64 @@
1
+ function getFormStorePayment(formSubmissionPayment) {
2
+ const providerTransactionId = formSubmissionPayment.paymentTransaction?.paymentReferenceNumber;
3
+ const providerReceiptNumber = formSubmissionPayment.paymentTransaction?.receiptNumber;
4
+ return {
5
+ status: formSubmissionPayment.status,
6
+ ...(providerTransactionId ? { providerTransactionId } : {}),
7
+ ...(providerReceiptNumber ? { providerReceiptNumber } : {}),
8
+ };
9
+ }
10
+ function getDisplayDetails(formSubmissionPayment, { formatCurrency, formatDate }) {
11
+ const { paymentTransaction } = formSubmissionPayment;
12
+ if (!paymentTransaction) {
13
+ return;
14
+ }
15
+ const amount = {
16
+ value: paymentTransaction.totalAmount.amount,
17
+ formatted: formatCurrency(parseFloat(paymentTransaction.totalAmount.amount.toString())),
18
+ };
19
+ return {
20
+ amount,
21
+ paymentDisplayDetails: [
22
+ {
23
+ key: 'WESTPAC_QUICK_STREAM_RECEIPT_NUMBER',
24
+ label: 'Receipt Number',
25
+ value: paymentTransaction.receiptNumber,
26
+ },
27
+ {
28
+ key: 'WESTPAC_QUICK_STREAM_PAYMENT_REFERENCE_NUMBER',
29
+ label: 'Payment Reference',
30
+ value: paymentTransaction.paymentReferenceNumber,
31
+ },
32
+ {
33
+ key: 'WESTPAC_QUICK_STREAM_CUSTOMER_REFERENCE_NUMBER',
34
+ label: 'Customer Reference Number',
35
+ value: paymentTransaction.customerReferenceNumber,
36
+ },
37
+ {
38
+ key: 'WESTPAC_QUICK_STREAM_AMOUNT',
39
+ label: 'Amount',
40
+ value: amount.formatted,
41
+ },
42
+ ...(paymentTransaction.surchargeAmount.amount
43
+ ? [
44
+ {
45
+ key: 'WESTPAC_QUICK_STREAM_SURCHARGE_AMOUNT',
46
+ label: 'Surcharge Amount',
47
+ value: formatCurrency(parseFloat(paymentTransaction.surchargeAmount.amount.toString())),
48
+ },
49
+ ]
50
+ : []),
51
+ {
52
+ key: 'WESTPAC_QUICK_STREAM_SETTLEMENT_DATE',
53
+ label: 'Settlement Date',
54
+ value: formatDate(paymentTransaction.settlementDate),
55
+ },
56
+ ],
57
+ };
58
+ }
59
+ const westpacQuickStreamPaymentProvider = {
60
+ getFormStorePayment,
61
+ getDisplayDetails,
62
+ };
63
+ export default westpacQuickStreamPaymentProvider;
64
+ //# sourceMappingURL=westpacQuickStream.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"westpacQuickStream.js","sourceRoot":"","sources":["../../../src/paymentService/providers/westpacQuickStream.ts"],"names":[],"mappings":"AAaA,SAAS,mBAAmB,CAC1B,qBAA8D;IAE9D,MAAM,qBAAqB,GACzB,qBAAqB,CAAC,kBAAkB,EAAE,sBAAsB,CAAA;IAClE,MAAM,qBAAqB,GACzB,qBAAqB,CAAC,kBAAkB,EAAE,aAAa,CAAA;IAEzD,OAAO;QACL,MAAM,EAAE,qBAAqB,CAAC,MAAM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AAkB,CAAC,eAAe,CAAC,MAAM,CAAC,QAAQ,EAAE,CACrD,CACF;qBACF;iBACF;gBACH,CAAC,CAAC,EAAE,CAAC;YACP;gBACE,GAAG,EAAE,sCAAsC;gBAC3C,KAAK,EAAE,iBAAiB;gBACxB,KAAK,EAAE,UAAU,CAAC,kBAAkB,CAAC,cAAc,CAAC;aACrD;SACF;KACF,CAAA;AACH,CAAC;AAED,MAAM,iCAAiC,GACrC;IACE,mBAAmB;IACnB,iBAAiB;CAClB,CAAA;AAEH,eAAe,iCAAiC,CAAA","sourcesContent":["import { SubmissionTypes } from '@oneblink/types'\r\nimport {\r\n FormStorePayment,\r\n PaymentDisplayDetailsResult,\r\n PaymentDisplayFormatters,\r\n PaymentProvider,\r\n} from '../types.js'\r\n\r\ntype WestpacQuickStreamFormSubmissionPayment = Extract<\r\n SubmissionTypes.FormSubmissionPayment,\r\n { type: 'WESTPAC_QUICK_STREAM' }\r\n>\r\n\r\nfunction getFormStorePayment(\r\n formSubmissionPayment: WestpacQuickStreamFormSubmissionPayment,\r\n): FormStorePayment {\r\n const providerTransactionId =\r\n formSubmissionPayment.paymentTransaction?.paymentReferenceNumber\r\n const providerReceiptNumber =\r\n formSubmissionPayment.paymentTransaction?.receiptNumber\r\n\r\n return {\r\n status: formSubmissionPayment.status,\r\n ...(providerTransactionId ? { providerTransactionId } : {}),\r\n ...(providerReceiptNumber ? { providerReceiptNumber } : {}),\r\n }\r\n}\r\n\r\nfunction getDisplayDetails(\r\n formSubmissionPayment: WestpacQuickStreamFormSubmissionPayment,\r\n { formatCurrency, formatDate }: PaymentDisplayFormatters,\r\n): PaymentDisplayDetailsResult | undefined {\r\n const { paymentTransaction } = formSubmissionPayment\r\n if (!paymentTransaction) {\r\n return\r\n }\r\n\r\n const amount = {\r\n value: paymentTransaction.totalAmount.amount,\r\n formatted: formatCurrency(\r\n parseFloat(paymentTransaction.totalAmount.amount.toString()),\r\n ),\r\n }\r\n\r\n return {\r\n amount,\r\n paymentDisplayDetails: [\r\n {\r\n key: 'WESTPAC_QUICK_STREAM_RECEIPT_NUMBER',\r\n label: 'Receipt Number',\r\n value: paymentTransaction.receiptNumber,\r\n },\r\n {\r\n key: 'WESTPAC_QUICK_STREAM_PAYMENT_REFERENCE_NUMBER',\r\n label: 'Payment Reference',\r\n value: paymentTransaction.paymentReferenceNumber,\r\n },\r\n {\r\n key: 'WESTPAC_QUICK_STREAM_CUSTOMER_REFERENCE_NUMBER',\r\n label: 'Customer Reference Number',\r\n value: paymentTransaction.customerReferenceNumber,\r\n },\r\n {\r\n key: 'WESTPAC_QUICK_STREAM_AMOUNT',\r\n label: 'Amount',\r\n value: amount.formatted,\r\n },\r\n ...(paymentTransaction.surchargeAmount.amount\r\n ? [\r\n {\r\n key: 'WESTPAC_QUICK_STREAM_SURCHARGE_AMOUNT' as const,\r\n label: 'Surcharge Amount',\r\n value: formatCurrency(\r\n parseFloat(\r\n paymentTransaction.surchargeAmount.amount.toString(),\r\n ),\r\n ),\r\n },\r\n ]\r\n : []),\r\n {\r\n key: 'WESTPAC_QUICK_STREAM_SETTLEMENT_DATE',\r\n label: 'Settlement Date',\r\n value: formatDate(paymentTransaction.settlementDate),\r\n },\r\n ],\r\n }\r\n}\r\n\r\nconst westpacQuickStreamPaymentProvider: PaymentProvider<WestpacQuickStreamFormSubmissionPayment> =\r\n {\r\n getFormStorePayment,\r\n getDisplayDetails,\r\n }\r\n\r\nexport default westpacQuickStreamPaymentProvider\r\n"]}
@@ -0,0 +1,25 @@
1
+ import { SubmissionEventTypes, SubmissionTypes } from '@oneblink/types';
2
+ import { ReplaceInjectablesFormatters } from '../submissionService.js';
3
+ export type FormStorePayment = NonNullable<SubmissionTypes.FormStoreRecord['payment']>;
4
+ export type PaymentDisplayDetail = {
5
+ label: string;
6
+ value: string;
7
+ /** A unique key across payment providers to identify the detail */
8
+ key: SubmissionEventTypes.PaymentDisplayDetailKey;
9
+ };
10
+ export type PaymentDisplayDetailsResult = {
11
+ amount: {
12
+ value: number;
13
+ formatted: string;
14
+ };
15
+ paymentDisplayDetails: PaymentDisplayDetail[];
16
+ };
17
+ export type PaymentDisplayFormatters = Pick<ReplaceInjectablesFormatters, 'formatCurrency' | 'formatDate' | 'formatDateTime'>;
18
+ /**
19
+ * Pure transforms for a payment provider. Implementations must not perform
20
+ * HTTP or other I/O — they only accept known types and return values.
21
+ */
22
+ export interface PaymentProvider<T extends SubmissionTypes.FormSubmissionPayment> {
23
+ getFormStorePayment(formSubmissionPayment: T): FormStorePayment;
24
+ getDisplayDetails(formSubmissionPayment: T, formatters: PaymentDisplayFormatters): PaymentDisplayDetailsResult | undefined;
25
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/paymentService/types.ts"],"names":[],"mappings":"","sourcesContent":["import { SubmissionEventTypes, SubmissionTypes } from '@oneblink/types'\r\nimport { ReplaceInjectablesFormatters } from '../submissionService.js'\r\n\r\nexport type FormStorePayment = NonNullable<\r\n SubmissionTypes.FormStoreRecord['payment']\r\n>\r\n\r\nexport type PaymentDisplayDetail = {\r\n label: string\r\n value: string\r\n /** A unique key across payment providers to identify the detail */\r\n key: SubmissionEventTypes.PaymentDisplayDetailKey\r\n}\r\n\r\nexport type PaymentDisplayDetailsResult = {\r\n amount: {\r\n value: number\r\n formatted: string\r\n }\r\n paymentDisplayDetails: PaymentDisplayDetail[]\r\n}\r\n\r\nexport type PaymentDisplayFormatters = Pick<\r\n ReplaceInjectablesFormatters,\r\n 'formatCurrency' | 'formatDate' | 'formatDateTime'\r\n>\r\n\r\n/**\r\n * Pure transforms for a payment provider. Implementations must not perform\r\n * HTTP or other I/O — they only accept known types and return values.\r\n */\r\nexport interface PaymentProvider<\r\n T extends SubmissionTypes.FormSubmissionPayment,\r\n> {\r\n getFormStorePayment(formSubmissionPayment: T): FormStorePayment\r\n getDisplayDetails(\r\n formSubmissionPayment: T,\r\n formatters: PaymentDisplayFormatters,\r\n ): PaymentDisplayDetailsResult | undefined\r\n}\r\n"]}
@@ -1,6 +1,7 @@
1
1
  import { FormTypes, SubmissionEventTypes, SubmissionTypes } from '@oneblink/types';
2
- import { ReplaceInjectablesFormatters } from './submissionService.js';
3
2
  import { AddOffsetToDate, EndOfDay, ParseDayOnlyDate, StartOfDay } from './conditionalLogicService/types.js';
3
+ import type { FormStorePayment, PaymentDisplayDetail, PaymentDisplayFormatters, PaymentDisplayDetailsResult } from './paymentService/types.js';
4
+ export { FormStorePayment, PaymentDisplayDetail, PaymentDisplayDetailsResult, PaymentDisplayFormatters, };
4
5
  /**
5
6
  * Examine a submission and its form definition to validate whether a payment
6
7
  * workflow event needs to run.
@@ -48,12 +49,6 @@ export declare function checkForPaymentEvent({ definition, submission, submissio
48
49
  paymentSubmissionEvent: SubmissionEventTypes.FormPaymentEvent;
49
50
  amount: number;
50
51
  } | undefined;
51
- type PaymentDisplayDetail = {
52
- label: string;
53
- value: string;
54
- /** A unique key across payment providers to identify the detail */
55
- key: SubmissionEventTypes.PaymentDisplayDetailKey;
56
- };
57
52
  /**
58
53
  * Retrieve an array of detail items from a form submission payment.
59
54
  *
@@ -77,11 +72,20 @@ type PaymentDisplayDetail = {
77
72
  */
78
73
  export declare const getDisplayDetailsFromFormSubmissionPayment: (
79
74
  /** The form submission payment to get the details from */
80
- formSubmissionPayment: SubmissionTypes.FormSubmissionPayment, { formatCurrency, formatDateTime, formatDate, }: Pick<ReplaceInjectablesFormatters, "formatCurrency" | "formatDate" | "formatDateTime">) => {
81
- amount: {
82
- value: number;
83
- formatted: string;
84
- };
85
- paymentDisplayDetails: PaymentDisplayDetail[];
86
- } | undefined;
87
- export {};
75
+ formSubmissionPayment: SubmissionTypes.FormSubmissionPayment, formatters: PaymentDisplayFormatters) => PaymentDisplayDetailsResult | undefined;
76
+ /**
77
+ * Map a form submission payment to the Form Store payment property.
78
+ *
79
+ * #### Example
80
+ *
81
+ * ```js
82
+ * const formStorePayment =
83
+ * paymentService.getFormStorePaymentFromFormSubmissionPayment(
84
+ * formSubmissionPayment,
85
+ * )
86
+ * ```
87
+ *
88
+ * @param formSubmissionPayment
89
+ * @returns
90
+ */
91
+ export declare function getFormStorePaymentFromFormSubmissionPayment(formSubmissionPayment: SubmissionTypes.FormSubmissionPayment): FormStorePayment;