magento自定义支付网关通知


magento custom payment gateway notification

我正在开发一个定制的支付解决方案,我一直在思考如何通知magento付款被接受或拒绝。

我有一个PaymentController.php文件,需要输入代码来处理此问题。

支付网关在下面提供一个HTTP GET请求。

http://www.websitename.co.uk/mygateway/payment/response?SessionID=&Note=&Tariff=&Status=

  1. SessionID是由支付网关分配的唯一ID

  2. 注意是由magento 生成的订单ID

  3. 关税是以便士为单位的订单价格,即100便士

  4. 状态是付款的状态,大约有10种不同的类型,状态=100是成功付款,状态=200是失败付款

所以可能是http://www.websitename.co.uk/mygateway/payment/response?SessionID=123456&Note=1000051&Tariff=300&Status=100

我不确定如何创建代码来处理这个get请求并计算出状态

我需要把代码放在paymentcontroller 的这个区域之间

public function responseAction() {
    if($this->getRequest()->isPost()) {
        /*
        /* Your gateway's code to make sure the reponse you
        /* just got is from the gatway and not from some weirdo.
        /* This generally has some checksum or other checks,
        /* and is provided by the gateway.
        /* For now, we assume that the gateway's response is valid
        */
        $validated = true;
        $orderId = '';
        if($validated) {

使用Zend_Http_Client类。

你会在zend:的这个小教程中找到你需要知道的一切

http://framework.zend.com/manual/1.12/de/zend.http.client.html

一种快速而肮脏的方法是:

$client = new Zend_Http_Client('http://www.websitename.co.uk/mygateway/payment/response?SessionID=123456&Note=1000051&Tariff=300&Status=100');
$response = $client->request();

然后检查回应和你的好去处。祝你好运