Why am I getting 'Access Denied' when integrating a payment app with PHP in Shopify?

There are two scenarios which cause the below error.

“errors”: [
{
“message”: “PaymentsAppConfigure access denied”,

Scenario-1: X-Shopify-Access-Token which you are passing in the request header is not a valid access token.
Scenario-2: When ever you are working with payment apps you must request access to the below scopes which are mandatory to work with Shopify Payment App Extension.
write_payment_gateways, write_payment_sessions.
This access scopes should be requested by your public app(Payment App) during the OAuth grant screen installation process.