PHP Worldpay 付款响应示例

发布于 2024-12-23 01:48:30 字数 232 浏览 1 评论 0原文

我正在为客户开发一个网站,要求之一是将 worldpay 付款集成到购买流程中。

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

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

谢谢!

I am developing a site for a client and one of the requirements is to integrate worldpay payments for the purchasing process.

Once the user has completed payment for a product I need to alert a licencing system to the completed payment. The worldpay documentation gives an overview of the payment response service but does not give a code example.

I have had the client set up the payment response option in their test installation but would rather not have to go about coding my own page to handle the response if someone else has already done it. Does anyone have a link to a good code example (in php)?? I have had a decent look online and have not turned up much.

Thanks!

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

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

发布评论

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

评论(4

不弃不离 2024-12-30 01:48:30

问题解决了。我最终创建了一个自定义类来处理来自 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>

Problem solved. I ended up creating a custom class to handle the response from worldpay. Here is a simplified version of my handler page in case anyone else might find it useful.

(Note: I am not really a php developer so some syntax might be a bit dodgy!)

<?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>
分开我的手 2024-12-30 01:48:30

对于通过 Google 搜索阅读本文的其他人,请参阅:worldpay 付款回复。

2015 年 3 月:

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

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

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

完成这项工作后,我再也不会碰 WorldPay,但我的客户已经向他们支付了签约费,所以我必须为他实现这一点。 :-/

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

For others who are reading this from a Google search, re: worldpay Payment response.

March 2015:

I am setting up a worldpay online payment system for a client and damn, it's terrible. They have made a mediocre system in 2011 and not bothered updating it since. It is tedious and the code examples and documentation leaves a LOT to be desired.

Worldpay still use MD5() hashing as a "highly secure method of encryption" and are still referencing various resources and server concepts that are no longer used. From a practical programming point of view DO NOT USE WORLDPAY .

They have no documentation to handle dynamic payments and still expect each payment to be completed by me sending them a .html file for them to display, rather than them sending the customer back to my website to output dynamic code.

I would never touch WorldPay after this work, but my client has already paid them for signing up with them, and so I have to implement this for him. :-/

Their customer service (UK) is also very poor.

无所的.畏惧 2024-12-30 01:48:30

看起来很像贝宝。基本上是服务器<>服务器的东西。他们在这里有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 年里发生了怎样的变化。

looks a lot like paypal. basically server<>server stuff. they have their 9 yards here. http://www.worldpay.com/support/kb/bg/pdf/custa.pdf are you looking for a full blown buy service center? b/c just receiving with a simple notification is a page or so. google has some open source stuff. http://code.google.com/p/opencart/source/browse/trunk/upload/catalog/language/english/payment/worldpay.php?spec=svn694&r=694. just google worldpay.php. if you find something, LET US KNOW. we have been considering offering WORLDPAY to our clients. My how they have changed in the last 5 years.

不寐倦长更 2024-12-30 01:48:30

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'];

    }
}

small class extension to the TGuimond - WorldPay_Response class:

<?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'];

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