<commit_before><?php

namespace CJSDevelopment;

use GuzzleHttp\Client;
use Illuminate\Http\Request;


define('paymentUrl', 'https://pay.cm.nl/API/v3/getTransactionUrl');
define('methodsUrl', 'https://pay.cm.nl/API/v3/getPaymentMethods');

class CmPayService
{
    /**
     * getPaymentMethods.
     *
     * @since 01-2016
     *
     * @author <NAME> <<EMAIL>>
     *
     * @param $amount
     *
     * @return bool|\Psr\Http\Message\ResponseInterface
     */
    public static function getPaymentMethods($amount)
    {
        // Standard data
        $sendObject = self::mandatoryData();

        // Optional or Flexible Data
        $sendObject['Amount'] = $amount;

        // Hash Calculation
        $sendObject['Hash'] = self::calculateHash($sendObject);

        // Get results
        $resultSet = self::transferData($sendObject, $method = 1);

        $return = json_decode($resultSet, true);

        return $return["paymentMethods"];
    }

    /**
     * getTransactionUrl gets the Transaction Url from the API.
     *
     * @since 01-2016
     *
     * @author <NAME> <<EMAIL>>
     *
     * @param $amount The amount
     * @param $method Payment Method (iDeal mostly)
     * @param $option Payment Option (Bank Code)
     * @param $parameters
     *
     * @return bool|string
     */
    public static function getTransactionUrl($amount, $method, $option, $parameters)
    {

        // Standard data
        $sendObject = self::mandatoryData();

        // Optional or Flexible Data
        $sendObject['Amount'] = $amount;
        $sendObject['Reference'] = (array_key_exists('reference', $parameters)) ? $parameters['reference'] : config('cmpayservice.reference_prefix', 'your order with').' '.config('cmpayservice.company', 'company');

        // Return Url's
        $sendObject['SuccessURL'] = (array_key_exists('SuccessURL', $parameters)) ? $parameters['SuccessURL'] : config('cmpayservice.return_url').config('cmpayservice.success_url');
        $sendObject['FailURL'] = (array_key_exists('FailURL', $parameters)) ? $parameters['FailURL'] : config('cmpayservice.return_url').config('cmpayservice.fail_url');
        $sendObject['ErrorURL'] = (array_key_exists('ErrorURL', $parameters)) ? $parameters['ErrorURL'] : config('cmpayservice.return_url').config('cmpayservice.error_url');
        $sendObject['CancelURL'] = (array_key_exists('CancelURL', $parameters)) ? $parameters['CancelURL'] : config('cmpayservice.return_url').config('cmpayservice.cancel_url');

        // Payment data
        $sendObject['PaymentMethod'] = $method;
        $sendObject['PaymentMethodOption'] = $option;

        // Hash Calculation
        $sendObject['Hash'] = self::calculateHash($sendObject);

        // Get results and return given URL
        return self::transferData($sendObject);
    }

    public static function checkPayment(Request $request, array $parameters = null)
    {
        dd($request->all());
    }













    /**
     * Not Reachable functions. Should not, will not, be not, can not. Well, of course you can, because everything can. Coffee can. Thats a Dutch joke. Totally not working in English.
     *
     * Allright, this comment block was just to make a line between public accessible methods and private(ers)!
     */<commit_msg>Return correct TransactionURL<commit_after><?php

namespace CJSDevelopment;

use GuzzleHttp\Client;
use Illuminate\Http\Request;


define('paymentUrl', 'https://pay.cm.nl/API/v3/getTransactionUrl');
define('methodsUrl', 'https://pay.cm.nl/API/v3/getPaymentMethods');

class CmPayService
{
    /**
     * getPaymentMethods.
     *
     * @since 01-2016
     *
     * @author <NAME> <<EMAIL>>
     *
     * @param $amount
     *
     * @return bool|\Psr\Http\Message\ResponseInterface
     */
    public static function getPaymentMethods($amount)
    {
        // Standard data
        $sendObject = self::mandatoryData();

        // Optional or Flexible Data
        $sendObject['Amount'] = $amount;

        // Hash Calculation
        $sendObject['Hash'] = self::calculateHash($sendObject);

        // Get results
        $resultSet = self::transferData($sendObject, $method = 1);

        $return = json_decode($resultSet, true);

        return $return["paymentMethods"];
    }

    /**
     * getTransactionUrl gets the Transaction Url from the API.
     *
     * @since 01-2016
     *
     * @author <NAME> <<EMAIL>>
     *
     * @param $amount The amount
     * @param $method Payment Method (iDeal mostly)
     * @param $option Payment Option (Bank Code)
     * @param $parameters
     *
     * @return bool|string
     */
    public static function getTransactionUrl($amount, $method, $option, $parameters)
    {

        // Standard data
        $sendObject = self::mandatoryData();

        // Optional or Flexible Data
        $sendObject['Amount'] = $amount;
        $sendObject['Reference'] = (array_key_exists('reference', $parameters)) ? $parameters['reference'] : config('cmpayservice.reference_prefix', 'your order with').' '.config('cmpayservice.company', 'company');

        // Return Url's
        $sendObject['SuccessURL'] = (array_key_exists('SuccessURL', $parameters)) ? $parameters['SuccessURL'] : config('cmpayservice.return_url').config('cmpayservice.success_url');
        $sendObject['FailURL'] = (array_key_exists('FailURL', $parameters)) ? $parameters['FailURL'] : config('cmpayservice.return_url').config('cmpayservice.fail_url');
        $sendObject['ErrorURL'] = (array_key_exists('ErrorURL', $parameters)) ? $parameters['ErrorURL'] : config('cmpayservice.return_url').config('cmpayservice.error_url');
        $sendObject['CancelURL'] = (array_key_exists('CancelURL', $parameters)) ? $parameters['CancelURL'] : config('cmpayservice.return_url').config('cmpayservice.cancel_url');

        // Payment data
        $sendObject['PaymentMethod'] = $method;
        $sendObject['PaymentMethodOption'] = $option;

        // Hash Calculation
        $sendObject['Hash'] = self::calculateHash($sendObject);

        // Get results and return given URL
        $transferData = self::transferData($sendObject);
        $returnedData = json_decode($transferData, true);

        
        return $returnedData["Transaction"]["TransactionUrl"];
    }

    public static function checkPayment(Request $request, array $parameters = null)
    {
        dd($request->all());
    }













    /**
     * Not Reachable functions. Should not, will not, be not, can not. Well, of course you can, because everything can. Coffee can. Thats a Dutch joke. Totally not working in English.
     *
     * Allright, this comment block was just to make a line between public accessible methods and private(ers)!
     */
{'fraction_non_alphanumeric': 0.141984505363528, 'fraction_numerical': 0.004469606674612634, 'mean_word_length': 3.143827160493827, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '471348', 'n_tokens_mistral': 1927, 'n_tokens_neox': 1861, 'n_words': 421}