mirror of
https://github.com/valitydev/checkout.git
synced 2024-11-06 02:25:18 +00:00
Add onProgress message type (#344)
This commit is contained in:
parent
5111cbfdd2
commit
ba95f7b434
@ -1,4 +1,4 @@
|
||||
export const sendPostMessage = (message: 'onSuccess' | 'onError' | 'onBack') => {
|
||||
window.top.postMessage(message);
|
||||
export const sendPostMessage = (message: 'onSuccess' | 'onError' | 'onBack' | 'onProgress') => {
|
||||
window.top.postMessage(message, '*');
|
||||
console.info(`${message} message sent`);
|
||||
};
|
||||
|
@ -12,6 +12,9 @@ const handlePaymentStatusChanged = (condition: PaymentStatusChanged) => {
|
||||
case 'failed':
|
||||
sendPostMessage('onError');
|
||||
break;
|
||||
case 'pending':
|
||||
sendPostMessage('onProgress');
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
@ -36,6 +39,11 @@ export function usePostMessage(conditions: PaymentCondition[]) {
|
||||
case 'invoiceStatusChanged':
|
||||
handleInvoiceStatusChanged(lastCondition);
|
||||
break;
|
||||
case 'paymentStatusUnknown':
|
||||
case 'interactionCompleted':
|
||||
case 'paymentStarted':
|
||||
sendPostMessage('onProgress');
|
||||
break;
|
||||
}
|
||||
}, [conditions]);
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import {
|
||||
PaymentModelContext,
|
||||
ViewModelContext,
|
||||
} from 'checkout/contexts';
|
||||
import { isNil, last } from 'checkout/utils';
|
||||
import { isNil, last, sendPostMessage } from 'checkout/utils';
|
||||
|
||||
import { ResultIcon } from './ResultIcon';
|
||||
import { getPaymentFormViewId, getResultInfo, isExternalIdEmpty, isInstantPayment } from './utils';
|
||||
@ -79,7 +79,10 @@ export function PaymentResultView() {
|
||||
colorScheme="brand"
|
||||
size="lg"
|
||||
variant="link"
|
||||
onClick={() => window.open(initContext.redirectUrl, '_self')}
|
||||
onClick={() => {
|
||||
sendPostMessage('onBack');
|
||||
window.open(initContext.redirectUrl, '_self');
|
||||
}}
|
||||
>
|
||||
{l['form.button.back.to.website']}
|
||||
</Button>
|
||||
|
Loading…
Reference in New Issue
Block a user