<commit_before><?php

namespace Payum\PostfinanceDirectLink;

use GuzzleHttp\Client;
use Http\Message\MessageFactory;
use Payum\Core\Exception\Http\HttpException;
use Payum\Core\HttpClientInterface;
use PostFinance\DirectLink\DirectLinkMaintenanceRequest;
use PostFinance\DirectLink\DirectLinkMaintenanceResponse;
use PostFinance\DirectLink\DirectLinkPaymentRequest;
use PostFinance\DirectLink\DirectLinkPaymentResponse;
use PostFinance\ParameterFilter\ShaInParameterFilter;
use PostFinance\Passphrase;
use PostFinance\ShaComposer\AllParametersShaComposer;

class Api
{
    const TEST = 'test';
    const PRODUCTION = 'production';

    protected $options = [
        'sha-in-passphrase' => null,
        'pspid' => null,
        'user' => null,
        'password' => <PASSWORD>,
        'environment' => self::TEST,
    ];

    /**
     * @var HttpClientInterface
     */
    private $client;

    /**
     * @var MessageFactory
     */
    private $messageFactory;

    /**
     * @param array $options
     */
    public function __construct(array $options, HttpClientInterface $client, MessageFactory $messageFactory)
    {
        $this->options = $options;
        $this->client = $client;
        $this->messageFactory = $messageFactory;
    }

    /**
     * @param array $fields
     *
     * @return array
     */
    public function createTransaction(array $fields)
    {
        $passphrase = new Passphrase($this->options['sha-in-passphrase']);
        $shaComposer = new AllParametersShaComposer($passphrase);
        $shaComposer->addParameterFilter(new ShaInParameterFilter()); //optional

        $directLinkRequest = new DirectLinkPaymentRequest($shaComposer);

        if ($this->options['environment'] === self::PRODUCTION) {
            $directLinkRequest->setPostFinanceUri(DirectLinkPaymentRequest::PRODUCTION);
        } else {
            $directLinkRequest->setPostFinanceUri(DirectLinkPaymentRequest::TEST);
        }

        $directLinkRequest->setOrderid($fields['orderid']);
        $directLinkRequest->setPspid($this->options['pspid']);
        $directLinkRequest->setUserId($this->options['user']);
        $directLinkRequest->setPassword($this->options['password']);
        $directLinkRequest->setAmount($fields['amount']);<commit_msg>force amount to be int<commit_after><?php

namespace Payum\PostfinanceDirectLink;

use GuzzleHttp\Client;
use Http\Message\MessageFactory;
use Payum\Core\Exception\Http\HttpException;
use Payum\Core\HttpClientInterface;
use PostFinance\DirectLink\DirectLinkMaintenanceRequest;
use PostFinance\DirectLink\DirectLinkMaintenanceResponse;
use PostFinance\DirectLink\DirectLinkPaymentRequest;
use PostFinance\DirectLink\DirectLinkPaymentResponse;
use PostFinance\ParameterFilter\ShaInParameterFilter;
use PostFinance\Passphrase;
use PostFinance\ShaComposer\AllParametersShaComposer;

class Api
{
    const TEST = 'test';
    const PRODUCTION = 'production';

    protected $options = [
        'sha-in-passphrase' => null,
        'pspid' => null,
        'user' => null,
        'password' => <PASSWORD>,
        'environment' => self::TEST,
    ];

    /**
     * @var HttpClientInterface
     */
    private $client;

    /**
     * @var MessageFactory
     */
    private $messageFactory;

    /**
     * @param array $options
     */
    public function __construct(array $options, HttpClientInterface $client, MessageFactory $messageFactory)
    {
        $this->options = $options;
        $this->client = $client;
        $this->messageFactory = $messageFactory;
    }

    /**
     * @param array $fields
     *
     * @return array
     */
    public function createTransaction(array $fields)
    {
        $passphrase = new Passphrase($this->options['sha-in-passphrase']);
        $shaComposer = new AllParametersShaComposer($passphrase);
        $shaComposer->addParameterFilter(new ShaInParameterFilter()); //optional

        $directLinkRequest = new DirectLinkPaymentRequest($shaComposer);

        if ($this->options['environment'] === self::PRODUCTION) {
            $directLinkRequest->setPostFinanceUri(DirectLinkPaymentRequest::PRODUCTION);
        } else {
            $directLinkRequest->setPostFinanceUri(DirectLinkPaymentRequest::TEST);
        }

        $directLinkRequest->setOrderid($fields['orderid']);
        $directLinkRequest->setPspid($this->options['pspid']);
        $directLinkRequest->setUserId($this->options['user']);
        $directLinkRequest->setPassword($this->options['password']);
        $directLinkRequest->setAmount((int) $fields['amount']);
{'fraction_non_alphanumeric': 0.1251372118551043, 'fraction_numerical': 0.0, 'mean_word_length': 3.5469061876247503, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '7494475', 'n_tokens_mistral': 1274, 'n_tokens_neox': 1255, 'n_words': 208}