PHP code example of professionalweb / paymentdrivers

1. Go to this page and download the library: Download professionalweb/paymentdrivers library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

professionalweb / paymentdrivers example snippets


class PaymentDriverFabric
{
    const DRIVER_FSG       = 'fsg';
    const DRIVER_CYBERPLAT = 'cyberplat';
    const DRIVER_RAPIDA    = 'rapida';
    const DRIVER_A3        = 'a3';

    /**
     * Get driver by name
     *
     * @param string $driverName
     * @return \professionalweb\paymentdrivers\interfaces\PaymentSystem
     */
    public static function getDriver($driverName)
    {
        $result = null;
        switch ($driverName) {
            case self::DRIVER_FSG:
                $result = self::getFsgDriver();
                break;
            case self::DRIVER_CYBERPLAT:
                $result = self::getCyberplatDriver();
                break;
            case self::DRIVER_RAPIDA:
                $result = self::getRapidaDriver();
                break;
            case self::DRIVER_A3:
                $result = self::getA3Driver();
                break;
        }
        return $result;
    }

    /**
     * Get FSG payment driver
     *
     * @return \professionalweb\paymentdrivers\interfaces\PaymentSystem
     */
    public static function getFsgDriver()
    {
        $driver = new \professionalweb\paymentdrivers\FSG\FSG;
        return $driver
                ->setCertificate(FDG_CERT_PATH)
                ->setHost(FSG_HOST)
                ->setPort(FSG_PORT)
                ->setTerminalName(FSG_TERMINAL_NAME)
                ->setIsTLS(FSG_IS_TLS);
    }

    /**
     * Get cyberplat payment driver
     *
     * @return \professionalweb\paymentdrivers\interfaces\PaymentSystem
     */
    public static function getCyberplatDriver()
    {
        $driver = new \professionalweb\paymentdrivers\cyberplat\Cyberplat();
        return $driver
                ->setAP(CYBERPLAT_AP)
                ->setOP(CYBERPLAT_OP)
                ->setSD(CYBERPLAT_SD)
                ->setTermId(CYBERPLAT_TERM_ID)
                ->setSerial(CYBERPLAT_SERIAL)
                ->setSecretKey(file_get_contents(CYBERPLAT_PATH_TO_SECRET_KEY))
                ->setPublicKey(file_get_contents(CYBERPLAT_PATH_TO_PUBLIC_KEY))
                ->setSecretKeyPassword(CYBERPLAT_SSL_KEY_PASSWORD)
                ->setNoRoute(CYBERPLAT_NO_ROUTE)
                ->setPayTool(CYBERPLAT_PAY_TOOL)
                ->setAcceptedKeys(CYBERPLAT_ACCEPT_KEYS);
    }

    /**
     * Get rapida payment driver
     *
     * @return \professionalweb\paymentdrivers\interfaces\PaymentSystem
     */
    public static function getRapidaDriver()
    {
        $driver = new \professionalweb\paymentdrivers\rapida\Rapida();
        return $driver
                ->setUrl(RAPIDA_URL)
                ->setCAPath(RAPIDA_PATH_TO_CA)
                ->setSSLCertPath(RAPIDA_PATH_TO_SSL_CERT)
                ->setSSLKeyPath(RAPIDA_PATH_TO_SSL_KEY)
                ->setSSLKeyPassword(RAPIDA_SSL_KEY_PASSWORD)
                ->setTermType(RAPIDA_TERM_TYPE)
                ->setTermId(RAPIDA_TERM_ID);
    }

    /**
     * Get A3 payment driver
     *
     * @return \professionalweb\paymentdrivers\interfaces\PaymentSystem
     */
    public static function getA3Driver()
    {
        $driver = new \professionalweb\paymentdrivers\a3\A3();
        return $driver
                ->setUrl(A3_WSDL_URL)
                ->setSSLCertificatePath(A3_PATH_TO_SSL_CERT)
                ->setSSLCertificatePassword(A3_SSL_CERT_PASSWORD)
                ->setCertificatePath(A3_PATH_TO_SIGN_CERT)
                ->setCertificatePassword(A3_SIGN_CERT_PASSWORD);
    }
}