I use webform as my return URL from Amazon Payments to collect additional order data from customer once their payment is pre-authorized. Once user fills out webform, I am trying to redirect them to a page according to a payment status code that I received back from Amazon Payments site. Payment status is filling in properly to a field named "payment_status" using get from Amazon URL querystring. The payment stauts field is a hidden field with a system name of "payment_status".

Once user completes form and submits, I am having trouble creating a variable redirect URL that appends the payment status code to the end of the URL.

I am using a two letter code "PR" as an example below that points to a page on my site "../payments/pr". This way, I can take user to a different page for every possible payment code received from Amazon. I am not a coder, but have placed the following snippet in the additional processing window.

<?php
$status = $form_values['submitted_tree']['payment_status'];

$node->webform['confirmation'] = url('payments/', array('query' => 'var=' . $status, 'absolute' => TRUE));

?>

I have tested the code with a manually entered field value also, but URL is still missing variable. What am I doing wrong?

Comments

mdayton’s picture

I originally posted this to an older issue that was related, but was an older post left active. http://drupal.org/node/343929

mdayton’s picture

anyone?...anyone?...Bueller?....anyone?...

marcus_gbs’s picture

I needed to do something similar and it took a bit of hacking around to find something that worked. I could not find any way to reference form data within the redirect section. I also had issues accessing form data in the additional processing section. I finally could find something that worked from additional validation.

I use a fully-qualified url (http://xxx.xxx.com/content/page-name) that is generated using the $base_url global and appending a path to it.

In additional validation, try something like:

global $base_url;
$status = $form_values['submitted_tree']['payment_status'];
$fq_url_string = {build your fully-qualified url path string here - relative to the } $base_url . '/payment/' .  $status;
variable_set($redirect_url,   $fq_url_string  );

Then, in the redirect URL section:

drupal_goto(variable_get($redirect_url, NULL));
quicksketch’s picture

Status: Active » Closed (fixed)

Support for writing custom code is no longer provided in the Webform issue queue.