打开购物车v 2.x.x. PayPal标准插件没有回复CallBack

时间:2017-09-20 11:38:18

标签: php opencart2.x

我在购买OpenCart v.2.x.x时遇到问题。开放卡有他们的Pay Pal标准插件,但这里有一个问题是,callback()函数是为了回调而取得请求,但没有得到回复:

public function callback() {
        if (isset($this->request->post['custom'])) {
            $order_id = $this->request->post['custom'];
        } else {
            $order_id = 0;
        }

        $this->load->model('checkout/order');

        $order_info = $this->model_checkout_order->getOrder($order_id);

        if ($order_info) {
            $request = 'cmd=_notify-validate';

            foreach ($this->request->post as $key => $value) {
                $request .= '&' . $key . '=' . urlencode(html_entity_decode($value, ENT_QUOTES, 'UTF-8'));
            }

            if (!$this->config->get('pp_standard_test')) {
                $curl = curl_init('https://www.paypal.com/cgi-bin/webscr');
            } else {
                $curl = curl_init('https://www.sandbox.paypal.com/cgi-bin/webscr');
            }

            curl_setopt($curl, CURLOPT_POST, true);
            curl_setopt($curl, CURLOPT_POSTFIELDS, $request);
            curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
            curl_setopt($curl, CURLOPT_HEADER, false);
            curl_setopt($curl, CURLOPT_TIMEOUT, 30);
            curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);

            $response = curl_exec($curl);

            if (!$response) {
                $this->log->write('PP_STANDARD :: CURL failed ' . curl_error($curl) . '(' . curl_errno($curl) . ')');
            }

            if ($this->config->get('pp_standard_debug')) {
                $this->log->write('PP_STANDARD :: IPN REQUEST: ' . $request);
                $this->log->write('PP_STANDARD :: IPN RESPONSE: ' . $response);
            }

            // if ((strcmp($response, 'VERIFIED') == 0 || strcmp($response, 'UNVERIFIED') == 0) && isset($this->request->post['payment_status'])) {
            if (isset($this->request->post['payment_status']) && $this->request->post['payment_status'] == 'Completed') {
                $order_status_id = $this->config->get('config_order_status_id');

                switch($this->request->post['pp_standard_debug']) {
                    case 'Canceled_Reversal':
                        $order_status_id = $this->config->get('pp_standard_canceled_reversal_status_id');
                        break;
                    case 'Completed':
                        $receiver_match = (strtolower($this->request->post['receiver_email']) == strtolower($this->config->get('pp_standard_email')));

                        $total_paid_match = ((float)$this->request->post['mc_gross'] == $this->currency->format($order_info['total'], $order_info['currency_code'], $order_info['currency_value'], false));

                        if ($receiver_match && $total_paid_match) {
                            $order_status_id = $this->config->get('pp_standard_completed_status_id');
                        }

                        if (!$receiver_match) {
                            $this->log->write('PP_STANDARD :: RECEIVER EMAIL MISMATCH! ' . strtolower($this->request->post['receiver_email']));
                        }

                        if (!$total_paid_match) {
                            $this->log->write('PP_STANDARD :: TOTAL PAID MISMATCH! ' . $this->request->post['mc_gross']);
                        }
                        break;
                    case 'Denied':
                        $order_status_id = $this->config->get('pp_standard_denied_status_id');
                        break;
                    case 'Expired':
                        $order_status_id = $this->config->get('pp_standard_expired_status_id');
                        break;
                    case 'Failed':
                        $order_status_id = $this->config->get('pp_standard_failed_status_id');
                        break;
                    case 'Pending':
                        $order_status_id = $this->config->get('pp_standard_pending_status_id');
                        break;
                    case 'Processed':
                        $order_status_id = $this->config->get('pp_standard_processed_status_id');
                        break;
                    case 'Refunded':
                        $order_status_id = $this->config->get('pp_standard_refunded_status_id');
                        break;
                    case 'Reversed':
                        $order_status_id = $this->config->get('pp_standard_reversed_status_id');
                        break;
                    case 'Voided':
                        $order_status_id = $this->config->get('pp_standard_voided_status_id');
                        break;
                }

                $this->model_checkout_order->addOrderHistory($order_id, $order_status_id);
            } else {
                $this->model_checkout_order->addOrderHistory($order_id, $this->config->get('config_order_status_id'));
            }

            curl_close($curl);
        }
    }

所以, 这是该插件的问题,所以你也可能遇到同样的问题而且你知道如何修复它,日志写道:PP_STANDARD :: IPN RESPONSE: INVALID

谢谢。

0 个答案:

没有答案