我正在为客户开发一个网站,其中一个要求是为采购流程整合世界支付。
用户完成产品付款后,我需要提醒许可系统完成付款。 worldpay文档概述了支付响应服务,但未提供代码示例。
我让客户在他们的测试安装中设置了付款响应选项,但是如果其他人已经完成它,则不必编写我自己的页面来处理响应。有没有人有一个良好的代码示例链接(在PHP中)?我在网上看起来很不错,并没有多少出现。
谢谢!
答案 0 :(得分:4)
问题解决了。我最终创建了一个自定义类来处理来自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>
答案 1 :(得分:1)
对于正在通过Google搜索阅读此内容的其他人,请重新:worldpay付款响应。
2015年3月:
我正在为客户建立一个支付世界级的在线支付系统,该死的,很糟糕。他们在2011年建立了一个平庸的系统,从那时起就没有打扰它了。这很乏味,代码示例和文档留下了很多不足之处。
Worldpay仍然使用MD5()
哈希作为一种高度安全的加密方法&#34;并且仍在引用不再使用的各种资源和服务器概念。从实际编程的角度来看不要使用WORLDPAY 。
他们没有处理动态付款的文档,但我仍然期望每次付款都是由我发送 .html
文件供他们显示,而不是将客户发回给我的网站输出动态代码。
在这项工作之后我永远不会接触WorldPay,但是我的客户已经付钱给他们注册,所以我必须为他实现这一点。 : - /
他们的客户服务(英国)也非常差。
答案 2 :(得分:0)
看起来很像贝宝。基本上是服务器&lt;&gt;服务器的东西。他们在这里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。只是google worldpay.php。如果你找到了什么,让我们知道。我们一直在考虑向客户提供WORLDPAY。我在过去的5年中发生了怎样的变化。
答案 3 :(得分:0)
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'];
}
}