Posted by duckzland on June 23, 2010 at 5:20am
2 followers
Jump to:
| Project: | Simple payments |
| Version: | 6.x-1.0 |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Issue Summary
I'm building a module that uses this module to link the payment process to paypal but the simple payment module only redirect to paypal login page without any purchased data posted in.
<?php
function paid_advert_payment_form($form_state, $data) {
$vars = array(
'module' => 'paid_advert',
'type' => 'paid_advert type',
'custom' => $data,
'item_name' => 'paid_advert payment',
'no_shipping' => TRUE,
'no_note' => TRUE,
'return' => url('', array('absolute' => TRUE)),
'amount' => 100,
);
$form = simple_payments_paypal_payment_form($vars);
$form['button'] = array(
'#type' => 'button',
'#value' => t('Continue to Paypal'),
);
return $form;
}
?>What could be the problem here? thanks
Comments
#1
I got the problem, The form is posting nothing, seems that $vars is not transformed into hidden input element
<?php
function simple_payments_paypal_payment_form($vars = array()) {
$vars['cmd'] = '_xclick';
$vars['notify_url'] = url(SIMPLE_PAYMENTS_PAYPAL_IPN_PATH, array('absolute' => TRUE));
if(!$vars['business'])
$vars['business'] = variable_get('simple_payments_paypal_account', '');
$form['#action'] = variable_get('simple_payments_paypal_sandbox', 0) ? SIMPLE_PAYMENTS_PAYPAL_SUBMIT_URL_SANDBOX : SIMPLE_PAYMENTS_PAYPAL_SUBMIT_URL;
// added, It can be added in the form instead here
foreach($vars as $key => $value) {
$form[$key] = array(
'#type' => 'hidden',
'#value' => $value,
);
}
return $form;
}
?>
by modifying adding the line it worked.
#2
Normally this is handled by the line
<?php$form = simple_payments_build_form($vars);
?>
It seems to be missing from your simple_payments_paypal_payment_form().
#3
It would be helpful if this is added to the guide in the module page. because I build the form using the same method as the description in the module page.
Thanks for this great module btw :)
#4
I think the problem was just with copy of the module on your site. The line in #2 is already in the module.