<?php

use SecurionPay\SecurionPayGateway;
use SecurionPay\Exception\SecurionPayException;
use SecurionPay\Exception\ConnectionException;
use SecurionPay\Request\ChargeRequest;
use SecurionPay\Request\RefundRequest;
use SecurionPay\Request\CustomerRequest;
use SecurionPay\Request\CardRequest;
require_once 'SecurionPay/Util/SecurionPayAutoloader.php';
\SecurionPay\Util\SecurionPayAutoloader::register();
class SecurionpayApi
{
    private $gateway = null;
    private $publicKey;
    private $privateKey;
    public function __construct()
    {
        global $securionpay4wc;
        $this->publicKey = $securionpay4wc->settings['public_key'];
        $this->privateKey = $securionpay4wc->settings['secret_key'];
    }
    /**
     * @param SecurionpayCustomer $customer
     */
    public function createCharge($customer, $cardId, $order)
    {
        $request = new ChargeRequest();
        $request->amount((int) ($order->get_total() * 100));
        $request->currency(strtoupper($order->get_order_currency()));
        $request->card($cardId);
 /**
  * @return \SecurionPay\SecurionPayGateway
  */
 protected function createGateway()
 {
     require_once __DIR__ . '/lib/SecurionPay/Util/SecurionPayAutoloader.php';
     \SecurionPay\Util\SecurionPayAutoloader::register();
     require_once __DIR__ . '/CurrencyUtils.php';
     $userAgent = 'SecurionPay-PrestaShop/' . self::VERSION . ' (PrestaShop/' . _PS_VERSION_ . ')';
     $gateway = new \SecurionPay\SecurionPayGateway($this->getPrivateKey());
     $gateway->setUserAgent($userAgent);
     return $gateway;
 }