【问题标题】:PHP Worldpay Payment Response ExamplePHP Worldpay 支付响应示例
【发布时间】:2012-01-29 01:27:30
【问题描述】:

我正在为客户开发一个网站,其中一项要求是为购买流程集成 worldpay 支付。

一旦用户完成对产品的付款,我需要提醒许可系统注意已完成的付款。 worldpay 文档概述了支付响应服务,但没有给出代码示例。

我已经让客户在他们的测试安装中设置了支付响应选项,但如果其他人已经这样做了,我宁愿不必编写我自己的页面来处理响应。有没有人有一个好的代码示例(在 php 中)的链接?我在网上看起来不错,但没有出现太多。

谢谢!

【问题讨论】:

  • 我不知道 Worldpay,但我不确定我是否理解 - 响应服务调用的代码不完全取决于您吗?看到只有您知道您的许可系统是如何工作的?通常,响应 URL 将包含一些唯一 ID 来识别交易 - 其他一切都取决于您
  • @Pekka - Worldpay 向客户端指定的 URL 发送一个发布请求。这篇文章包含很多与交易相关的不同参数。我正在寻找一些 php 代码来处理这个 post 请求的响应,这样我就可以将它用作我的代码的基础,它会提醒许可证服务器等。基本上我试图不重新发明轮子,因为这看起来像这是一个很常见的过程。

标签: php payment worldpay


【解决方案1】:

问题解决了。我最终创建了一个自定义类来处理来自 worldpay 的响应。这是我的处理程序页面的简化版本,以防其他人发现它有用。

(注意:我不是真正的 php 开发人员,所以有些语法可能有点狡猾!)

<?php //Worldpay 

// class definition
class WorldPay_Response {
    // define properties
    public $transaction_id = null;
    public $transaction_status = null;
    public $transaction_time = null;
    public $authorisation_amount = null;
    public $authorisation_currency = null;
    public $authorisation_amount_string = null;
    public $raw_auth_message = null;
    public $raw_auth_code = null;
    public $callback_password = null;
    public $card_type = null;
    public $authentication = null;
    public $ip_address = null;
    public $character_encoding = null;
    public $future_payment_id = null;
    public $future_payment_status_change = null;

    //custom properties not included by worldpay
    public $mc_custom_property = null;

    // constructor
    public function __construct() {
        $this->transaction_id = $_POST['transId'];
        $this->transaction_status = $_POST['transStatus']; //should be either Y (successful) or C (cancelled)
        $this->transaction_time = $_POST['transTime'];
        $this->authorisation_amount = $_POST['authAmount'];
        $this->authorisation_currency = $_POST['authCurrency'];
        $this->authorisation_amount_string = $_POST['authAmountString'];
        $this->raw_auth_message = $_POST['rawAuthMessage'];
        $this->raw_auth_code = $_POST['rawAuthCode'];
        $this->callback_password = $_POST['callbackPW'];
        $this->card_type = $_POST['cardType'];
        $this->country_match = $_POST['countryMatch']; //Y - Match, N - Mismatch, B - Not Available, I - Country not supplied, S - Issue Country not available
        $this->waf_merchant_message = $_POST['wafMerchMessage'];
        $this->authentication = $_POST['authentication'];
        $this->ip_address = $_POST['ipAddress'];
        $this->character_encoding = $_POST['charenc'];
        $this->future_payment_id = $_POST['futurePayId'];
        $this->future_payment_status_change = $_POST['futurePayStatusChange'];

        //custom properties
        $this->mc_custom_property = $_POST['MC_custom_property'];

    }
}

?>
<html>
<head><title>Thank you for your payment</title></head>
<WPDISPLAY FILE="header.html">

<?php
//Response from Worldpay
$wp_response = new WorldPay_Response();


    if($wp_response->transaction_status == "Y"){ ?>

            <strong>Transaction Details</strong><br />
     <?php
            echo "Worldpay Transaction id: " . $wp_response->transaction_id . "<br />";
            echo "Payment Status: " . $wp_response->transaction_status . "<br />";
            echo "Transaction Time: " . $wp_response->transaction_time . "<br />";
            echo "Amount: " . $wp_response->authorisation_amount_string . "<br />";
            echo "IP Address: " . $wp_response->ip_address . "<br /><br />"; 
        }else if($wp_response->transaction_status == "C") { ?>
            <strong>Transaction Cancelled</strong>
<?php } else { ?>
        Your transaction was unsuccessful.
<?php } ?>
<WPDISPLAY ITEM="banner">
<WPDISPLAY FILE="footer.html">
</html>

