# Preventing payment authorization
To run a check before authorizing the payment in PayPal, use the beforePay
hook. This hook should return false
to prevent the payment or true
to proceed.
Example using the PaymentPaypalExpressProvider
component:
<template>
<PaymentPaypalExpressProvider
:afterPay="afterPayAndOrder"
:afterRedirect="toggleCartSidebar"
:useConfirmationPage="false"
:beforePay="shouldAllowAuthorizePayment"
/>
</template>
Example using the PaymentPaypalProvider
component:
<template>
<PaymentPaypalProvider
:afterPay="afterPayAndOrder"
:beforePay="shouldAllowAuthorizePayment"
/>
</template>
You can use the payment-refused-by-beforePay
slot to customize the error message:
<template>
<PaymentPaypalProvider
:afterPay="afterPayAndOrder"
:beforePay="shouldAllowAuthorizePayment"
>
<template #payment-refused-by-beforePay>
My custom message!
</template>
</PaymentPaypalProvider>
</template>
# Using Express checkout with a confirmation page
Suppose you want to prevent payment authorization in this scenario. In that case, you should add the corresponding code at the very beginning of processExpressOrder
function from this part of another document.