繁体   English   中英

无需登录 PayPal 即可将 Paypal 与 PHP 集成

[英]Paypal integration with PHP without logging into the PayPal

我们想将 PHP 与 Paypal 支付集成。 由于我们有 Paypal 企业帐户,我们希望将此付款与我们的电子商务网站集成。 我们已经尝试了以下代码。

 <?php

                    // $x = 0;
                    $y = $this->session->userdata('sub_total');

                    $discounttotal = $this->session->userdata('discount_total');
                      // $tax = $this->session->userdata('tax');
                    $shipping = $this->session->userdata('shipping');
                      $final_amount = $this->session->userdata('final_amount');
                      $z=0;
?>

<div id="paypal-button"></div>
<script>
  paypal.Button.render({
    // Configure environment
    env: 'sandbox',
    client: {
      sandbox: 'AetxekWctvziIYR4_YnKYCE7NjzwNV1duPwtOKYzjjly3Cgc4-TpaGhdeVlXY-4bRufu_S8tN9ZHdra_',
      production: 'demo_production_client_id'
    },
    // Customize button (optional)
    locale: 'en_IN',
    style: {
      size: 'small',
      color: 'gold',
      shape: 'pill',
    },

    // Enable Pay Now checkout flow (optional)
    commit: true,

    // Set up a payment
    payment: function(data, actions) {
      return actions.payment.create({
        transactions: [{
          amount: {
            total: <?php echo $final_amount;?>,
            currency: 'INR'
          }
        }]
      });
    },
    // Execute the payment
    onAuthorize: function(data, actions) {
      return actions.payment.execute().then(function() {
        // Show a confirmation message to the buyer
        /*for (var propertyName in data) {
          //alert( propertyName + " : " + data[propertyName] );
        }*/
        window.alert('Thank you for your purchase!');
        $("form").submit();
      });
    }
  }, '#paypal-button');

</script>

在运行代码时,页面上会出现贝宝按钮,当我们点击它时,它会重定向到贝宝登录页面。 问题来了,如果用户没有贝宝账户,付款将如何完成。 是否有机会通过信用卡/借记卡、手机钱包接受付款,以便将金额添加到我们的贝宝金额中。 请建议我正确的方法。 提前致谢。

您使用的是智能支付按钮,因此全球许多国家/地区的买家可以通过单击页面上的黑色按钮直接使用信用卡/借记卡付款。

但是有些国家,比如印度,没有这个。 常规的 PayPal 结帐将打开,他们需要登录或注册一个帐户。

如果您担心没有现有 PayPal 帐户的客户的体验,您应该在私人/隐身浏览器或没有存储电子邮件地址的 paypal.com cookie 的浏览器中测试流程。 您会发现输入信用卡然后选择密码并选中底部的框以立即创建PayPal帐户的流程并不复杂

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM