Esempio n. 1
0
                $payment_type = (int) Configuration::get('PS_OS_PAYPAL');
                $message = $this->l('Pending payment confirmation.') . '<br />';
            } else {
                $payment_type = (int) Configuration::get('PS_OS_ERROR');
                $message = $this->l('Cart changed, please retry.') . '<br />';
            }
        }
        return array('message' => $message, 'payment_type' => (int) $payment_type);
    }
    public function getResult()
    {
        if ((int) Configuration::get('PAYPAL_SANDBOX') == 1) {
            $action_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_notify-validate';
        } else {
            $action_url = 'https://www.paypal.com/cgi-bin/webscr?cmd=_notify-validate';
        }
        $request = '';
        foreach ($_POST as $key => $value) {
            $value = urlencode(Tools::stripslashes($value));
            $request .= "&{$key}={$value}";
        }
        $handle = fopen(dirname(__FILE__) . '/log.txt', 'w+');
        fwrite($handle, $action_url . $request);
        return Tools::file_get_contents($action_url . $request);
    }
}
if (Tools::getIsset('custom')) {
    $ipn = new PayPalIPN();
    $custom = Tools::jsonDecode(Tools::getValue('custom'), true);
    $ipn->confirmOrder($custom);
}