Error PayPal gateway has rejected request. Security header is not valid (#10002: Security error) PHP Magento 2.

When you have set up a Payment Method as Paypal for your eCommerce store and might be you have faced the error of the Paypal gateway has rejected the request in Magento 2 or PHP Web application.

The error will be,
PayPal gateway has rejected the request. Security header is not valid (#10002: Security error)