0

I try enable payment gateway Przelewy24 with Omnipay library for Codeigniter 3.

For this I install via composer both libraries.

Library:

https://github.com/mysiar-org/omnipay-przelewy24v1

and

https://github.com/thephpleague/omnipay

Then I create controller Cart_contoller.php I add function

   use Omnipay\Omnipay;
    
         /**
         * Payment with Przelewy24
         */
        public function przelewy24_payment_post()
        {
            $przelewy24 = get_payment_gateway('przelewy24');
            if (empty($przelewy24)) {
                $this->session->set_flashdata('error', "Payment method not found!");
                echo json_encode([
                    'result' => 0
                ]);
                exit();
            }
        /** @var \Omnipay\Przelewy24\Gateway $gateway */
            $gateway = Omnipay::create('Przelewy24');
    
            $gateway->initialize([
             'merchantId' => 'xxxx',
             'posId'      => 'xxxx',
             'crc'        => 'xxxxxxxxxxxx',
             'testMode'   => true,
             ]);
    
            $params = array(
            'sessionId' => 2327398739,
            'amount' => 12.34,
            'currency' => 'PLN',
            'description' => 'Payment test',
            'returnUrl' => 'www.xxxxxx',
            'notifyUrl' => 'www.xxxxxxxxxxx',
            'card' => array(
            'email' => 'info@example.com',
            'name' => 'My name',
            'country' => 'PL',
            ),
        );
    
         $response = $gateway->purchase($params)->send();
    
           if ($response->isSuccessful()) {
          $response->redirect();
          } else {
          echo 'Failed';
                }
        }

in view page I add:

 <?php echo form_open('cart_controller/przelewy24_payment_post'); ?>
                <div class="payment-icons-container">
                    <label class="payment-icons">
                        <?php $logos = @explode(',', $payment_gateway->logos);
                        if (!empty($logos) && item_count($logos) > 0):
                            foreach ($logos as $logo): ?>
                                <img src="<?php echo base_url(); ?>assets/img/payment/<?= html_escape(trim($logo)); ?>.svg" alt="<?= html_escape(trim($logo)); ?>">
                            <?php endforeach;
                        endif; ?>
                    </label>
                </div>
                <button id="submit" class="btn btn-primary" id="card-button">
                    <span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
                    <?= trans("pay"); ?>&nbsp;<?= price_formatted($total_amount, $currency); ?>
                </button>
            <?php echo form_close(); ?><!-- form end -->

On button submit I get:

Type: Omnipay\Common\Exception\InvalidRequestException

Message: The email parameter is required

What I do wrong? Can anyone help me with this code how to correct integrate this gateway?

0 Answers0