mews/pos-bundle

Virtual POS bundle for Turkey banks.

Installs: 16

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 2

Forks: 0

Open Issues: 0

Type:symfony-bundle

0.1.2 2019-10-09 21:05 UTC

This package is auto-updated.

Last update: 2024-04-10 06:54:52 UTC


README

Temel Paket

Pos

Minimum Gereksinimler

  • PHP >= 7.1.3
  • ext-dom
  • ext-json
  • ext-SimpleXML

###Kurulum

$ composer require mews/pos-bundle

config/bundles.php içerisine aşağıdaki satırı ekleyin

<?php
return [
    // ...
    Mews\PosBundle\PosBundle::class => ['all' => true],
];

config/services.yaml içerisinde, services altına alağıdaki şekilde PosService parametresini ekleyin:

services:
    // ...

    # pos service
    Mews\PosBundle\DependencyInjection\PosService:
        arguments: ['@parameter_bag']

Aşağıdaki komutla ayarların bulunduğu yaml dosyasını proje ayar dizinine kopyalayın:

cp vendor/mews/pos-bundle/Resources/config/packages/pos.yaml config/packages/

###Kullanım

<?php

declare(strict_types=1);

namespace App\Controller;

use Mews\Pos\Exceptions\BankClassNullException;
use Mews\Pos\Exceptions\BankNotFoundException;
use Mews\PosBundle\DependencyInjection\PosService;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

class MyController extends AbstractController
{
    /**
     * @Route("/my-route", name="my-route")
     * @param Request $request
     * @param PosService $posService
     * @return Response
     * @throws BankClassNullException
     * @throws BankNotFoundException
     */
    public function index(Request $request, PosService $posService): Response
    {
        // Pos hesabını al
        $pos = $posService->getPos([
            'bank' => 'akbank',
            'model' => 'regular',
            'client_id' => 'XXXXXXXX',
            'username' => 'XXXXXXXX',
            'password' => 'XXXXXXXX',
            'env' => 'test', // test veya production. test ise; API Test Url, production ise; API Production URL kullanılır.
        ]);

        // Siparişi hazırla
        $pos->prepare([
            'id' => 'BENZERSIZ-SIPERIS-ID',
            'name' => 'John Doe', // zorunlu değil
            'email' => 'mail@customer.com', // zorunlu değil
            'user_id' => '12', // zorunlu değil
            'amount' => (double)20, // Sipariş tutarı
            'installment' => '0',
            'currency' => 'TRY',
            'ip' => $request->getClientIp(),
            'transaction' => 'pay', // pay => Auth, pre PreAuth (Direkt satış için pay, ön provizyon için pre)
        ]);

        // Ödemeyi yap
        $payment = $pos->payment([
            'number' => 'XXXXXXXXXXXXXXXX', // Kredi kartı numarası
            'month' => 'XX', // SKT ay
            'year' => 'XX', // SKT yıl, son iki hane
            'cvv' => 'XXX', // Güvenlik kodu, son üç hane
        ]);

        if ($payment->isSuccess()) {
            // ödeme başarılı
        } else {
            // Ödeme başarısız
        }

        // Sonuç
        dd($payment->response);
    }
}