Hi everybody,

I really enjoy Commerce and all its submodules!

I created a role for my comptroller. I don't want him to manage the payments (he shouldn't be able to create payment methods, or create new payments...) but I want him to be able to export (xls, csv via Views) the list of payment transactions with all data so he can directly send it to the bank (in particular for the "Commerce cheque" module).

So I want him to access (view) the "payload" of a payment transaction.
If other people have the same need, it would be great to create a new permission called "View payments payload".

I directly modified myself the payment/commerce_payment.module adding the following lines to the commerce_payment_permission() function:

    'view payments payloads' => array(
      'title' => t('View payments payloads'),
      'description' => t('Allows users to view transactions payloads.'),
      'restrict access' => TRUE,
    ),

and add "administer payments" on the user_access test on line 184 (payment/includes/commerce_payment_transaction.controller.inc):

if (user_access('view payments payloads') OR user_access('administer payments'))

After that, I only have to change the permissions for the role "comptroller" and let him "view payments payloads"

Hope this can help!

Comments

afagioli’s picture

Issue summary: View changes

Thanks for sharing,
so precious to me!

Today, it's row 193

    if (  user_access('view payments payloads') OR user_access('administer payments')) {
      if (!empty($transaction->payload)) {
        $rows[] = array(t('Payload'), '<pre>' . check_plain(print_r($transaction->payload, TRUE)) . '</pre>');
      }
    }
afagioli’s picture

rszrama’s picture

Status: Active » Closed (outdated)

I'm closing this out as outdated, because I wouldn't want to introduce a new permission at this stage in Commerce 1.x's life. However, we'll certainly ensure payload logs on Commerce 2.x have a unique permission. In the meantime, what you did was / is a great solution; I'd advise anyone with a similar need to do the same vs. us trying to figure out an upgrade path for everyone else. : D