【问题标题】:codeigniter and pay-pal - nothing happens on clickcodeigniter 和 pay-pal - 点击时没有任何反应
【发布时间】:2013-10-30 14:24:04
【问题描述】:

我正在为 codeigniter found here codeigniter 2.0+、php 5.3.13 和 apache 2.2.22 使用 Pay-pal 插件。这个插件过时了吗?

所以这就是我所拥有的,问题是什么。

private function getPayPalForm( $first_name, $last_name, $amount, $registration_id ){
    $this->load->library('Paypal_Lib');        
    $this->paypal_lib->add_field('return', site_url('/register/success/'));
    $this->paypal_lib->add_field('cancel_return', site_url('/register/cancel/'));
    $this->paypal_lib->add_field('notify_url', site_url('/register/ipn/'));
    $this->paypal_lib->add_field('custom', $registration_id);
    $this->paypal_lib->add_field('item_name', 'Registration ID - '.$registration_id." for ".$first_name." ".$last_name);
    $this->paypal_lib->add_field('item_number', $registration_id );
    $this->paypal_lib->add_field('amount', $amount);
    return $this->paypal_lib->paypal_form();
}

这是插件调用的函数

function paypal_form($form_name='paypal_form') 
{
    $str = '';
    $str .= '<form method="post" action="'.$this->paypal_url.'" name="'.$form_name.'"/>' . "\n";
    foreach ($this->fields as $name => $value)
        $str .= form_hidden($name, $value) . "\n";
    $str .= '<p>'. $this->submit_btn . '</p>';
    $str .= form_close() . "\n";

    return $str;
}

所有信息都出现在我的自定义视图的正确位置。这是那个视图。

<div>
       <div class="innerwidget">
        <div class="bubble">
            <div class="rectangle"><span>Make Payment</span></div>
            <div class="triangle-l"></div>
            <div class="triangle-r"></div>
            <div class="info">
                <p>Hari Om <?php echo $firstname; ?>, you are almost done.</p>
                <p> To make your payment, please click the Pay-Pal button below.</p>

<div class="form-button-container">
    <?php echo( $paypal_form ); ?>
    <p style="font-size: 12px; color:blue;"> <b>Check out with Paypal to pay by Paypal Account or credit card.</b></p>
</div>  

            </div>
        </div>
     </div> 
</div> 

所有这一切都很好,问题是,当我点击我的按钮时没有任何反应。我没有被转发到支付宝。我正在加载 jquery 库作为我的基本模板头部分的一部分。这些库有冲突吗?

这是火灾错误输出。

<div class="form-button-container">
 <form method="post" action="https://www.sandbox.paypal.com/cgi-bin/webscr" name="paypal_form"/>
   <input type="hidden" name="rm" value="2" />
  <input type="hidden" name="cmd" value="_xclick" />
  <input type="hidden" name="currency_code" value="USD" />
   <input type="hidden" name="quantity" value="1" />
  <input type="hidden" name="business" value="mymail@gmail.com" />
   <input type="hidden" name="return" value="https://www.mydomain.org/successFunction" />
   <input type="hidden" name="cancel_return" value="https://www.mydomain.org/cancelFunction />
   <input type="hidden" name="notify_url" value="https://www.mydomain.org/ipn" />
   <input type="hidden" name="custom" value="1375" />
  <input type="hidden" name="item_name" value="2013 Annual Banquet - 2 persons" />
   <input type="hidden" name="amount" value="50" />
  <p> <input type="image" name="add" src="https://www.mydomain.org/assets/images/buttons/btn_xpressCheckout.gif" border="0" /></p>
  </form>
  <p style="font-size: 12px; color:red;"> <b>Check out with Paypal to pay by Paypal Account or credit card.</b></p>
</div> 

这是我第一次使用支付宝,我完全被难住了。

编辑: 我应该调整插件以将输入类型说为提交而不是图像吗?插件就是这样来的。

function image()
{
    $this->submit_btn = '<input type="image" name="add" src="' . base_url() . 'images/paypal-button.png" border="0" />';
}

【问题讨论】:

  • 除非贝宝改变了表单提交的工作方式,否则图书馆应该可以正常工作。您在“添加”图像上单击什么?如果是这样,可能是因为当您单击图像时浏览器不知道该做什么。您可能需要创建一些 JS 来为其分配操作
  • 请在
  • 我尝试了我在编辑中概述的...不工作

标签: php jquery codeigniter paypal


【解决方案1】:

如果其他人遇到类似问题,可以。我正在使用 jquery ajax 发布到我的操作。该操作返回我只是清空并附加到正文的 HTML。 BIG MISTAKE 我使用http://www.avramovic.info/razno/jquery/redirect/ 在 jquery stye 中进行重定向,并且效果很好。参见this post 以及

        $.post( "<?php echo base_url();?>register/finish", mydataobject, function(data){
              //bla bla
        }); 

现在我要做的就是

$().redirect('<?php echo base_url();?>register/finish', mydataobject);

希望对有需要的人有所帮助

【讨论】:

    【解决方案2】:

    我会说,是的,它已经过时了。它的版权是2006年。

    我并不是要简单地插入我自己的东西,但是由于您使用的是 CodeIgniter,我建议您使用我的 CI Library for PayPal。我维护它,多年来它对许多不同的开发人员都非常有效。

    现在,我的库不包含您在此处使用的 Payments Standard,但它确实包含 Express Checkout(以及 PayPal 提供的几乎所有其他 API),它是标准结帐表单的 API 版本。

    Express Checkout 由 SetExpressCheckout、GetExpressCheckoutDetails 和 DoExpressCheckoutPayment 组成。它需要做更多的工作,但它的限制比 Payments Standard 的限制要少,而且它可以让您在结帐体验中解放出来做不同的事情,而这是 Standard Payments 集成无法做到的。

    例如,使用 Payments Standard,即使您在 PayPal 帐户资料中启用了自动返回,也不能保证用户最终会回到您的网站。重定向需要 5 到 10 秒,用户可以(并且经常这样做)在重定向发生之前关闭浏览器。

    使用快速结帐,用户将始终在完成结帐流程之前返回您的站点,因此您可以更轻松地处理结帐过程中的事情。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-03
      • 1970-01-01
      • 1970-01-01
      • 2020-11-21
      • 2011-07-16
      • 2013-05-04
      相关资源
      最近更新 更多