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.

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

duckzland’s picture

I got the problem, The form is posting nothing, seems that $vars is not transformed into hidden input element

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.

jbrown’s picture

Category: bug » support
Priority: Critical » Normal

Normally this is handled by the line

$form = simple_payments_build_form($vars);

It seems to be missing from your simple_payments_paypal_payment_form().

duckzland’s picture

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 :)

jbrown’s picture

I think the problem was just with copy of the module on your site. The line in #2 is already in the module.