【讨论】:

    【解决方案2】:

    对于通过 Google 搜索阅读此内容的其他人,请回复:worldpay 付款响应。

    2015 年 3 月:

    我正在为客户建立一个 worldpay 在线支付系统,该死的,太糟糕了。他们在 2011 年制作了一个平庸的系统,从那以后就没有更新它。这很乏味,代码示例和文档还有很多不足之处。

    Worldpay 仍然使用MD5() 散列作为“高度安全的加密方法”,并且仍在引用不再使用的各种资源和服务器概念。从实际编程的角度来看不要使用 WORLDPAY

    他们没有处理动态付款的文档,并且仍然希望我向他们发送 .html 文件以供他们显示,而不是他们将客户发送回我的网站来完成每笔付款输出动态代码。

    完成这项工作后,我将永远不会接触 WorldPay,但我的客户已经支付了他们注册的费用,所以我必须为他实施这个。 :-/

    他们的客户服务(英国)也很差。

    【讨论】:

      【解决方案3】:

      看起来很像贝宝。基本上是服务器服务器的东西。他们在这里有 9 码。 http://www.worldpay.com/support/kb/bg/pdf/custa.pdf在寻找一个完整的购买服务中心吗? b/c 只收到一个简单的通知就是一个页​​面左右。谷歌有一些开源的东西。 http://code.google.com/p/opencart/source/browse/trunk/upload/catalog/language/english/payment/worldpay.php?spec=svn694&r=694。只是谷歌worldpay.php。如果您发现了什么,让我们知道。我们一直在考虑向我们的客户提供 WORLDPAY。我的他们在过去 5 年里发生了怎样的变化。

      【讨论】:

      • +1 我从来没有想过简单地搜索 worldpay.php。好主意:)
      【解决方案4】:

      对 TGuimond - WorldPay_Response 类的小类扩展:

      <?php //Worldpay 
      
      class WorldPay_Response {
          // define properties
          public $transaction_id = null;
          public $transaction_status = null;
          public $transaction_time = null;
          public $authorisation_amount = null;
          public $authorisation_currency = null;
          public $authorisation_amount_string = null;
          public $raw_auth_message = null;
          public $raw_auth_code = null;
          public $callback_password = null;
          public $card_type = null;
          public $authentication = null;
          public $ip_address = null;
          public $character_encoding = null;
          public $future_payment_id = null;
          public $future_payment_status_change = null;
      
          /* extension */
          public $name = null;
          public $address = null;
          public $town = null;
          public $email = null;
          public $desc = null;
      
          //custom properties not included by worldpay
          public $mc_custom_property = null;
      
          // constructor
          public function __construct() {
              $this->transaction_id = $_POST['transId'];
              $this->transaction_status = $_POST['transStatus']; //should be either Y (successful) or C (cancelled)
              $this->transaction_time = $_POST['transTime'];
              $this->authorisation_amount = $_POST['authAmount'];
              $this->authorisation_currency = $_POST['authCurrency'];
              $this->authorisation_amount_string = $_POST['authAmountString'];
              $this->raw_auth_message = $_POST['rawAuthMessage'];
              $this->raw_auth_code = $_POST['rawAuthCode'];
              $this->callback_password = $_POST['callbackPW'];
              $this->card_type = $_POST['cardType'];
              $this->country_match = $_POST['countryMatch']; //Y - Match, N - Mismatch, B - Not Available, I - Country not supplied, S - Issue Country not available
              $this->waf_merchant_message = $_POST['wafMerchMessage'];
              $this->authentication = $_POST['authentication'];
              $this->ip_address = $_POST['ipAddress'];
              $this->character_encoding = $_POST['charenc'];
              $this->future_payment_id = $_POST['futurePayId'];
              $this->future_payment_status_change = $_POST['futurePayStatusChange'];
      
              if(isset($_POST['name'])){
                  $this->name = $_POST['name'];
              }
      
              if(isset($_POST['address'])){
                  $this->address = $_POST['address'];
              }
      
              if(isset($_POST['town'])){
                  $this->town = $_POST['town'];
              }
      
              if(isset($_POST['email'])){
                  $this->email = $_POST['email'];
              }
      
              if(isset($_POST['desc'])){
                  $this->desc = $_POST['desc'];
              }
      
              //custom properties
              $this->mc_custom_property = $_POST['MC_custom_property'];
      
          }
      }
      

      【讨论】:

        猜你喜欢
        • 2015-08-19
        • 1970-01-01
        • 2018-11-07
        • 2023-03-22
        • 2014-01-24
        • 1970-01-01
        • 2020-03-10
        • 2013-08-28
        • 2017-12-29
        相关资源
        最近更新 更多