Things don't appear to be working right now.

Baseadmin
Contributor
Contributor

I am receiving the above issue every time I tried to take payments through my website. I have gone through every 'solution' found with in the community and still nothing has remidied the issue my website can't process any payments and I have tried to get in touch with PayPal mts but have had no response.

Login to Me Too
23 REPLIES 23

Baseadmin
Contributor
Contributor

Also this is the Module I'm using.

 

class PaypalModel extends PaymentDriverModel
{
    public $payment_data = array(
        'gid'           => 'paypal',
        'name'          => 'Paypal',
        'settings_data' => 'a:1:{s:9:"seller_id";s:0:"";}',
        'logo'          => 'logo_paypal.png',
    );
    public $settings = array(
        "seller_id" => array("type" => "text", "content" => "string", "size" => "middle"),
    );
    protected $variables = array(
        "business"    => "seller_id",
        "mc_gross"    => "amount",
        "mc_currency" => "currency",
        "custom"      => "id_payment",
        "test_ipn"    => "test_mode",
    );

    public function funcRequest($payment_data, $system_settings)
    {
        $return = array("errors" => array(), "info" => array(), "data" => $payment_data);

        $send_data = array(
            "business"      => $system_settings["settings_data"]["seller_id"],
            "amount"        => $payment_data["amount"],
            "currency_code" => $payment_data["currency_gid"],
            "charset"       => 'utf-8',
            "custom"        => $payment_data["id_payment"],
            "test_ipn"      => "0",
            "rm"            => "2",
            "return"        => site_url(),
            "notify_url"    => site_url() . "payments/responce/paypal",
            "cancel_return" => site_url(),
            "cmd"           => "_xclick",
            "item_name"     => $payment_data["payment_data"]["name"],
        );
        $this->send_data("https://www.paypal.com/cgi-bin/webscr", $send_data, "post");

        return $return;
    }

    public function funcResponce($payment_data, $system_settings)
    {
        $return = array("errors" => array(), "info" => array(), "data" => array(), "type" => "exit");

        // verify
        $verify = $this->verifyData($payment_data);

        if (!$verify) {
            exit;
        }

        foreach ($this->variables as $payment_var => $site_var) {
            $return["data"][$site_var] = isset($payment_data[$payment_var]) ? $this->ci->input->xss_clean($payment_data[$payment_var]) : "";
        }

        $this->ci->load->model("Payments_model");
        $site_payment_data = $this->ci->Payments_model->get_payment_by_id($return["data"]['id_payment']);
        if (floatval($site_payment_data["amount"]) != floatval($return["data"]['amount']) ||
            $site_payment_data["currency_gid"] != $return["data"]['currency']) {
            $error = true;
        }

        //// get status
        $return["data"]["status"] = 0;
        if (isset($payment_data['payment_status'])) {
            switch ($payment_data['payment_status']) {
                case "Completed": $return["data"]["status"] = 1;
                    break;
                case "Pending": $return["data"]["status"] = 0;
                    break;
                default: $return["data"]["status"] = -1;
                    break;
            }
        }

        return $return;
    }

    public function getSettingsMap()
    {
        foreach ($this->settings as $param_id => $param_data) {
            $this->settings[$param_id]["name"] = l('system_field_' . $param_id, 'payments');
        }

        return $this->settings;
    }

    private function verifyData($payment_data)
    {
        $req = 'cmd=_notify-validate';

        foreach ($payment_data as $key => $value) {
            $req .= '&' . $key . '=' . urlencode(stripslashes($value));
        }

        $verify_url = 'www.paypal.com';

        if (function_exists('curl_init')) {
            $ch = curl_init('https://' . $verify_url . '/cgi-bin/webscr');
            curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
            curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
            curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: Close'));
            $res = curl_exec($ch);
            curl_close($ch);
        } else {
            $header = "POST /cgi-bin/webscr HTTP/1.1\r\n";
            $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
            $header .= "Content-Length: " . strlen($req) . "\r\n\r\n";

            $fp = fsockopen('ssl://' . $verify_url, 443, $errno, $errstr, 10);
            fputs($fp, $header . $req);

            while (!feof($fp)) {
                $res = fgets($fp, 1024);
                break;
            }
        }

        if (strcmp($res, "VERIFIED") == 0) {
            return true;
        } elseif (strcmp($res, "INVALID") == 0) {
        }

        return false;
    }
}

Login to Me Too

angelleye
Advisor
Advisor
I copied this code exactly and just added my account ID into the business parameter. It's working fine when I run it from my test server.

Are you guys absolutely sure the code is getting output this like when rendered on a page? What if you just copy this form code to a basic html file and load it directly? Does it work for you then?
Angell EYE - www.angelleye.com
PayPal Partner and Certified Developer - Kudos are Greatly Appreciated!
Login to Me Too

Baseadmin
Contributor
Contributor
So this is what I receive when submitting the request. console - http://joxi.ru/eAOGeJJH4Xe86A framework.js:3301 https://www.paypalobjects.com/js/xo/hermes/1.1.0/framework.js POST https://www.paypal.com/webapps/hermes/api/checkout/5GW16151C5804253G/session/createPayment 400 (Bad Request) send @ framework.js:3301 ajax @ framework.js:3164 (anonymous) @ api.js:780 w @ framework.js:7401 resolver @ promise.js:19 httpJQuery @ api.js:748 http @ api.js:703 getHttpResponse @ api.js:534 (anonymous) @ api.js:430 (anonymous) @ framework.js:7305 $eval @ framework.js:7660 $digest @ framework.js:7608 (anonymous) @ framework.js:7664 e @ framework.js:5416 (anonymous) @ framework.js:5506 setTimeout (async) Kf.l.defer @ framework.js:5504 $evalAsync @ framework.js:7663 (anonymous) @ framework.js:7264 f @ framework.js:7296 $$resolve @ framework.js:7349 resolve @ framework.js:7341 (anonymous) @ framework.js:7292 (anonymous) @ framework.js:7402 request.success @ api.js:761 j @ framework.js:1360 fireWith @ framework.js:1403 x @ framework.js:3177 b @ framework.js:3313 XMLHttpRequest.send (async) send @ framework.js:3301 ajax @ framework.js:3164 (anonymous) @ api.js:780 w @ framework.js:7401 resolver @ promise.js:19 httpJQuery @ api.js:748 http @ api.js:703 getHttpResponse @ api.js:534 (anonymous) @ api.js:430 (anonymous) @ framework.js:7305 $eval @ framework.js:7660 $digest @ framework.js:7608 $apply @ framework.js:7687 proto.$apply @ middleware.js:67 (anonymous) @ framework.js:10808 dispatch @ framework.js:1792 r.handle @ framework.js:1723
Login to Me Too

Baseadmin
Contributor
Contributor

I have had no response from anyone for a week now, can someone help me?

Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.