Code Monkey home page Code Monkey logo

pos's Introduction

Türk bankaları için sanal pos paketi (PHP)

Bu paket ile amaçlanan; ortak bir arayüz sınıfı ile, tüm Türk banka sanal pos sistemlerinin kullanılabilmesidir. EST altyapısı tam olarak test edilmiş ve kullanıma hazırdır. Garanti Ödeme sistemi çalışmaktadır, fakat 3D ödeme kısmının üretim ortamında test edilmesi gerekiyor. YapıKredi Posnet sistemi çalışmaktadır, fakat 3D ödeme kısmının üretim ortamında test edilmesi gerekiyor.

EST altyapısında olan Akbank ve Ziraat bankası test edilmiştir.

Özellikler

  • Standart E-Commerce modeliyle ödeme (model => regular)
  • 3D modeliyle ödeme (model => 3d)
  • 3D Pay modeliyle ödeme (model => 3d_pay)
  • Sipariş/Ödeme sorgulama (query)
  • Sipariş/Ödeme geçmişi sorgulama (history)
  • Sipariş/Para iadesi yapma (refund)
  • Sipariş iptal etme (cancel)

Minimum Gereksinimler

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

Kurulum

Test sunucunuz üzerinde;

$ mkdir pos-test && cd pos-test
$ composer require mews/pos

config.php (Ayar dosyası)

<?php

require './vendor/autoload.php';

$host_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http') . "://$_SERVER[HTTP_HOST]";
$path = '/pos-test/';
$base_url = $host_url . $path;

$request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
$ip = $request->getClientIp();

// API kullanıcı bilgileri
$account = [
    '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.
];

// API kullanıcı hesabı ile paket bir değişkene aktarılıyor
try {
    $pos = new \Mews\Pos\Pos($account);
} catch (\Mews\Pos\Exceptions\BankNotFoundException $e) {
    var_dump($e->getCode(), $e->getMessage());
    exit();
} catch (\Mews\Pos\Exceptions\BankClassNullException $e) {
    var_dump($e->getCode(), $e->getMessage());
    exit();
}

test.php (Test Dosyası)

<?php

require 'config.php';

// Sipariş bilgileri
$order = [
    'id'            => 'BENZERSIZ-SIPERIS-ID',
    'name'          => 'John Doe', // zorunlu değil
    'email'         => '[email protected]', // zorunlu değil
    'user_id'       => '12', // zorunlu değil
    'amount'        => (double) 20, // Sipariş tutarı
    'installment'   => '0',
    'currency'      => 'TRY',
    'ip'            => $ip,
    'transaction'   => 'pay', // pay => Auth, pre PreAuth (Direkt satış için pay, ön provizyon için pre)
];

// Kredi kartı bilgieri
$card = [
    'number'        => 'XXXXXXXXXXXXXXXX', // Kredi kartı numarası
    'month'         => 'XX', // SKT ay
    'year'          => 'XX', // SKT yıl, son iki hane
    'cvv'           => 'XXX', // Güvenlik kodu, son üç hane
];

// API kullanıcısı ile oluşturulan $pos değişkenine prepare metoduyla sipariş bilgileri gönderiliyor
$pos->prepare($order);

// Ödeme tamamlanıyor
$payment = $pos->payment($card);

// Ödeme başarılı mı?
$payment->isSuccess();
//veya
$pos->isSuccess();

// Ödeme başarısız mı?
$payment->isError();
//veya
$pos->isError();

// Sonuç çıktısı
var_dump($payment->response);

Farklı Banka Sanal Poslarını Eklemek

Kendi projenizin dizinindeyken

$ cp ./vendor/mews/pos/config/pos.php ./pos_ayarlar.php

ya da;

Projenizde bir ayar dosyası oluşturup (pos_ayarlar.php gibi), paket içerisinde ./config/pos.php dosyasının içeriğini buraya kopyalayın.

<?php

return [
    // Para birimleri
    'currencies'    => [
        'TRY'       => 949,
        'USD'       => 840,
        'EUR'       => 978,
        'GBP'       => 826,
        'JPY'       => 392,
        'RUB'       => 643,
    ],

    // Banka sanal pos tanımlamaları
    'banks'         => [
        'akbank'    => [
            'name'  => 'AKBANK T.A.S.',
            'class' => \Mews\Pos\EstPos::class,
            'urls'  => [
                'production'    => 'https://www.sanalakpos.com/fim/api',
                'test'          => 'https://entegrasyon.asseco-see.com.tr/fim/api',
                'gateway'       => [
                    'production'    => 'https://www.sanalakpos.com/fim/est3Dgate',
                    'test'          => 'https://entegrasyon.asseco-see.com.tr/fim/est3Dgate',
                ],
            ]
        ],

        // Yeni eklenen banka
        'isbank'    => [
            'name'  => 'İŞ BANKASI .A.S.',
            'class' => \Mews\Pos\EstPos::class, // Altyapı sınıfı
            'urls'  => [
                'production'    => 'xxxx', // API Url
                'test'          => 'xxxx', // API Test Url
                'gateway'       => [
                    'production'    => 'xxxx', // 3d Kapı Url
                    'test'          => 'xxxx', // 3d Test Kapı Url
                ],
            ]
        ],
    ]
];

Bundan sonra nesnemizi, yeni ayarlarımıza göre oluşturup kullanmamız gerekir. Örnek:

$yeni_ayarlar = require './pos_ayarlar.php';
$pos = new \Mews\Pos\Pos($account, $yeni_ayarlar);

Örnek Kodlar

./pos/examples dizini içerisinde.

Yol Haritası

  • Dökümantasyon hazırlanacak
  • UnitTest yazılacak -> Bu hiçbir zaman olmayabilir, birisi el atarsa sevinirim :)

Değerli yorum, öneri ve katkılarınızı bekliyorum.

License

MIT

pos's People

Contributors

mewebstudio avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.