Other (offline) payment modules like "Commerce Bank transfer" provide a little form to maintain the payment status. Currently the payment status in this module can not be managed manually, which would make some sense.

I've attached some screenshots, how bank transfer solves this. I think it should work 1:1 for this module and would be a great benefit.

Comments

anybody’s picture

Category: Task » Feature request
anybody’s picture

StatusFileSize
new3.08 KB

I've now added this feature because I required it :)

Here's the code to add for a proper management of payment status:

1. Add these lines to commerce_directdebit.module:

/**
 * Implements hook_menu().
 */
function commerce_directdebit_menu() {
  $items = array();

  // Add a menu item for capturing authorizations.
  $items['admin/commerce/orders/%commerce_order/payment/%commerce_payment_transaction/directdebit-confirm'] = array(
    'title' => 'Confirm payment',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('commerce_directdebit_confirm_form', 3, 5),
    'access callback' => 'commerce_directdebit_transaction_confirm_access',
    'access arguments' => array(3, 5),
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'context' => MENU_CONTEXT_INLINE,
    'weight' => 2,
    'file' => 'includes/commerce_directdebit.admin.inc',
  );

  return $items;
}

/**
 * Access callback function to limit use to non-completed direct debit transactions.
 */
function commerce_directdebit_transaction_confirm_access($order, $transaction = NULL, $account = NULL) {
  $access = commerce_payment_transaction_access('update', $transaction, $account);
  if ($access && $transaction) {
    if (!in_array($transaction->payment_method, array('commerce_directdebit', 'commerce_directdebit_sepa'))) {
      $access = FALSE;
    }
    else if ($transaction->status == COMMERCE_PAYMENT_STATUS_SUCCESS) {
      $access = FALSE;
    }
  }
  return $access;
}

2. Add the attached "commerce_directdebit.admin.inc" to the "includes" directory.

PS: It would be very very cool, if you could add DROWL.de to the list of sponsors on the module page perhaps, if the new features helped you, and you also think this would be fair. If not, it's also okay for us. Thanks a lot in advance!

Thanks a lot to the maintainers of commerce_bank_transfer.module, whose code was a very good basis for further development of this functionality.

anybody’s picture

Status: Active » Needs review
daniel wentsch’s picture

Thanks for sharing your solution, thats exactly what I needed! Works.

davidrobinson_pw’s picture

I've rerolled Anybody's work as a git patch so it's easier to try in a make file.