I think this is where things go wrong:
public function process_refund( $order_id, $amount = null, $reason = ” ) {
$user = wp_get_current_user();
if ( ! in_array( $this->rolecapturerefunddelete, $user->roles, true ) || ! in_array( ‘administrator’, $user->roles, true ) ) {
// The user can only view the data.
return new WP_Error( ‘notpermitted’, __( ‘Your user role is not allowed to refund via Worldline Online Checkout’, ‘bambora-online-checkout’ ) );
}
…
The user needs to have role ‘administrator’ and the settings must be set to ‘administrator’. Anything else leads to WP_Error.
A developer of this plugin could maybe change || to &&
Additional info: In the setting “User role for access to capture/refund/delete” teh “Shop Manager” role is selected. The problem occurs for the Administrator.
Thank you @teknikjg for the suggestion. The current logic is weird. I changed || to && and it works. This will limit the access to users with either the designated role or being an administrator, actually only returns error when user does not have the designated role and also not being an administrator.