public function createPaymentForm(array $data)
    {
        $this->ensureApiIsConfigured();

        try {
            $data = $this
                ->getRequestOptionsResolver()
                ->resolve($data);
        } catch (ExceptionInterface $e) {
            throw new InvalidArgumentException($e->getMessage(), $e->getCode(), $e);
        }

        $fields = [
            'TPE'         => $this->config['tpe'],
            'date'        => $data['date'],
            'montant'     => $data['amount'] . $data['currency'],
            'reference'   => $data['reference'],
            'texte-libre' => $data['comment'],
            'version'     => static::VERSION,
            'lgue'        => $data['locale'],
            'societe'     => $this->config['company'],
            'mail'        => $data['email'],
        ];

        $macData = array_values($fields);

        $fields['texte-libre'] = $this->htmlEncode($data['comment']);

        if (!empty($data['schedule'])) {
            $macData[] = $fields['nbrech'] = count($data['schedule']);

            $count = 0;
            foreach ($data['schedule'] as $datum) {
                $count++;
                $macData[] = $fields['dateech' . $count] = $datum['date'];
                $macData[] = $fields['montantech' . $count] = $datum['amount'] . $data['currency'];
            }

            // Fills empty schedule
            for ($i = 2 * $count + 10; $i < 18; $i++) {
                $macData[] = null;
            }

            $options = [];
            foreach ($data['options'] as $key => $value) {
                $options = "$key=$value";
            }
            $macData[] = $fields['options'] = implode('&', $options);
        }

        $fields['MAC'] = $this->computeMac($macData);

        $fields['url_retour'] = $data['return_url'];
        $fields['url_retour_ok'] = $data['success_url'];
        $fields['url_retour_err'] = $data['failure_url'];

        return [
            'action' => $this->getEndpointUrl(static::TYPE_PAYMENT),
            'method' => 'POST',
            'fields' => $fields,
        ];
    }
public function createPaymentForm(array $data)
    {
        $this->ensureApiIsConfigured();

        try {
            $data = $this
                ->getRequestOptionsResolver()
                ->resolve($data);
        } catch (ExceptionInterface $e) {
            throw new InvalidArgumentException($e->getMessage(), $e->getCode(), $e);
        }

        $fields = [
            'TPE'         => $this->config['tpe'],
            'date'        => $data['date'],
            'montant'     => $data['amount'] . $data['currency'],
            'reference'   => $data['reference'],
            'texte-libre' => $data['comment'],
            'version'     => static::VERSION,
            'lgue'        => $data['locale'],
            'societe'     => $this->config['company'],
            'mail'        => $data['email'],
        ];

        $macData = array_values($fields);

        $fields['texte-libre'] = $this->htmlEncode($data['comment']);

        if (!empty($data['schedule'])) {
            $macData[] = $fields['nbrech'] = count($data['schedule']);

            $count = 0;
            foreach ($data['schedule'] as $datum) {
                $count++;
                $macData[] = $fields['dateech' . $count] = $datum['date'];
                $macData[] = $fields['montantech' . $count] = $datum['amount'] . $data['currency'];
            }

            // Fills empty schedule
            for ($i = 2 * $count + 10; $i < 18; $i++) {
                $macData[] = null;
            }

            $options = [];
            foreach ($data['options'] as $key => $value) {
                $options = "$key=$value";
            }
            $macData[] = $fields['options'] = implode('&', $options);
        }

        $fields['MAC'] = $this->computeMac($macData);

        $fields['url_retour'] = $data['return_url'];
        $fields['url_retour_ok'] = $data['success_url'];
        $fields['url_retour_err'] = $data['failure_url'];

        return [
            'action' => $this->getEndpointUrl(static::TYPE_PAYMENT),
            'method' => 'POST',
            'fields' => $fields,
        ];
    }
public function createPaymentForm ( array $ data ) { $ this -> ensureApiIsConfigured ( ) ; try { $ data = $ this -> getRequestOptionsResolver ( ) -> resolve ( $ data ) ; } catch ( ExceptionInterface $ e ) { throw new InvalidArgumentException ( $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e ) ; } $ fields = [ 'TPE' => $ this -> config [ 'tpe' ] , 'date' => $ data [ 'date' ] , 'montant' => $ data [ 'amount' ] . $ data [ 'currency' ] , 'reference' => $ data [ 'reference' ] , 'texte-libre' => $ data [ 'comment' ] , 'version' => static :: VERSION , 'lgue' => $ data [ 'locale' ] , 'societe' => $ this -> config [ 'company' ] , 'mail' => $ data [ 'email' ] , ] ; $ macData = array_values ( $ fields ) ; $ fields [ 'texte-libre' ] = $ this -> htmlEncode ( $ data [ 'comment' ] ) ; if ( ! empty ( $ data [ 'schedule' ] ) ) { $ macData [ ] = $ fields [ 'nbrech' ] = count ( $ data [ 'schedule' ] ) ; $ count = 0 ; foreach ( $ data [ 'schedule' ] as $ datum ) { $ count ++ ; $ macData [ ] = $ fields [ 'dateech' . $ count ] = $ datum [ 'date' ] ; $ macData [ ] = $ fields [ 'montantech' . $ count ] = $ datum [ 'amount' ] . $ data [ 'currency' ] ; } // Fills empty schedule for ( $ i = 2 * $ count + 10 ; $ i < 18 ; $ i ++ ) { $ macData [ ] = null ; } $ options = [ ] ; foreach ( $ data [ 'options' ] as $ key => $ value ) { $ options = "$key=$value" ; } $ macData [ ] = $ fields [ 'options' ] = implode ( '&' , $ options ) ; } $ fields [ 'MAC' ] = $ this -> computeMac ( $ macData ) ; $ fields [ 'url_retour' ] = $ data [ 'return_url' ] ; $ fields [ 'url_retour_ok' ] = $ data [ 'success_url' ] ; $ fields [ 'url_retour_err' ] = $ data [ 'failure_url' ] ; return [ 'action' => $ this -> getEndpointUrl ( static :: TYPE_PAYMENT ) , 'method' => 'POST' , 'fields' => $ fields , ] ; }
Creates the request form.

@param array $data

@return array
Creates the request form .