printCardForm - lemonwaysas/php-client-directkit-json2 GitHub Wiki

   /**
     * This function will Get the HTML content of the "card form" and print this content to your caller page
     *
     * @param string    $moneyInToken
     * @param string    $cssUrl
     * @param string    $language
     */
    public function printCardForm($moneyInToken, $cssUrl = '', $language = 'en')
    {
        // If Payxpert
        // echo("<script>location.href = '".'https://sandbox-webkit.lemonway.fr/YOUR_COMPANY/dev/' . "?moneyintoken=" . $moneyInToken . '&p=' . urlencode($cssUrl) . '&lang=' . $language."';</script>");
        // If Atos
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, 'https://sandbox-webkit.lemonway.fr/YOUR_COMPANY/dev/' . "?moneyintoken=" . $moneyInToken . '&p=' . urlencode($cssUrl) . '&lang=' . $language);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $this->config->sslVerification);
        $server_output = curl_exec($ch);
        if (curl_errno($ch)) {
            error_log('curl_err : ' . curl_error($ch));
            throw new LwException(curl_error($ch), LwException::UNKNOWN_ERROR);
        } else {
            $returnCode = (int)curl_getinfo($ch, CURLINFO_HTTP_CODE);
            switch ($returnCode) {
                case 200:
                    curl_close($ch);
                    $parsedUrl = parse_url('https://sandbox-webkit.lemonway.fr/YOUR_COMPANY/dev/');
                    $root = strstr('https://sandbox-webkit.lemonway.fr/YOUR_COMPANY/dev/', $parsedUrl['path'], true);
                    $server_output = preg_replace("/src=\"([a-zA-Z\/\.]*)\"/i", "src=\"" . $root . "$1\"", $server_output);
                    echo($server_output);
                    break;
                default:
                    throw new Exception("An error has occured for HTTP code $returnCode", $returnCode);
                    break;
            }
        }
    }
⚠️ **GitHub.com Fallback** ⚠️