<commit_before><?php
/**
 * Paystack extension for Joomla Icebooking Reservation System (http://icejoomla.com)
 *
 * DISCLAIMER
 * This file will not be supported if it is modified.
 *
 * @category  Paystack
 * @package   Paystack_Icebooking
 * @author    <NAME> <<EMAIL>>
 * @copyright 2016 Yabacon Valley. (https://github.com/yabacon/paystack-joomla-icebooking)
 * @license   MIT License (MIT)
 */

defined('_JEXEC') or die ( 'Restricted access' );
require_once(JPATH_COMPONENT_ADMINISTRATOR.DS.'gateways/gatewayInterface.php');
class IcebookingModelPaystack extends GatewayInterface
{

    function redir_meta($url) {
        return "<meta http-equiv=\"refresh\" content=\"0;url=" . addslashes($url) . "\" />";
    }

    public function __construct()
    {
        parent::__construct('paystack');
        $this->callbackForward = 0;
        $this->configs = $this->_getConfigurationsArray();
    }
    
    public function getSecretKey(){
        return (strtolower($this->configs['MODE'])==='live')?
            $this->configs['LIVE_SECRET_KEY'] :
            $this->configs['TEST_SECRET_KEY'] ;
    }

    public function generatePayForm(&$data)
    {
        $lg = JFactory::getLanguage();
        $activeLanguage = $lg->getTag();
        if(!strlen($activeLanguage))
        {
            $activeLanguage = 'en-GB';
        }

        // initialize a transaction
        $transactionInit = new stdClass();
        $myref=$data['bookingID'].'---'.rand(10000,99999);
        $fields = [
          'reference'     => $myref,
          'callback_url'  => $this->getCallbackUrl().
                            ((strpos($this->getCallbackUrl(), '?')===-1) ? '?' : '&').
                            'ref='.urlencode($myref).'&iscallback',
            'email'       => $data['email'],
            'amount'      => $data['gateway_amount'] * 100
        ];

        // build query from the array
        $fields_string = http_build_query($fields);

        //open connection
        $ch = curl_init();

        //set the url, number of POST vars, POST data
        curl_setopt($ch, CURLOPT_URL, 'https://api.paystack.co/transaction/initialize');

        //set the headers
        curl_setopt($ch, CURLOPT_HTTPHEADER, [
          'Authorization: Bearer ' . $this->getSecretKey(),
          "Content-Type: application/x-www-form-urlencoded"]);

        //set number of POST vars, POST data
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_SSLVERSION, 6);<commit_msg>use returntransfer for transaction initialize<commit_after><?php
/**
 * Paystack extension for Joomla Icebooking Reservation System (http://icejoomla.com)
 *
 * DISCLAIMER
 * This file will not be supported if it is modified.
 *
 * @category  Paystack
 * @package   Paystack_Icebooking
 * @author    <NAME> <<EMAIL>>
 * @copyright 2016 Yabacon Valley. (https://github.com/yabacon/paystack-joomla-icebooking)
 * @license   MIT License (MIT)
 */

defined('_JEXEC') or die ( 'Restricted access' );
require_once(JPATH_COMPONENT_ADMINISTRATOR.DS.'gateways/gatewayInterface.php');
class IcebookingModelPaystack extends GatewayInterface
{

    function redir_meta($url) {
        return "<meta http-equiv=\"refresh\" content=\"0;url=" . addslashes($url) . "\" />";
    }

    public function __construct()
    {
        parent::__construct('paystack');
        $this->callbackForward = 0;
        $this->configs = $this->_getConfigurationsArray();
    }
    
    public function getSecretKey(){
        return (strtolower($this->configs['MODE'])==='live')?
            $this->configs['LIVE_SECRET_KEY'] :
            $this->configs['TEST_SECRET_KEY'] ;
    }

    public function generatePayForm(&$data)
    {
        $lg = JFactory::getLanguage();
        $activeLanguage = $lg->getTag();
        if(!strlen($activeLanguage))
        {
            $activeLanguage = 'en-GB';
        }

        // initialize a transaction
        $transactionInit = new stdClass();
        $myref=$data['bookingID'].'---'.rand(10000,99999);
        $fields = [
          'reference'     => $myref,
          'callback_url'  => $this->getCallbackUrl().
                            ((strpos($this->getCallbackUrl(), '?')===-1) ? '?' : '&').
                            'ref='.urlencode($myref).'&iscallback',
            'email'       => $data['email'],
            'amount'      => $data['gateway_amount'] * 100
        ];

        // build query from the array
        $fields_string = http_build_query($fields);

        //open connection
        $ch = curl_init();

        //set the url, number of POST vars, POST data
        curl_setopt($ch, CURLOPT_URL, 'https://api.paystack.co/transaction/initialize');

        //set the headers
        curl_setopt($ch, CURLOPT_HTTPHEADER, [
          'Authorization: Bearer ' . $this->getSecretKey(),
          "Content-Type: application/x-www-form-urlencoded"]);

        //set number of POST vars, POST data
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_SSLVERSION, 6);
{'fraction_non_alphanumeric': 0.15162882527147087, 'fraction_numerical': 0.008884501480750246, 'mean_word_length': 2.4889807162534434, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 39, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5908568', 'n_tokens_mistral': 1597, 'n_tokens_neox': 1514, 'n_words': 294}