1

I'm working on a website that communicates with a bank API. During the process, the API sends a request to a callback page. I, therefore, created a "callback_bank.php" file, and put it at the root of the drupal folder (along with index.php, cron.php, etc.) so it's accessible by http://www.mywebsite.com/callback_bank.php

How would I go about packaging/deploying that file with the custom module I created, that does the rest of the work ?

Thank you!

1 Answer 1

2

Assuming the return path is configurable with the bank, you'd be better to create a hook_menu callback to handle the bank response.

That way you can leverage the Drupal API, e.g access callback to restrict to their IP address range to prevent spoofing etc..

e.g:

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

  $items['payment/callback'] = array(
    'title' => 'Payment callback',
    'page callback' => 'MYMODULE_payment_callback_handler',
    'access callback' => 'MYMODULE_payment_callback_access',
    'type' => MENU_CALLBACK,
    'file' => 'MYMODULE.pages.inc',
  );

  return $items;
}

The bank can then request https://www.yoursite.com/payment/callback?param1=foo&param2=bar

1
  • For anyone looking at this solution : MYMODULE_payment_callback_access must return TRUE. Otherwise you'll get an "access refused" error. Thanks for the answer ! It works like a charm :)
    – Ebpo
    Jan 11, 2013 at 14:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.