@oneblink/apps-react 5.7.0-beta.7 → 5.7.0-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/payments/PaymentForm.d.ts +3 -1
- package/dist/components/payments/PaymentForm.js +10 -3
- package/dist/components/payments/PaymentForm.js.map +1 -1
- package/dist/components/payments/WestpacQuickStreamPaymentForm.d.ts +3 -1
- package/dist/components/payments/WestpacQuickStreamPaymentForm.js +33 -31
- package/dist/components/payments/WestpacQuickStreamPaymentForm.js.map +1 -1
- package/dist/components/renderer/Modal.d.ts +5 -0
- package/dist/components/renderer/Modal.js +8 -1
- package/dist/components/renderer/Modal.js.map +1 -1
- package/dist/styles/westpac-payment.scss +48 -7
- package/dist/styles.css +39 -3
- package/package.json +1 -1
@@ -1,6 +1,6 @@
|
|
1
1
|
import { SubmissionTypes } from '@oneblink/types';
|
2
2
|
import React from 'react';
|
3
|
-
declare function PaymentForm({ captchaSiteKey, onCompleted, onCancelled, }: {
|
3
|
+
declare function PaymentForm({ captchaSiteKey, onCompleted, onCancelled, appImageUrl, title, }: {
|
4
4
|
captchaSiteKey: string;
|
5
5
|
onCompleted: (result: {
|
6
6
|
formSubmissionPayment: SubmissionTypes.FormSubmissionPayment;
|
@@ -9,6 +9,8 @@ declare function PaymentForm({ captchaSiteKey, onCompleted, onCancelled, }: {
|
|
9
9
|
onCancelled: (result: {
|
10
10
|
paymentReceiptUrl: string;
|
11
11
|
}) => void;
|
12
|
+
appImageUrl?: string;
|
13
|
+
title?: string;
|
12
14
|
}): JSX.Element;
|
13
15
|
declare const _default: React.MemoExoticComponent<typeof PaymentForm>;
|
14
16
|
export default _default;
|
@@ -4,7 +4,7 @@ import WestpacQuickStreamPaymentForm from './WestpacQuickStreamPaymentForm';
|
|
4
4
|
import useQuery from '../../hooks/useQuery';
|
5
5
|
import useLoadDataState from '../../hooks/useLoadDataState';
|
6
6
|
import OnLoading from '../renderer/OnLoading';
|
7
|
-
function PaymentForm({ captchaSiteKey, onCompleted, onCancelled, }) {
|
7
|
+
function PaymentForm({ captchaSiteKey, onCompleted, onCancelled, appImageUrl, title, }) {
|
8
8
|
const query = useQuery();
|
9
9
|
const loadPaymentFormConfiguration = React.useCallback(async (abortSignal) => {
|
10
10
|
const formSubmissionPaymentId = query.formSubmissionPaymentId;
|
@@ -27,11 +27,18 @@ function PaymentForm({ captchaSiteKey, onCompleted, onCancelled, }) {
|
|
27
27
|
abortSignal,
|
28
28
|
});
|
29
29
|
return {
|
30
|
-
renderPaymentForm: () => (React.createElement(WestpacQuickStreamPaymentForm, { formSubmissionResult: formSubmissionResult, paymentSubmissionEvent: paymentSubmissionEvent, formSubmissionPaymentId: formSubmissionPaymentId, supplierBusinessCode: supplierBusinessCode, publishableApiKey: publishableApiKey, isTestMode: isTestMode, captchaSiteKey: captchaSiteKey, onCompleted: onCompleted, onCancelled: onCancelled })),
|
30
|
+
renderPaymentForm: () => (React.createElement(WestpacQuickStreamPaymentForm, { formSubmissionResult: formSubmissionResult, paymentSubmissionEvent: paymentSubmissionEvent, formSubmissionPaymentId: formSubmissionPaymentId, supplierBusinessCode: supplierBusinessCode, publishableApiKey: publishableApiKey, isTestMode: isTestMode, captchaSiteKey: captchaSiteKey, onCompleted: onCompleted, onCancelled: onCancelled, appImageUrl: appImageUrl, title: title })),
|
31
31
|
};
|
32
32
|
}
|
33
33
|
}
|
34
|
-
}, [
|
34
|
+
}, [
|
35
|
+
appImageUrl,
|
36
|
+
captchaSiteKey,
|
37
|
+
onCancelled,
|
38
|
+
onCompleted,
|
39
|
+
query.formSubmissionPaymentId,
|
40
|
+
title,
|
41
|
+
]);
|
35
42
|
const [state] = useLoadDataState(loadPaymentFormConfiguration);
|
36
43
|
switch (state.status) {
|
37
44
|
case 'LOADING': {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"PaymentForm.js","sourceRoot":"","sources":["../../../src/components/payments/PaymentForm.tsx"],"names":[],"mappings":"AAAA,OAA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AAG,SAAS,EAAC,yEAAyE,YAElF,CACA;gBACN,2BAAG,SAAS,EAAC,sEAAsE,IAChF,KAAK,CAAC,KAAK,CAAC,OAAO,CAClB,CACI,CACX,CAAA;SACF;QACD,KAAK,SAAS,CAAC,CAAC;YACd,OAAO,KAAK,CAAC,MAAM,CAAC,iBAAiB,EAAE,CAAA;SACxC;KACF;AACH,CAAC;AAED,eAAe,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA","sourcesContent":["import { paymentService } from '@oneblink/apps'\nimport { SubmissionTypes } from '@oneblink/types'\nimport React from 'react'\nimport WestpacQuickStreamPaymentForm from './WestpacQuickStreamPaymentForm'\nimport useQuery from '../../hooks/useQuery'\nimport useLoadDataState from '../../hooks/useLoadDataState'\nimport OnLoading from '../renderer/OnLoading'\n\nfunction PaymentForm({\n captchaSiteKey,\n onCompleted,\n onCancelled,\n appImageUrl,\n title,\n}: {\n captchaSiteKey: string\n onCompleted: (result: {\n formSubmissionPayment: SubmissionTypes.FormSubmissionPayment\n paymentReceiptUrl: string\n }) => void\n onCancelled: (result: { paymentReceiptUrl: string }) => void\n appImageUrl?: string\n title?: string\n}) {\n const query = useQuery()\n\n const loadPaymentFormConfiguration = React.useCallback(\n async (abortSignal: AbortSignal) => {\n const formSubmissionPaymentId = query.formSubmissionPaymentId\n if (typeof formSubmissionPaymentId !== 'string') {\n throw new Error(\n 'It looks like you are attempting to make an unknown payment.',\n )\n }\n\n const { formSubmissionResult, paymentSubmissionEvent } =\n await paymentService.getFormSubmissionResultPayment()\n switch (paymentSubmissionEvent.type) {\n case 'BPOINT':\n case 'CP_PAY':\n case 'NSW_GOV_PAY':\n case 'WESTPAC_QUICK_WEB': {\n throw new Error(\n `\"${paymentSubmissionEvent.type}\" payment events do not support a custom payment form.`,\n )\n }\n case 'WESTPAC_QUICK_STREAM': {\n const { supplierBusinessCode, publishableApiKey, isTestMode } =\n await paymentService.westpacQuickStream.getPaymentFormConfiguration(\n {\n formSubmissionPaymentId,\n formSubmissionResult,\n paymentSubmissionEvent,\n abortSignal,\n },\n )\n return {\n renderPaymentForm: () => (\n <WestpacQuickStreamPaymentForm\n formSubmissionResult={formSubmissionResult}\n paymentSubmissionEvent={paymentSubmissionEvent}\n formSubmissionPaymentId={formSubmissionPaymentId}\n supplierBusinessCode={supplierBusinessCode}\n publishableApiKey={publishableApiKey}\n isTestMode={isTestMode}\n captchaSiteKey={captchaSiteKey}\n onCompleted={onCompleted}\n onCancelled={onCancelled}\n appImageUrl={appImageUrl}\n title={title}\n />\n ),\n }\n }\n }\n },\n [\n appImageUrl,\n captchaSiteKey,\n onCancelled,\n onCompleted,\n query.formSubmissionPaymentId,\n title,\n ],\n )\n\n const [state] = useLoadDataState(loadPaymentFormConfiguration)\n\n switch (state.status) {\n case 'LOADING': {\n return (\n <section>\n <div className=\"cypress-loading has-text-centered\">\n <OnLoading className=\"has-text-centered\"></OnLoading>\n <span>Loading payment configuration...</span>\n </div>\n </section>\n )\n }\n case 'ERROR': {\n return (\n <section className=\"cypress-payment-form-loading-error-message\">\n <div className=\"ob-payment-form__error-icon-container has-text-centered has-margin-bottom-8\">\n <i className=\"ob-payment-form__error-icon material-icons has-text-danger icon-x-large\">\n error\n </i>\n </div>\n <p className=\"ob-payment-form__error-message has-text-centered has-margin-bottom-4\">\n {state.error.message}\n </p>\n </section>\n )\n }\n case 'SUCCESS': {\n return state.result.renderPaymentForm()\n }\n }\n}\n\nexport default React.memo(PaymentForm)\n"]}
|
@@ -28,7 +28,7 @@ declare global {
|
|
28
28
|
};
|
29
29
|
}
|
30
30
|
}
|
31
|
-
declare function WestpacQuickStreamPaymentForm({ formSubmissionResult, paymentSubmissionEvent, formSubmissionPaymentId, supplierBusinessCode, publishableApiKey, isTestMode, captchaSiteKey, onCompleted, onCancelled, }: {
|
31
|
+
declare function WestpacQuickStreamPaymentForm({ formSubmissionResult, paymentSubmissionEvent, formSubmissionPaymentId, supplierBusinessCode, publishableApiKey, isTestMode, captchaSiteKey, onCompleted, onCancelled, appImageUrl, title, }: {
|
32
32
|
formSubmissionResult: submissionService.FormSubmissionResult;
|
33
33
|
paymentSubmissionEvent: SubmissionEventTypes.WestpacQuickStreamSubmissionEvent;
|
34
34
|
formSubmissionPaymentId: string;
|
@@ -43,6 +43,8 @@ declare function WestpacQuickStreamPaymentForm({ formSubmissionResult, paymentSu
|
|
43
43
|
onCancelled: (result: {
|
44
44
|
paymentReceiptUrl: string;
|
45
45
|
}) => void;
|
46
|
+
appImageUrl?: string;
|
47
|
+
title?: string;
|
46
48
|
}): JSX.Element;
|
47
49
|
declare const _default: React.MemoExoticComponent<typeof WestpacQuickStreamPaymentForm>;
|
48
50
|
export default _default;
|
@@ -1,11 +1,12 @@
|
|
1
|
-
import { OneBlinkAppsError, paymentService, } from '@oneblink/apps';
|
1
|
+
import { OneBlinkAppsError, paymentService, localisationService, } from '@oneblink/apps';
|
2
2
|
import clsx from 'clsx';
|
3
3
|
import React from 'react';
|
4
4
|
import ReCAPTCHA from 'react-google-recaptcha';
|
5
5
|
import OnLoading from '../renderer/OnLoading';
|
6
6
|
import OneBlinkAppsErrorOriginalMessage from '../renderer/OneBlinkAppsErrorOriginalMessage';
|
7
7
|
import Modal from '../renderer/Modal';
|
8
|
-
function WestpacQuickStreamPaymentForm({ formSubmissionResult, paymentSubmissionEvent, formSubmissionPaymentId, supplierBusinessCode, publishableApiKey, isTestMode, captchaSiteKey, onCompleted, onCancelled, }) {
|
8
|
+
function WestpacQuickStreamPaymentForm({ formSubmissionResult, paymentSubmissionEvent, formSubmissionPaymentId, supplierBusinessCode, publishableApiKey, isTestMode, captchaSiteKey, onCompleted, onCancelled, appImageUrl, title, }) {
|
9
|
+
var _a, _b;
|
9
10
|
const [{ isCompletingTransaction, completeTransactionError, captchaToken, displayCaptchaRequired, }, setCompleteTransactionState,] = React.useState({
|
10
11
|
isCompletingTransaction: false,
|
11
12
|
completeTransactionError: null,
|
@@ -63,15 +64,8 @@ function WestpacQuickStreamPaymentForm({ formSubmissionResult, paymentSubmission
|
|
63
64
|
threeDS2: true,
|
64
65
|
},
|
65
66
|
iframe: {
|
66
|
-
width: '100%',
|
67
|
-
height: '100%',
|
68
67
|
style: {
|
69
|
-
border: '1px solid #dedede',
|
70
|
-
'border-radius': '2px',
|
71
|
-
'min-height': '400px',
|
72
|
-
padding: '1.5rem',
|
73
68
|
width: '100%',
|
74
|
-
'background-color': 'white',
|
75
69
|
},
|
76
70
|
},
|
77
71
|
showAcceptedCards: true,
|
@@ -196,33 +190,41 @@ function WestpacQuickStreamPaymentForm({ formSubmissionResult, paymentSubmission
|
|
196
190
|
React.createElement("div", { className: "cypress-loading has-text-centered" },
|
197
191
|
React.createElement(OnLoading, { className: "has-text-centered" }),
|
198
192
|
React.createElement("span", null, "Building payment form...")))),
|
199
|
-
loadError && (React.createElement("section", { className: "cypress-payment-
|
200
|
-
React.createElement("div", { className: "ob-payment-
|
201
|
-
React.createElement("i", { className: "ob-payment-
|
202
|
-
React.createElement("p", { className: "ob-payment-
|
193
|
+
loadError && (React.createElement("section", { className: "cypress-payment-form-loading-error-message" },
|
194
|
+
React.createElement("div", { className: "ob-payment-form__error-icon-container has-text-centered has-margin-bottom-8" },
|
195
|
+
React.createElement("i", { className: "ob-payment-form__error-icon material-icons has-text-danger icon-x-large" }, "error")),
|
196
|
+
React.createElement("p", { className: "ob-payment-form__error-message has-text-centered has-margin-bottom-4" }, loadError.message))),
|
203
197
|
React.createElement("section", null,
|
204
198
|
React.createElement("form", { onSubmit: (event) => {
|
205
199
|
event.preventDefault();
|
206
200
|
handleSubmit();
|
207
201
|
} },
|
208
|
-
React.createElement("div", {
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
React.createElement(
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
202
|
+
React.createElement("div", { className: "ob-payment-form__westpac-quickstream-container" },
|
203
|
+
!!appImageUrl && (React.createElement("figure", { className: "image is-128x128 has-margin-bottom-6 ml-auto mr-auto" },
|
204
|
+
React.createElement("img", { alt: "Application Icon", className: "is-rounded", src: appImageUrl }))),
|
205
|
+
!!title && (React.createElement("h3", { className: "title is-3 is-size-3-mobile ob-header__heading has-text-centered" }, title)),
|
206
|
+
React.createElement("label", { className: "label ob-label has-text-centered" }, "Fill out the form below to complete your secure payment."),
|
207
|
+
React.createElement("div", { className: "ob-payment-form__westpac-quickstream-amount" },
|
208
|
+
React.createElement("div", null, "Amount"),
|
209
|
+
React.createElement("div", { className: "ob-payment-form__westpac-quickstream-amount-value" }, localisationService.formatCurrency((_b = (_a = formSubmissionResult.payment) === null || _a === void 0 ? void 0 : _a.amount) !== null && _b !== void 0 ? _b : 0))),
|
210
|
+
React.createElement("div", { "data-quickstream-api": "creditCardContainer", className: "quickstream-credit-card-container" }),
|
211
|
+
!isLoading && !loadError && (React.createElement(React.Fragment, null,
|
212
|
+
React.createElement(ReCAPTCHA, { sitekey: captchaSiteKey, onChange: (newValue) => {
|
213
|
+
setCompleteTransactionState((currentState) => ({
|
214
|
+
...currentState,
|
215
|
+
captchaToken: newValue,
|
216
|
+
displayCaptchaRequired: newValue === null,
|
217
|
+
}));
|
218
|
+
}, className: "ob-input cypress-captcha-control ob-payment-form__westpac-quickstream-captcha" }),
|
219
|
+
displayCaptchaRequired && (React.createElement("div", { role: "alert", className: "has-margin-top-8" },
|
220
|
+
React.createElement("div", { className: "has-text-danger ob-error__text cypress-required cypress-validation-message" }, "Please complete the CAPTCHA successfully")))))),
|
221
|
+
!isLoading && !loadError && (React.createElement("div", { className: "ob-payment-form__westpac-quickstream-form-actions" },
|
222
|
+
React.createElement("button", { type: "button", disabled: isCompletingTransaction || isCancellingTransaction, onClick: handleCancel, className: clsx('button ob-button is-outlined', {
|
223
|
+
'is-loading': isCancellingTransaction,
|
224
|
+
}) }, "Cancel"),
|
225
|
+
React.createElement("button", { type: "submit", disabled: isCompletingTransaction || isCancellingTransaction, className: clsx('button ob-button is-success', {
|
226
|
+
'is-loading': isCompletingTransaction,
|
227
|
+
}) }, "Make Payment"))))),
|
226
228
|
React.createElement(Modal, { isOpen: !!completeTransactionError, title: "Payment Issue", className: "cypress-payment-error-close-button", actions: React.createElement(React.Fragment, null,
|
227
229
|
React.createElement("button", { type: "button", className: "button ob-button cypress-payment-error-close-button is-primary", onClick: clearCompleteTransactionError, autoFocus: true }, "Okay")) },
|
228
230
|
React.createElement(React.Fragment, null,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"WestpacQuickStreamPaymentForm.js","sourceRoot":"","sources":["../../../src/components/payments/WestpacQuickStreamPaymentForm.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,cAAc,GAEf,MAAM,gBAAgB,CAAA;AAEvB,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,SAAS,MAAM,wBAAwB,CAAA;AAC9C,OAAO,SAAS,MAAM,uBAAuB,CAAA;AAC7C,OAAO,gCAAgC,MAAM,8CAA8C,CAAA;AAC3F,OAAO,KAAK,MAAM,mBAAmB,CAAA;AA4CrC,SAAS,6BAA6B,CAAC,EACrC,oBAAoB,EACpB,sBAAsB,EACtB,uBAAuB,EACvB,oBAAoB,EACpB,iBAAiB,EACjB,UAAU,EACV,cAAc,EACd,WAAW,EACX,WAAW,GAcZ;IACC,MAAM,CACJ,EACE,uBAAuB,EACvB,wBAAwB,EACxB,YAAY,EACZ,sBAAsB,GACvB,EACD,2BAA2B,EAC5B,GAAG,KAAK,CAAC,QAAQ,CAKf;QACD,uBAAuB,EAAE,KAAK;QAC9B,wBAAwB,EAAE,IAAI;QAC9B,YAAY,EAAE,IAAI;QAClB,sBAAsB,EAAE,KAAK;KAC9B,CAAC,CAAA;IAEF,MAAM,6BAA6B,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE;QAC3D,2BAA2B,CAAC,CAAC,Y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W,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,CAC7D;gBACL,WAAW,YAAY,iBAAiB,IAAI,CAC3C,oBAAC,gCAAgC,IAC/B,KAAK,EAAE,WAAW,CAAC,aAAa,GAChC,CACH,CACA,CACG,CACP,CACJ,CAAA;AACH,CAAC;AAED,eAAe,KAAK,CAAC,IAAI,CAAC,6BAA6B,CAAC,CAAA","sourcesContent":["import {\n OneBlinkAppsError,\n paymentService,\n submissionService,\n} from '@oneblink/apps'\nimport { SubmissionTypes, SubmissionEventTypes } from '@oneblink/types'\nimport clsx from 'clsx'\nimport React from 'react'\nimport ReCAPTCHA from 'react-google-recaptcha'\nimport OnLoading from '../renderer/OnLoading'\nimport OneBlinkAppsErrorOriginalMessage from '../renderer/OneBlinkAppsErrorOriginalMessage'\nimport Modal from '../renderer/Modal'\n\ninterface TrustedFrame {\n submitForm(\n callback: (\n errors:\n | Array<{\n fieldName: string\n messages: string[]\n }>\n | undefined,\n data: {\n singleUseToken: {\n singleUseTokenId: string\n }\n },\n ) => void,\n ): void\n}\n\ndeclare global {\n interface Window {\n QuickstreamAPI: {\n init(options: { publishableApiKey: string }): void\n creditCards: {\n createTrustedFrame(\n options: unknown,\n callback: (\n errors:\n | Array<{\n fieldName: string\n messages: string[]\n }>\n | undefined,\n data: {\n trustedFrame: TrustedFrame\n },\n ) => void,\n ): void\n }\n }\n }\n}\n\nfunction WestpacQuickStreamPaymentForm({\n formSubmissionResult,\n paymentSubmissionEvent,\n formSubmissionPaymentId,\n supplierBusinessCode,\n publishableApiKey,\n isTestMode,\n captchaSiteKey,\n onCompleted,\n onCancelled,\n}: {\n formSubmissionResult: submissionService.FormSubmissionResult\n paymentSubmissionEvent: SubmissionEventTypes.WestpacQuickStreamSubmissionEvent\n formSubmissionPaymentId: string\n supplierBusinessCode: string\n publishableApiKey: string\n isTestMode: boolean\n captchaSiteKey: string\n onCompleted: (result: {\n formSubmissionPayment: SubmissionTypes.FormSubmissionPayment\n paymentReceiptUrl: string\n }) => void\n onCancelled: (result: { paymentReceiptUrl: string }) => void\n}) {\n const [\n {\n isCompletingTransaction,\n completeTransactionError,\n captchaToken,\n displayCaptchaRequired,\n },\n setCompleteTransactionState,\n ] = React.useState<{\n captchaToken: string | null\n displayCaptchaRequired: boolean\n isCompletingTransaction: boolean\n completeTransactionError: Error | null\n }>({\n isCompletingTransaction: false,\n completeTransactionError: null,\n captchaToken: null,\n displayCaptchaRequired: false,\n })\n\n const clearCompleteTransactionError = React.useCallback(() => {\n setCompleteTransactionState((currentState) => ({\n ...currentState,\n isCompletingTransaction: false,\n completeTransactionError: null,\n }))\n }, [])\n\n const [{ trustedFrame, isLoading, loadError }, setLoadState] =\n React.useState<{\n trustedFrame: TrustedFrame | null\n isLoading: boolean\n loadError: Error | null\n }>({\n trustedFrame: null,\n isLoading: true,\n loadError: null,\n })\n\n React.useEffect(() => {\n const abortController = new AbortController()\n const scriptEle = document.createElement('script')\n scriptEle.type = 'text/javascript'\n scriptEle.async = true\n\n const run = async () => {\n try {\n scriptEle.src = isTestMode\n ? 'https://api.quickstream.support.qvalent.com/rest/v1/quickstream-api-1.0.min.js'\n : 'https://api.quickstream.westpac.com.au/rest/v1/quickstream-api-1.0.min.js'\n\n await new Promise((resolve, reject) => {\n try {\n scriptEle.addEventListener(\n 'load',\n () => {\n resolve(undefined)\n },\n {\n signal: abortController.signal,\n },\n )\n\n scriptEle.addEventListener(\n 'error',\n () => {\n reject(new Error(`Failed to load the script ${scriptEle.src}`))\n },\n {\n signal: abortController.signal,\n },\n )\n\n document.body.appendChild(scriptEle)\n } catch (error) {\n console.warn('Failed to load script', error)\n reject(error)\n }\n })\n\n window.QuickstreamAPI.init({\n publishableApiKey,\n })\n const newTrustedFrame = await new Promise<TrustedFrame>(\n (resolve, reject) => {\n window.QuickstreamAPI.creditCards.createTrustedFrame(\n {\n config: {\n supplierBusinessCode,\n threeDS2: true,\n },\n iframe: {\n width: '100%',\n height: '100%',\n style: {\n border: '1px solid #dedede',\n 'border-radius': '2px',\n 'min-height': '400px',\n padding: '1.5rem',\n width: '100%',\n 'background-color': 'white',\n },\n },\n showAcceptedCards: true,\n showRequiredIndicators: true,\n },\n (errors, data) => {\n if (errors) {\n reject(errors)\n return\n }\n resolve(data.trustedFrame)\n },\n )\n },\n )\n\n if (!abortController.signal.aborted) {\n setLoadState({\n trustedFrame: newTrustedFrame,\n isLoading: false,\n loadError: null,\n })\n }\n } catch (error) {\n if (!abortController.signal.aborted) {\n setLoadState({\n trustedFrame: null,\n isLoading: false,\n loadError: error as Error,\n })\n }\n }\n }\n\n run()\n\n return () => {\n abortController.abort()\n document.body.removeChild(scriptEle)\n }\n }, [isTestMode, publishableApiKey, supplierBusinessCode])\n\n const handleSubmit = React.useCallback(async () => {\n if (!trustedFrame) {\n return\n }\n\n if (!captchaToken) {\n setCompleteTransactionState({\n captchaToken: null,\n displayCaptchaRequired: true,\n isCompletingTransaction: false,\n completeTransactionError: null,\n })\n return\n }\n\n setCompleteTransactionState((currentState) => ({\n ...currentState,\n isCompletingTransaction: true,\n completeTransactionError: null,\n }))\n\n trustedFrame.submitForm((errors, data) => {\n if (errors) {\n console.log('Invalid payment form submission', errors)\n setCompleteTransactionState((currentState) => ({\n ...currentState,\n isCompletingTransaction: false,\n completeTransactionError: null,\n }))\n return\n }\n\n paymentService.westpacQuickStream\n .completeTransaction({\n singleUseTokenId: data.singleUseToken.singleUseTokenId,\n formSubmissionResult,\n formSubmissionPaymentId,\n paymentSubmissionEvent,\n captchaToken,\n })\n .then(onCompleted)\n .catch((error) => {\n setCompleteTransactionState((currentState) => ({\n ...currentState,\n isCompletingTransaction: false,\n completeTransactionError: error,\n }))\n })\n })\n }, [\n captchaToken,\n formSubmissionPaymentId,\n formSubmissionResult,\n onCompleted,\n paymentSubmissionEvent,\n trustedFrame,\n ])\n\n const [{ isCancellingTransaction, cancelError }, setCancelState] =\n React.useState<{\n isCancellingTransaction: boolean\n cancelError: Error | null\n }>({\n isCancellingTransaction: false,\n cancelError: null,\n })\n\n const clearCancelError = React.useCallback(() => {\n setCancelState({\n isCancellingTransaction: false,\n cancelError: null,\n })\n }, [])\n\n const handleCancel = React.useCallback(async () => {\n setCancelState({\n isCancellingTransaction: true,\n cancelError: null,\n })\n try {\n const result = await paymentService.westpacQuickStream.cancelPayment({\n formSubmissionPaymentId,\n formSubmissionResult,\n })\n onCancelled(result)\n } catch (error) {\n console.warn('Failed to cancel payment', error)\n setCancelState({\n isCancellingTransaction: false,\n cancelError: error as Error,\n })\n }\n }, [formSubmissionPaymentId, formSubmissionResult, onCancelled])\n\n return (\n <>\n {isLoading && (\n <section>\n <div className=\"cypress-loading has-text-centered\">\n <OnLoading className=\"has-text-centered\"></OnLoading>\n <span>Building payment form...</span>\n </div>\n </section>\n )}\n\n {loadError && (\n <section className=\"cypress-payment-receipt-loading-error-message\">\n <div className=\"ob-payment-receipt__error-icon-container has-text-centered has-margin-bottom-8\">\n <i className=\"ob-payment-receipt__error-icon material-icons has-text-danger icon-x-large\">\n error\n </i>\n </div>\n <p className=\"ob-payment-receipt__error-message has-text-centered has-margin-bottom-4\">\n {loadError.message}\n </p>\n </section>\n )}\n\n <section>\n <form\n onSubmit={(event) => {\n event.preventDefault()\n handleSubmit()\n }}\n >\n <div\n data-quickstream-api=\"creditCardContainer\"\n className=\"quickstream-container\"\n ></div>\n\n {!isLoading && !loadError && (\n <>\n <ReCAPTCHA\n sitekey={captchaSiteKey}\n onChange={(newValue) => {\n setCompleteTransactionState((currentState) => ({\n ...currentState,\n captchaToken: newValue,\n displayCaptchaRequired: newValue === null,\n }))\n }}\n className=\"ob-input cypress-captcha-control westpac-payment-captcha\"\n />\n {displayCaptchaRequired && (\n <div role=\"alert\" className=\"has-margin-top-8\">\n <div className=\"has-text-danger ob-error__text cypress-required cypress-validation-message\">\n Please complete the CAPTCHA successfully\n </div>\n </div>\n )}\n\n <div className=\"payment-form-actions\">\n <button\n type=\"button\"\n disabled={isCompletingTransaction || isCancellingTransaction}\n onClick={handleCancel}\n className={clsx('button ob-button is-outlined', {\n 'is-loading': isCancellingTransaction,\n })}\n >\n Cancel\n </button>\n <button\n type=\"submit\"\n disabled={isCompletingTransaction || isCancellingTransaction}\n className={clsx('button ob-button is-success', {\n 'is-loading': isCompletingTransaction,\n })}\n >\n Make Payment\n </button>\n </div>\n </>\n )}\n </form>\n </section>\n\n <Modal\n isOpen={!!completeTransactionError}\n title=\"Payment Issue\"\n className=\"cypress-payment-error-close-button\"\n actions={\n <>\n <button\n type=\"button\"\n className=\"button ob-button cypress-payment-error-close-button is-primary\"\n onClick={clearCompleteTransactionError}\n autoFocus\n >\n Okay\n </button>\n </>\n }\n >\n <>\n <div>\n {completeTransactionError instanceof Error\n ? completeTransactionError.message\n : completeTransactionError}\n </div>\n {completeTransactionError instanceof OneBlinkAppsError && (\n <OneBlinkAppsErrorOriginalMessage\n error={completeTransactionError.originalError}\n />\n )}\n </>\n </Modal>\n\n <Modal\n isOpen={!!cancelError}\n title=\"Cancel Issue\"\n className=\"cypress-cancel-error-close-button\"\n actions={\n <>\n <button\n type=\"button\"\n className=\"button ob-button cypress-cancel-error-close-button is-primary\"\n onClick={clearCancelError}\n autoFocus\n >\n Okay\n </button>\n </>\n }\n >\n <>\n <div>\n {cancelError instanceof Error ? cancelError.message : cancelError}\n </div>\n {cancelError instanceof OneBlinkAppsError && (\n <OneBlinkAppsErrorOriginalMessage\n error={cancelError.originalError}\n />\n )}\n </>\n </Modal>\n </>\n )\n}\n\nexport default React.memo(WestpacQuickStreamPaymentForm)\n"]}
|
1
|
+
{"version":3,"file":"WestpacQuickStreamPaymentForm.js","sourceRoot":"","sources":["../../../src/components/payments/WestpacQuickStreamPaymentForm.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,cAAc,EAEd,mBAAmB,GACpB,MAAM,gBAAgB,CAAA;AAEvB,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,SAAS,MAAM,wBAA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eAAe,KAAK,CAAC,IAAI,CAAC,6BAA6B,CAAC,CAAA","sourcesContent":["import {\n OneBlinkAppsError,\n paymentService,\n submissionService,\n localisationService,\n} from '@oneblink/apps'\nimport { SubmissionTypes, SubmissionEventTypes } from '@oneblink/types'\nimport clsx from 'clsx'\nimport React from 'react'\nimport ReCAPTCHA from 'react-google-recaptcha'\nimport OnLoading from '../renderer/OnLoading'\nimport OneBlinkAppsErrorOriginalMessage from '../renderer/OneBlinkAppsErrorOriginalMessage'\nimport Modal from '../renderer/Modal'\n\ninterface TrustedFrame {\n submitForm(\n callback: (\n errors:\n | Array<{\n fieldName: string\n messages: string[]\n }>\n | undefined,\n data: {\n singleUseToken: {\n singleUseTokenId: string\n }\n },\n ) => void,\n ): void\n}\n\ndeclare global {\n interface Window {\n QuickstreamAPI: {\n init(options: { publishableApiKey: string }): void\n creditCards: {\n createTrustedFrame(\n options: unknown,\n callback: (\n errors:\n | Array<{\n fieldName: string\n messages: string[]\n }>\n | undefined,\n data: {\n trustedFrame: TrustedFrame\n },\n ) => void,\n ): void\n }\n }\n }\n}\nfunction WestpacQuickStreamPaymentForm({\n formSubmissionResult,\n paymentSubmissionEvent,\n formSubmissionPaymentId,\n supplierBusinessCode,\n publishableApiKey,\n isTestMode,\n captchaSiteKey,\n onCompleted,\n onCancelled,\n appImageUrl,\n title,\n}: {\n formSubmissionResult: submissionService.FormSubmissionResult\n paymentSubmissionEvent: SubmissionEventTypes.WestpacQuickStreamSubmissionEvent\n formSubmissionPaymentId: string\n supplierBusinessCode: string\n publishableApiKey: string\n isTestMode: boolean\n captchaSiteKey: string\n onCompleted: (result: {\n formSubmissionPayment: SubmissionTypes.FormSubmissionPayment\n paymentReceiptUrl: string\n }) => void\n onCancelled: (result: { paymentReceiptUrl: string }) => void\n appImageUrl?: string\n title?: string\n}) {\n const [\n {\n isCompletingTransaction,\n completeTransactionError,\n captchaToken,\n displayCaptchaRequired,\n },\n setCompleteTransactionState,\n ] = React.useState<{\n captchaToken: string | null\n displayCaptchaRequired: boolean\n isCompletingTransaction: boolean\n completeTransactionError: Error | null\n }>({\n isCompletingTransaction: false,\n completeTransactionError: null,\n captchaToken: null,\n displayCaptchaRequired: false,\n })\n\n const clearCompleteTransactionError = React.useCallback(() => {\n setCompleteTransactionState((currentState) => ({\n ...currentState,\n isCompletingTransaction: false,\n completeTransactionError: null,\n }))\n }, [])\n\n const [{ trustedFrame, isLoading, loadError }, setLoadState] =\n React.useState<{\n trustedFrame: TrustedFrame | null\n isLoading: boolean\n loadError: Error | null\n }>({\n trustedFrame: null,\n isLoading: true,\n loadError: null,\n })\n\n React.useEffect(() => {\n const abortController = new AbortController()\n const scriptEle = document.createElement('script')\n scriptEle.type = 'text/javascript'\n scriptEle.async = true\n\n const run = async () => {\n try {\n scriptEle.src = isTestMode\n ? 'https://api.quickstream.support.qvalent.com/rest/v1/quickstream-api-1.0.min.js'\n : 'https://api.quickstream.westpac.com.au/rest/v1/quickstream-api-1.0.min.js'\n\n await new Promise((resolve, reject) => {\n try {\n scriptEle.addEventListener(\n 'load',\n () => {\n resolve(undefined)\n },\n {\n signal: abortController.signal,\n },\n )\n\n scriptEle.addEventListener(\n 'error',\n () => {\n reject(new Error(`Failed to load the script ${scriptEle.src}`))\n },\n {\n signal: abortController.signal,\n },\n )\n\n document.body.appendChild(scriptEle)\n } catch (error) {\n console.warn('Failed to load script', error)\n reject(error)\n }\n })\n\n window.QuickstreamAPI.init({\n publishableApiKey,\n })\n const newTrustedFrame = await new Promise<TrustedFrame>(\n (resolve, reject) => {\n window.QuickstreamAPI.creditCards.createTrustedFrame(\n {\n config: {\n supplierBusinessCode,\n threeDS2: true,\n },\n iframe: {\n style: {\n width: '100%',\n },\n },\n showAcceptedCards: true,\n showRequiredIndicators: true,\n },\n (errors, data) => {\n if (errors) {\n reject(errors)\n return\n }\n resolve(data.trustedFrame)\n },\n )\n },\n )\n\n if (!abortController.signal.aborted) {\n setLoadState({\n trustedFrame: newTrustedFrame,\n isLoading: false,\n loadError: null,\n })\n }\n } catch (error) {\n if (!abortController.signal.aborted) {\n setLoadState({\n trustedFrame: null,\n isLoading: false,\n loadError: error as Error,\n })\n }\n }\n }\n\n run()\n\n return () => {\n abortController.abort()\n document.body.removeChild(scriptEle)\n }\n }, [isTestMode, publishableApiKey, supplierBusinessCode])\n\n const handleSubmit = React.useCallback(async () => {\n if (!trustedFrame) {\n return\n }\n\n if (!captchaToken) {\n setCompleteTransactionState({\n captchaToken: null,\n displayCaptchaRequired: true,\n isCompletingTransaction: false,\n completeTransactionError: null,\n })\n return\n }\n\n setCompleteTransactionState((currentState) => ({\n ...currentState,\n isCompletingTransaction: true,\n completeTransactionError: null,\n }))\n\n trustedFrame.submitForm((errors, data) => {\n if (errors) {\n console.log('Invalid payment form submission', errors)\n setCompleteTransactionState((currentState) => ({\n ...currentState,\n isCompletingTransaction: false,\n completeTransactionError: null,\n }))\n return\n }\n\n paymentService.westpacQuickStream\n .completeTransaction({\n singleUseTokenId: data.singleUseToken.singleUseTokenId,\n formSubmissionResult,\n formSubmissionPaymentId,\n paymentSubmissionEvent,\n captchaToken,\n })\n .then(onCompleted)\n .catch((error) => {\n setCompleteTransactionState((currentState) => ({\n ...currentState,\n isCompletingTransaction: false,\n completeTransactionError: error,\n }))\n })\n })\n }, [\n captchaToken,\n formSubmissionPaymentId,\n formSubmissionResult,\n onCompleted,\n paymentSubmissionEvent,\n trustedFrame,\n ])\n\n const [{ isCancellingTransaction, cancelError }, setCancelState] =\n React.useState<{\n isCancellingTransaction: boolean\n cancelError: Error | null\n }>({\n isCancellingTransaction: false,\n cancelError: null,\n })\n\n const clearCancelError = React.useCallback(() => {\n setCancelState({\n isCancellingTransaction: false,\n cancelError: null,\n })\n }, [])\n\n const handleCancel = React.useCallback(async () => {\n setCancelState({\n isCancellingTransaction: true,\n cancelError: null,\n })\n try {\n const result = await paymentService.westpacQuickStream.cancelPayment({\n formSubmissionPaymentId,\n formSubmissionResult,\n })\n onCancelled(result)\n } catch (error) {\n console.warn('Failed to cancel payment', error)\n setCancelState({\n isCancellingTransaction: false,\n cancelError: error as Error,\n })\n }\n }, [formSubmissionPaymentId, formSubmissionResult, onCancelled])\n\n return (\n <>\n {isLoading && (\n <section>\n <div className=\"cypress-loading has-text-centered\">\n <OnLoading className=\"has-text-centered\"></OnLoading>\n <span>Building payment form...</span>\n </div>\n </section>\n )}\n\n {loadError && (\n <section className=\"cypress-payment-form-loading-error-message\">\n <div className=\"ob-payment-form__error-icon-container has-text-centered has-margin-bottom-8\">\n <i className=\"ob-payment-form__error-icon material-icons has-text-danger icon-x-large\">\n error\n </i>\n </div>\n <p className=\"ob-payment-form__error-message has-text-centered has-margin-bottom-4\">\n {loadError.message}\n </p>\n </section>\n )}\n\n <section>\n <form\n onSubmit={(event) => {\n event.preventDefault()\n handleSubmit()\n }}\n >\n <div className=\"ob-payment-form__westpac-quickstream-container\">\n {!!appImageUrl && (\n <figure className=\"image is-128x128 has-margin-bottom-6 ml-auto mr-auto\">\n <img\n alt=\"Application Icon\"\n className=\"is-rounded\"\n src={appImageUrl}\n />\n </figure>\n )}\n {!!title && (\n <h3 className=\"title is-3 is-size-3-mobile ob-header__heading has-text-centered\">\n {title}\n </h3>\n )}\n <label className=\"label ob-label has-text-centered\">\n Fill out the form below to complete your secure payment.\n </label>\n\n <div className=\"ob-payment-form__westpac-quickstream-amount\">\n <div>Amount</div>\n <div className=\"ob-payment-form__westpac-quickstream-amount-value\">\n {localisationService.formatCurrency(\n formSubmissionResult.payment?.amount ?? 0,\n )}\n </div>\n </div>\n <div\n data-quickstream-api=\"creditCardContainer\"\n className=\"quickstream-credit-card-container\"\n ></div>\n {!isLoading && !loadError && (\n <>\n <ReCAPTCHA\n sitekey={captchaSiteKey}\n onChange={(newValue) => {\n setCompleteTransactionState((currentState) => ({\n ...currentState,\n captchaToken: newValue,\n displayCaptchaRequired: newValue === null,\n }))\n }}\n className=\"ob-input cypress-captcha-control ob-payment-form__westpac-quickstream-captcha\"\n />\n {displayCaptchaRequired && (\n <div role=\"alert\" className=\"has-margin-top-8\">\n <div className=\"has-text-danger ob-error__text cypress-required cypress-validation-message\">\n Please complete the CAPTCHA successfully\n </div>\n </div>\n )}\n </>\n )}\n </div>\n {!isLoading && !loadError && (\n <div className=\"ob-payment-form__westpac-quickstream-form-actions\">\n <button\n type=\"button\"\n disabled={isCompletingTransaction || isCancellingTransaction}\n onClick={handleCancel}\n className={clsx('button ob-button is-outlined', {\n 'is-loading': isCancellingTransaction,\n })}\n >\n Cancel\n </button>\n <button\n type=\"submit\"\n disabled={isCompletingTransaction || isCancellingTransaction}\n className={clsx('button ob-button is-success', {\n 'is-loading': isCompletingTransaction,\n })}\n >\n Make Payment\n </button>\n </div>\n )}\n </form>\n </section>\n\n <Modal\n isOpen={!!completeTransactionError}\n title=\"Payment Issue\"\n className=\"cypress-payment-error-close-button\"\n actions={\n <>\n <button\n type=\"button\"\n className=\"button ob-button cypress-payment-error-close-button is-primary\"\n onClick={clearCompleteTransactionError}\n autoFocus\n >\n Okay\n </button>\n </>\n }\n >\n <>\n <div>\n {completeTransactionError instanceof Error\n ? completeTransactionError.message\n : completeTransactionError}\n </div>\n {completeTransactionError instanceof OneBlinkAppsError && (\n <OneBlinkAppsErrorOriginalMessage\n error={completeTransactionError.originalError}\n />\n )}\n </>\n </Modal>\n\n <Modal\n isOpen={!!cancelError}\n title=\"Cancel Issue\"\n className=\"cypress-cancel-error-close-button\"\n actions={\n <>\n <button\n type=\"button\"\n className=\"button ob-button cypress-cancel-error-close-button is-primary\"\n onClick={clearCancelError}\n autoFocus\n >\n Okay\n </button>\n </>\n }\n >\n <>\n <div>\n {cancelError instanceof Error ? cancelError.message : cancelError}\n </div>\n {cancelError instanceof OneBlinkAppsError && (\n <OneBlinkAppsErrorOriginalMessage\n error={cancelError.originalError}\n />\n )}\n </>\n </Modal>\n </>\n )\n}\n\nexport default React.memo(WestpacQuickStreamPaymentForm)\n"]}
|
@@ -9,6 +9,11 @@ type Props = {
|
|
9
9
|
titleClassName?: string;
|
10
10
|
bodyClassName?: string;
|
11
11
|
};
|
12
|
+
export declare const ModalContainerContext: React.Context<React.RefObject<HTMLDivElement> | null>;
|
13
|
+
export declare function ModalContainerProvider({ children, className, }: {
|
14
|
+
children: React.ReactNode;
|
15
|
+
className?: string;
|
16
|
+
}): JSX.Element;
|
12
17
|
declare function Modal({ isOpen, title, children, className, cardClassName, titleClassName, bodyClassName, actions, }: Props): JSX.Element;
|
13
18
|
declare const _default: React.MemoExoticComponent<typeof Modal>;
|
14
19
|
export default _default;
|
@@ -1,12 +1,19 @@
|
|
1
1
|
import * as React from 'react';
|
2
2
|
import clsx from 'clsx';
|
3
3
|
import { Modal as MuiModal } from '@mui/material';
|
4
|
+
export const ModalContainerContext = React.createContext(null);
|
5
|
+
export function ModalContainerProvider({ children, className, }) {
|
6
|
+
const modalRef = React.useRef(null);
|
7
|
+
return (React.createElement(ModalContainerContext.Provider, { value: modalRef },
|
8
|
+
React.createElement("div", { ref: modalRef, className: className }, children)));
|
9
|
+
}
|
4
10
|
function Modal({ isOpen, title, children, className, cardClassName, titleClassName, bodyClassName, actions, }) {
|
11
|
+
const ref = React.useContext(ModalContainerContext);
|
5
12
|
return (React.createElement(MuiModal, { className: clsx('modal ob-modal', className, {
|
6
13
|
'is-active': isOpen,
|
7
14
|
}), open: isOpen, slots: {
|
8
15
|
backdrop: () => React.createElement("div", { className: "modal-background-faded" }),
|
9
|
-
} },
|
16
|
+
}, container: ref === null || ref === void 0 ? void 0 : ref.current },
|
10
17
|
React.createElement("div", { className: clsx('modal-card', cardClassName) },
|
11
18
|
title && (React.createElement("header", { className: "modal-card-head" },
|
12
19
|
React.createElement("p", { className: clsx('modal-card-title', titleClassName) }, title))),
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Modal.js","sourceRoot":"","sources":["../../../src/components/renderer/Modal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,IAAI,MAAM,MAAM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O,CACL,oBAAC,QAAQ,IACP,SAAS,EAAE,IAAI,CAAC,gBAAgB,EAAE,SAAS,EAAE;YAC3C,WAAW,EAAE,MAAM;SACpB,CAAC,EACF,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE;YACL,QAAQ,EAAE,GAAG,EAAE,CAAC,6BAAK,SAAS,EAAC,wBAAwB,GAAO;SAC/D,EACD,SAAS,EAAE,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,OAAO;QAEvB,6BAAK,SAAS,EAAE,IAAI,CAAC,YAAY,EAAE,aAAa,CAAC;YAC9C,KAAK,IAAI,CACR,gCAAQ,SAAS,EAAC,iBAAiB;gBACjC,2BAAG,SAAS,EAAE,IAAI,CAAC,kBAAkB,EAAE,cAAc,CAAC,IAAG,KAAK,CAAK,CAC5D,CACV;YACD,iCAAS,SAAS,EAAE,IAAI,CAAC,iBAAiB,EAAE,aAAa,CAAC,IACvD,QAAQ,CACD;YACT,OAAO,IAAI,gCAAQ,SAAS,EAAC,iBAAiB,IAAE,OAAO,CAAU,CAC9D,CACG,CACZ,CAAA;AACH,CAAC;AAED,eAAe,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA","sourcesContent":["import * as React from 'react'\nimport clsx from 'clsx'\nimport { Modal as MuiModal } from '@mui/material'\n\ntype Props = {\n isOpen: boolean\n title?: string\n children: React.ReactNode\n actions: React.ReactNode | null\n className?: string\n cardClassName?: string\n titleClassName?: string\n bodyClassName?: string\n}\n\nexport const ModalContainerContext =\n React.createContext<React.RefObject<HTMLDivElement> | null>(null)\n\nexport function ModalContainerProvider({\n children,\n className,\n}: {\n children: React.ReactNode\n className?: string\n}) {\n const modalRef = React.useRef<HTMLDivElement>(null)\n\n return (\n <ModalContainerContext.Provider value={modalRef}>\n <div ref={modalRef} className={className}>\n {children}\n </div>\n </ModalContainerContext.Provider>\n )\n}\n\nfunction Modal({\n isOpen,\n title,\n children,\n className,\n cardClassName,\n titleClassName,\n bodyClassName,\n actions,\n}: Props) {\n const ref = React.useContext(ModalContainerContext)\n return (\n <MuiModal\n className={clsx('modal ob-modal', className, {\n 'is-active': isOpen,\n })}\n open={isOpen}\n slots={{\n backdrop: () => <div className=\"modal-background-faded\"></div>,\n }}\n container={ref?.current}\n >\n <div className={clsx('modal-card', cardClassName)}>\n {title && (\n <header className=\"modal-card-head\">\n <p className={clsx('modal-card-title', titleClassName)}>{title}</p>\n </header>\n )}\n <section className={clsx('modal-card-body', bodyClassName)}>\n {children}\n </section>\n {actions && <footer className=\"modal-card-foot\">{actions}</footer>}\n </div>\n </MuiModal>\n )\n}\n\nexport default React.memo(Modal)\n"]}
|
@@ -1,9 +1,50 @@
|
|
1
|
-
.payment-form-actions {
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
.ob-payment-form__westpac-quickstream-form-actions {
|
2
|
+
display: flex;
|
3
|
+
gap: $size-8;
|
4
|
+
justify-content: flex-end;
|
5
|
+
margin-top: $size-5;
|
5
6
|
}
|
6
7
|
|
7
|
-
.
|
8
|
-
|
9
|
-
|
8
|
+
.ob-payment-form__westpac-quickstream-captcha {
|
9
|
+
display: flex;
|
10
|
+
justify-content: center;
|
11
|
+
}
|
12
|
+
|
13
|
+
@media only screen and (max-width: 473px) {
|
14
|
+
.ob-payment-form__westpac-quickstream-captcha {
|
15
|
+
margin-top: $size-4;
|
16
|
+
}
|
17
|
+
}
|
18
|
+
|
19
|
+
.ob-payment-form__westpac-quickstream-container {
|
20
|
+
border: 1px solid #dedede;
|
21
|
+
border-radius: 2px;
|
22
|
+
background: #fff;
|
23
|
+
padding: 1.5rem;
|
24
|
+
}
|
25
|
+
|
26
|
+
.ob-payment-form__westpac-quickstream-container
|
27
|
+
.ob-payment-form__westpac-quickstream-amount {
|
28
|
+
padding-bottom: 1.5rem;
|
29
|
+
font-size: 13px;
|
30
|
+
font-weight: 400;
|
31
|
+
color: #2d373e;
|
32
|
+
}
|
33
|
+
|
34
|
+
.ob-payment-form__westpac-quickstream-container
|
35
|
+
.ob-payment-form__westpac-quickstream-amount
|
36
|
+
.ob-payment-form__westpac-quickstream-amount-value {
|
37
|
+
font-weight: 700;
|
38
|
+
font-size: 1rem;
|
39
|
+
}
|
40
|
+
|
41
|
+
.quickstream-credit-card-container {
|
42
|
+
container-type: inline-size;
|
43
|
+
container-name: quickstream-credit-card-container;
|
44
|
+
}
|
45
|
+
|
46
|
+
@container quickstream-credit-card-container (max-width: 767px) {
|
47
|
+
#trustedFrame-creditCard {
|
48
|
+
min-height: 350px;
|
49
|
+
}
|
50
|
+
}
|
package/dist/styles.css
CHANGED
@@ -9581,16 +9581,52 @@ textarea:disabled {
|
|
9581
9581
|
outline: hsl(229, 53%, 53%) auto 3px;
|
9582
9582
|
}
|
9583
9583
|
|
9584
|
-
.payment-form-actions {
|
9584
|
+
.ob-payment-form__westpac-quickstream-form-actions {
|
9585
9585
|
display: flex;
|
9586
9586
|
gap: 0.5rem;
|
9587
9587
|
justify-content: flex-end;
|
9588
|
+
margin-top: 1.25rem;
|
9588
9589
|
}
|
9589
9590
|
|
9590
|
-
.
|
9591
|
-
|
9591
|
+
.ob-payment-form__westpac-quickstream-captcha {
|
9592
|
+
display: flex;
|
9593
|
+
justify-content: center;
|
9592
9594
|
}
|
9593
9595
|
|
9596
|
+
@media only screen and (max-width: 473px) {
|
9597
|
+
.ob-payment-form__westpac-quickstream-captcha {
|
9598
|
+
margin-top: 1.5rem;
|
9599
|
+
}
|
9600
|
+
}
|
9601
|
+
.ob-payment-form__westpac-quickstream-container {
|
9602
|
+
border: 1px solid #dedede;
|
9603
|
+
border-radius: 2px;
|
9604
|
+
background: #fff;
|
9605
|
+
padding: 1.5rem;
|
9606
|
+
}
|
9607
|
+
|
9608
|
+
.ob-payment-form__westpac-quickstream-container .ob-payment-form__westpac-quickstream-amount {
|
9609
|
+
padding-bottom: 1.5rem;
|
9610
|
+
font-size: 13px;
|
9611
|
+
font-weight: 400;
|
9612
|
+
color: #2d373e;
|
9613
|
+
}
|
9614
|
+
|
9615
|
+
.ob-payment-form__westpac-quickstream-container .ob-payment-form__westpac-quickstream-amount .ob-payment-form__westpac-quickstream-amount-value {
|
9616
|
+
font-weight: 700;
|
9617
|
+
font-size: 1rem;
|
9618
|
+
}
|
9619
|
+
|
9620
|
+
.quickstream-credit-card-container {
|
9621
|
+
container-type: inline-size;
|
9622
|
+
container-name: quickstream-credit-card-container;
|
9623
|
+
}
|
9624
|
+
|
9625
|
+
@container quickstream-credit-card-container (max-width: 767px) {
|
9626
|
+
#trustedFrame-creditCard {
|
9627
|
+
min-height: 350px;
|
9628
|
+
}
|
9629
|
+
}
|
9594
9630
|
.flatpickr-calendar {
|
9595
9631
|
background: transparent;
|
9596
9632
|
opacity: 0;
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@oneblink/apps-react",
|
3
3
|
"description": "Helper functions for OneBlink apps in ReactJS.",
|
4
|
-
"version": "5.7.0-beta.
|
4
|
+
"version": "5.7.0-beta.9",
|
5
5
|
"author": "OneBlink <developers@oneblink.io> (https://oneblink.io)",
|
6
6
|
"bugs": {
|
7
7
|
"url": "https://github.com/oneblink/apps-react/issues"
|