Paypal Payflow 专业库

发布于 2024-09-04 18:06:56 字数 250 浏览 11 评论 0原文

我已经在我的 Codeigniter 应用程序中集成了快速结帐功能。现在我想集成无缝贝宝,我收集 CC 信息并将其传递给贝宝(通过后端),一旦一切都获得批准,我的应用程序就会向用户显示这一点。所有这一切都无需访问 Paypal 网站。

我知道 Paypal 提供了一堆示例代码,但他们有很多不同的产品在广告中做同样的事情。

PHP 中是否有任何包装库可以用来处理所有这些?

迁移到这样的系统涉及什么样的设计决策?我需要 SSL 证书吗?

I already have an express checkout integrated with my Codeigniter application. Now I want to integrate seamless paypal where I collect the CC information and pass it to Paypal (via backend) and once everything is approved, my application shows that to the user. All this with out ever going to Paypal's website.

I know that Paypal gives a bunch of sample code but they have so many different products that advertise to do the same thing.

Is there any wrapper library in PHP that I can use for handling all this?

What sort of design decision is involved in migrating to such system? Would I need SSL certificates for this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

迷途知返 2024-09-11 18:06:56

我在 CodeIgniter 中构建了一个电子商务网站,还进行了无缝 Paypal 集成。

当我进行狩猎时,似乎没有任何非常漂亮的面向对象的包装器,但我确实注意到了一些好的尝试。

我的解决方案最终有点平淡。我从这里下载了 PHP API:
https://cms.paypal.com/cms_content/US/ en_US/files/developer/PP_PHP_NVP_Samples.zip

我将 CallerService.php 文件保存为 application/helpers/paypal_helper.php 并将其添加到 application /config/autoload.php 将其拉入应用程序。

现在,CallerService.php 需要 constants.php,因此您需要将其复制并粘贴到其中,或者将 constants.php 文件包含在你的助手目录。我只是复制并粘贴。然后,请确保为您的帐户配置所有常量。

设置完成后,我的代码看起来像这样:

  $nvp_query_string = '&PAYMENTACTION=Sale'
                . '&AMT='.urlencode($order->total)
                . '&CREDITCARDTYPE='.urlencode($this->input->post('credit_card_type'))
                . '&ACCT='.urlencode($this->input->post('acct'))
                . '&EXPDATE='.urlencode(str_pad($this->input->post('exp_date_month'), 2, '0', STR_PAD_LEFT).'20'.$this->input->post('exp_date_year'))
                . '&CVV2='.urlencode($this->input->post('cvv2_number'))
                . '&FIRSTNAME='.urlencode($first_name)
                . '&LASTNAME='.urlencode($last_name)
                . '&STREET='.urlencode($order->billing_address_1)
                . '&CITY='.urlencode($order->billing_city)
                . '&STATE='.urlencode($order->billing_state)
                . '&ZIP='.urlencode($order->billing_zip)
                . '&COUNTRYCODE=US&CURRENCYCODE=USD';

  $response = hash_call('doDirectPayment', $nvp_query_string);
  if (strpos(strtoupper($response['ACK']), 'SUCCESS') !== false) {
    // Product purchase was successful.
  }
  else {
    // Product purchase was unsuccessful.
    // The Paypal response will be in $response['ACK'].
    // The Paypal error message to show the customer will be in $response['L_LONGMESSAGE0'].
  }

它不太优雅,但绝对运行良好。

另外,您绝对需要 SSL 证书。单个域名的购买价格约为 30 美元。一开始设置它们有点困难,但是您不能跳过这一步。 SSL 保护客户的计算机和您的服务器之间的传输,因此他们的 CC 信息在经过所有服务器和路由器(或通过 WiFi 嗅探)时无法被读取。因此,只需确保在用于获取 CC 信息的表单上,表单提交到 https:// 而不是不安全的 http://。

I built an e-commerce site in CodeIgniter, also doing seamless Paypal integration.

There didn't seem to be any suuuuuper-pretty object-oriented wrappers out there when I did my hunting, but I did notice some good attempts.

My solution ended up being a bit bland. I downloaded the PHP API from here:
https://cms.paypal.com/cms_content/US/en_US/files/developer/PP_PHP_NVP_Samples.zip

I saved the CallerService.php file as application/helpers/paypal_helper.php and added it to application/config/autoload.php to pull it into the app.

Now, CallerService.php requires constants.php, so you either need to copy and paste it in, or include the constants.php file in your helpers directory. I just copied and pasted. Then, be sure to configure all the constants for your account.

Once that's set up, my code just looked like this:

  $nvp_query_string = '&PAYMENTACTION=Sale'
                . '&AMT='.urlencode($order->total)
                . '&CREDITCARDTYPE='.urlencode($this->input->post('credit_card_type'))
                . '&ACCT='.urlencode($this->input->post('acct'))
                . '&EXPDATE='.urlencode(str_pad($this->input->post('exp_date_month'), 2, '0', STR_PAD_LEFT).'20'.$this->input->post('exp_date_year'))
                . '&CVV2='.urlencode($this->input->post('cvv2_number'))
                . '&FIRSTNAME='.urlencode($first_name)
                . '&LASTNAME='.urlencode($last_name)
                . '&STREET='.urlencode($order->billing_address_1)
                . '&CITY='.urlencode($order->billing_city)
                . '&STATE='.urlencode($order->billing_state)
                . '&ZIP='.urlencode($order->billing_zip)
                . '&COUNTRYCODE=US&CURRENCYCODE=USD';

  $response = hash_call('doDirectPayment', $nvp_query_string);
  if (strpos(strtoupper($response['ACK']), 'SUCCESS') !== false) {
    // Product purchase was successful.
  }
  else {
    // Product purchase was unsuccessful.
    // The Paypal response will be in $response['ACK'].
    // The Paypal error message to show the customer will be in $response['L_LONGMESSAGE0'].
  }

It's not too elegant, but it definitely works well.

Also, you DEFINITELY need an SSL certificate. These can be purchased for $30 or so for a single domain. They are a little difficult to set up at first, but you can't skip this step. SSL protects transmission between the customer's computer and your server, so their CC info can't be read as it passes through all the servers and routers (or sniffed out through wifi) along the way. So, just make sure that, on the form you use to take CC info, the form submits to https:// and not an unsecured http://.

七秒鱼° 2024-09-11 18:06:56

我非常确定,无论您的网站如何获取敏感数据(即信用卡号),那么您都需要 ssl 证书。除非它们位于其他人的服务器 (paypal.com) 上,否则您需要注意这一点。而且,正如您所说,您不想将它们发送到 paypal.com,所以是的,您需要一个。

另外,如果您已经集成了快速结账,那么无论如何您都应该使用 ssl 证书,对吗?

I'm pretty sure that no matter what if your website is taking sensitive data (i.e. credit card number), then you need an ssl certificate. Unless they are on someone else's server (paypal.com), you need to take care of that. And, like you said, you don't want to send them to paypal.com, so yeah, you'll need one.

Also, if you already have express checkout integrated, you should be using an ssl certificate for that anyway, right?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文