PHP code example of mews / laravel-pos

1. Go to this page and download the library: Download mews/laravel-pos 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/ */

    

mews / laravel-pos example snippets


    
    # /config/laravel-pos.php
    return [
        'banks' => [
            # array keyleri unique olmalıdır
            'kuveytpos' => [ # ilk sıradaki banka injection için default olur.
                'gateway_class'     => \Mews\Pos\Gateway\KuveytPos::class,
                'credentials'       => [
                    'merchant_id' => 'xxx',
                    'terminal_id' => 'yyyyyyy', // CustomerId
                    'user_name'   => 'zzzzzzz',
                    'secret_key'  => 'www123',
                ],
                'gateway_configs'   => [
                    'test_mode' => true,
                ],
                'gateway_endpoints' => [
                    'payment_api' => 'https://boatest.kuveytturk.com.tr/boa.virtualpos.services/Home',
                    'query_api'   => 'https://boatest.kuveytturk.com.tr/BOA.Integration.WCFService/BOA.Integration.VirtualPos/VirtualPosService.svc/Basic',
                ],
            ],
            'asseco_payten' => [
                'gateway_class'     => \Mews\Pos\Gateway\AssecoPos::class,
                'credentials'       => [
                    'merchant_id'   => '7001132146464',
                    'user_name'     => 'ISBXXXXX',
                    'user_password' => 'ISBYYYYY',
                    'secret_key'    => 'TRPZZZZZ',
                ],
                'gateway_endpoints' => [
                    'payment_api'     => 'https://entegrasyon.asseco-see.com.tr/fim/api',
                    'gateway_3d'      => 'https://entegrasyon.asseco-see.com.tr/fim/est3Dgate',
                    'gateway_3d_host' => 'https://sanalpos.sanalakpos.com.tr/fim/est3Dgate',
                ],
            ],
        ],
    ];
    

       # /config/session.php:
       return [
           // ...
           'same_site' => 'lax', # ya da 'none' deneyiniz.
       ]
       

        
        # /bootstrap/app.php
        
        use Illuminate\Foundation\Application;
        use Illuminate\Foundation\Configuration\Exceptions;
        use Illuminate\Foundation\Configuration\Middleware;
        
        return Application::configure(basePath: dirname(__DIR__))
            // ...
            ->withMiddleware(function (Middleware $middleware) {
                $middleware->validateCsrfTokens(except: [
                    '/payment/3d/response'
                ]);
            });
    

    
    # /app/Http/Middleware/VerifyCsrfToken.php
    namespace App\Http\Middleware;
    
    use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
    
    class VerifyCsrfToken extends Middleware
    {
        protected $except = [
            // success ve fail URL'lar buraya eklenecek:
            '/payment/3d/response',
        ];
    }
    

use Mews\LaravelPos\GatewayRegistry;
use Mews\LaravelPos\Facades\LaravelPos;

// Constructor injection
public function __construct(private GatewayRegistry $gatewayRegistry) {}
$pos = $this->gatewayRegistry->gateway('kuveytpos'); // PosInterface

// Facade
$pos = LaravelPos::gateway('kuveytpos');

// Tüm gateway'ler
$all = $this->gatewayRegistry->all(); // PosInterface[]

public function __construct(private \Mews\Pos\PosInterface $pos) {}