Opencart中的回发和返回URL

时间:2014-06-10 11:07:17

标签: php api opencart payment-gateway

我需要有关在Opencart上查找/配置回发和返回URL的帮助。我已成功整合了Dragonpay Payment Gateway API

但是,我需要知道Postback并返回URL,以便他们可以在他们的系统上配置它。我怎么知道回发&返回网址?

    public function callback() {
    if (isset($this->request->get['txnid'])) {
        $order_id = $this->request->get['txnid'];
    } else {
        $order_id = 0;
    }
    $this->load->model('checkout/order');
    $merchantid = $this->config->get('dragonpay_email');
    $ref_no = (isset($this->request->get['refno']))?$this->request->get['refno']:'';
    $status = (isset($this->request->get['status']))?$this->request->get['status']:'';
    $result = (isset($this->request->get['message']))?$this->request->get['message']:'';
    $passwd = $this->config->get('dragonpay_pwd');
    $rdigest_str = "$order_id:$ref_no:$status:$result:$passwd";
    $chk_rdigest = sha1($rdigest_str);      
    $order_info = $this->model_checkout_order->getOrder($order_id);

    if ($order_info && isset($this->request->get['digest']) && $chk_rdigest==$this->request->get['digest']) {

        if (isset($this->request->get['status'])&&strtoupper($this->request->get['status'])=="S") {
            $order_status_id = $this->config->get('config_order_status_id');
            switch(strtoupper($result)) {
                case 'SUCESS':
                    $order_status_id = $this->config->get('dragonpay_completed_status_id');
                    break;
                case 'FAILURE':
                    $order_status_id = $this->config->get('dragonpay_failed_status_id');
                    break;
                case 'PENDING':
                    $order_status_id = $this->config->get('dragonpay_pending_status_id');
                    break;

            }
            if (!$order_info['order_status_id']) {
                $this->model_checkout_order->confirm($order_id, $order_status_id);
            } else {
                $this->model_checkout_order->update($order_id, $order_status_id);
            }
        } else {
            $this->model_checkout_order->confirm($order_id, $this->config->get('config_order_status_id'));
        }
    }
    $this->redirect($this->url->link('checkout/success', '', 'SSL'));
}

提前致谢!

1 个答案:

答案 0 :(得分:0)

回发和返回URL是您拥有控制器和操作等待访问的URL,以及对在那里发布或查询的数据执行某些操作的URL。通常它是这样的:

  1. 您开始付款交易,这意味着您准备要发送的数据,加密并将其发布/查询到付款网关网址
  2. 用户完成付款后(甚至取消付款或出现其他错误)后,付款网关会将用户重定向回特定的网址
    • 通常是成功网址错误网址
  3. 如果成功,则网址可能为http://www.yourdomain.com/index.php?route=payment/yourpaygate/success - 此处付款门会发送数据,以便您的商店可以将订单设置为付款
  4. 如果出现错误,则网址可能为http://www.yourdomain.com/index.php?route=payment/yourpaygate/fail - 您知道付款尚未完成,可以将订单设置为待处理,已取消,等等。
  5. 因此,您创建/定义这些URL,然后将它们提供给支付网关提供商。