Thursday, November 15, 2012

Payment link button to PayPal just goes to sandbox dot paypal dot com without payment details

I have a submit button that takes the user to PayPal using the form action.  When I click the PayPal link I get taken to the front page of PayPal
https://www.sandbox.paypal.com/ but there is no reference to my payment details.  The code in the helper is as follows:
 
 function PPSetVars($sandbox) {
  if ($sandbox) {
   $this->pp_vars = array(
    'server' => 'http://www.sandbox.paypal.com/cgi-bin/webscr',
    'email' => 'danwgr_1341181512_biz@gmail.com',
    'return' => $this->base_url.'/pages/pp_return',
    'cancel_return' => $this->base_url.'/pages/pp_cancel', 
    'notify_url' => $this->base_url.'/subs/process_ipn'
   );
  }
  else {
   $this->pp_vars = array(
    'server' => 'http://www.paypal.com/cgi-bin/webscr',
    'email' => 'xxxxxxxxxxxxxxxxxxxxxx',
    'return' => $this->base_url.'/pages/pp_return',
    'cancel_return' => $this->base_url.'/pages/pp_cancel',
    'notify_url' => $this->base_url.'/subs/process_ipn'
   );
  }
 }
 function PPText($sub_type) {
  switch ($sub_type) {
   case '1m': return '1 month';
   case '3m': return '3 months';
   case '6m': return '6 months';
   case '1y': return '1 year';
  }
  return 0;
 }
 function PPAmount($sub_type) {
  switch ($sub_type) {
   case '1m': return 6;
   case '3m': return 12;
   case '6m': return 18;
   case '1y': return 30;
  }
  return 0;
 }
 function PPEchoHidden($cmd, $value) {
  echo '<input type="hidden" name="'.$cmd.'" value="'.$value.'"/>';
 }
 function PPEchoForm($sub_type, $custom) {
  $text = $this->PPText($sub_type);
  $item_name = $text.' subscription';
  $amount = $this->PPAmount($sub_type);
  $text .= ' &pound'.number_format($amount, 2);
  echo '<form action="'.$this->pp_vars['server'].'" method="post">';
  $this->PPEchoHidden('cmd', '_xclick');
  $this->PPEchoHidden('business', $this->pp_vars['email']);
  $this->PPEchoHidden('item_name', $item_name);
  $this->PPEchoHidden('currency_code', 'GBP');
  $this->PPEchoHidden('amount', $amount);
  $this->PPEchoHidden('bn', 'PP-BuyNowBF');
  $this->PPEchoHidden('return', $this->pp_vars['return']);
  $this->PPEchoHidden('cancel_return', $this->pp_vars['cancel_return']);
  $this->PPEchoHidden('notify_url', $this->pp_vars['notify_url']);
  $this->PPEchoHidden('rm', '2');
  $this->PPEchoHidden('custom', $custom);
  echo '<p><div id="normaltxt">'.$text.'</div>';
  echo '<input type="submit" value="Pay With PayPal" /></p>';
  echo '</form>';
 }
 
The above code is called from the view file as follows:
 
$this->Helperfns->PPSetVars($sandbox);
$this->Helperfns->PPEchoForm('1m', $user_id);
$this->Helperfns->PPEchoForm('3m', $user_id);
$this->Helperfns->PPEchoForm('6m', $user_id);
$this->Helperfns->PPEchoForm('1y', $user_id);
Thanks.

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 

No comments: