1

I am integrating with the Stripe payment gateway and I need to be able to handle a post from their server to authenticate a standalone account. I am trying to follow the instructions at https://stripe.com/docs/connect/standalone-accounts

Namely, I need to provide a callback URL which will receive the data I need through request parameters.

https://mydrupalsite.com/callback?scope=read_write&code=AUTHORIZATION_CODE

I need to be able to get the scope and the code value.

Once I have that, I will need to then redirect based on their values to certain pages.

I tried creating a MENU_CALLBACK type menu item with a page callback to handle the parameters, but what I tried didn't work. Below is the code I tried.

function bh_commerce_stripe_oauth_menu() {
  $items = array();
  $items['bh_commerce_stripe_oauth/callback/%'] = array(
        'title' => 'bh_commerce_stripe_oauth_callback',
        'page callback' => '_bh_commerce_stripe_oauth_handle_callback',
        'page arguments' => array(2),
        'type' => MENU_CALLBACK     
  );
  return $items;    
}


function _bh_commerce_stripe_oauth_handle_callback($post_parm_args) {
  drupal_set_message(t('_commerce_stripe_oauth_handle_callback: called'));
  drupal_goto('<front>');
}
1

1 Answer 1

1

Your path is wrong I think. You should be able to access that callback here.

https://mydrupalsite.com/bh_commerce_stripe_oauth/callback/randomstring

So actually your hook_menu should look like this.

/* Implements hook_menu */
function bh_commerce_stripe_oauth_menu() {
  $items = array();
  $items['callback'] = array(
    'title' => 'bh_commerce_stripe_oauth_callback',
    'page callback' => '_bh_commerce_stripe_oauth_handle_callback',
    'type' => MENU_CALLBACK     
  );
  return $items;    
}

Note: You don't have any path wildcards (represented by % in your array key) in the callback you are getting that are useful. Therefore you don't need any page arguments. The interesting things are in the $_GET (or $_REQUEST).

And then to access the results something like:

function _bh_commerce_stripe_oauth_handle_callback() {
  $scope = $_GET['scope'];
  $code = $_GET['code'];
  drupal_set_message(t('_commerce_stripe_oauth_handle_callback: called'));
  drupal_goto('<front>');
}

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.