mehmetuluc / pos
为土耳其银行提供的虚拟POS库
0.4.7
2021-05-17 00:17 UTC
Requires
- php: ^7.1.3
- ext-dom: *
- ext-json: *
- ext-openssl: *
- ext-simplexml: *
- guzzlehttp/guzzle: ^6.3.3
- symfony/http-foundation: ^5.0
- symfony/serializer: ^5.0
Requires (Dev)
- escapestudios/symfony2-coding-standard: ^3.11
- phpunit/phpunit: ^9.0
- squizlabs/php_codesniffer: ^3.5
- symfony/var-dumper: ^5.1
README
本包的目标是使用一个公共接口类,使所有土耳其银行虚拟POS系统能够使用。
EST架构已经完全测试并通过,可以使用。Garanti支付系统正在运行,但3D支付部分需要在生产环境中测试。
YapıKredi Posnet系统中的3D支付正在运行,但cancel
和refund
操作尚未测试。
支持Finansbank的PayFor虚拟POS系统,由于Finansbank没有IP限制,因此您可以在localhost上运行examples
目录中的示例代码。
Akbank,TEB和Ziraat银行的EST架构已经测试过。
特性
- 标准电子商务模型支付(model => regular)
- 3D模型支付(model => 3d)
- 3D Pay模型支付(model => 3d_pay)
- 订单/支付查询(status)
- 订单/支付历史查询(history)
- 订单/退款(refund)
- 订单取消(cancel)
最低要求
- PHP >= 7.1.3
- ext-dom
- ext-json
- ext-openssl
- ext-SimpleXML
安装
在测试服务器上;
$ mkdir pos-test && cd pos-test $ composer require mews/pos
运行单元测试
您需要在项目的根目录中运行此行
$ ./vendor/bin/phpunit tests
config.php(配置文件)
<?php require './vendor/autoload.php'; $host_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http') . "://$_SERVER[HTTP_HOST]"; $path = '/'; $base_url = $host_url . $path; $request = \Symfony\Component\HttpFoundation\Request::createFromGlobals(); $ip = $request->getClientIp(); // API kullanıcı bilgileri $account = \Mews\Pos\Factory\AccountFactory::createEstPosAccount('akbank', 'XXXXXXX', 'XXXXXXX', 'XXXXXXX', '3d', 'XXXXXXX', \Mews\Pos\Gateways\EstPos::LANG_TR); // API kullanıcı hesabı ile paket bir değişkene aktarılıyor try { $pos = \Mews\Pos\Factory\PosFactory::createPosGateway($account); //değere göre API URL'leri test veya production değerler kullanılır. $pos->setTestMode(true); } catch (\Mews\Pos\Exceptions\BankNotFoundException $e) { dump($e->getCode(), $e->getMessage()); exit(); } catch (\Mews\Pos\Exceptions\BankClassNullException $e) { dump($e->getCode(), $e->getMessage()); exit(); }
test.php(测试文件)
<?php require 'config.php'; // Sipariş bilgileri $order = [ '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' => $ip, ]; // Kredi kartı bilgieri $card = new \Mews\Pos\Entity\Card\CreditCardEstPos('1111222233334444', '20', '01', '000'); // API kullanıcısı ile oluşturulan $pos değişkenine prepare metoduyla sipariş bilgileri gönderiliyor $pos->prepare($order, \Mews\Pos\Gateways\AbstractGateway::TX_PAY); // Ödeme tamamlanıyor, $card zorunlu değil. $pos->payment($card); // Ödeme başarılı mı? $pos->isSuccess(); // Ödeme başarısız mı? $pos->isError(); // Sonuç çıktısı dump($pos->getResponse());
添加不同的银行虚拟POS
在您的项目目录中;
$ cp ./vendor/mews/pos/config/pos.php ./pos_ayarlar.php
或者;
在您的项目中创建一个配置文件(如pos_ayarlar.php),并将包中./config/pos.php
文件的内容复制到这里。
<?php return [ //param birimleri Gateway'ler icinde tanımlıdır, özel bir mapping istemediğiniz sürece boş bırakınız 'currencies' => [ // 'TRY' => 949, // 'USD' => 840, ], // Banka sanal pos tanımlamaları 'banks' => [ 'akbank' => [ 'name' => 'AKBANK T.A.S.', 'class' => \Mews\Pos\Gateways\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\Gateways\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 ], ] ], ] ];
之后,我们需要根据新的配置创建并使用我们的对象。例如
//yeni ayar yolu ya da degeri $yeni_ayarlar = require './pos_ayarlar.php'; $pos = \Mews\Pos\Factory\PosFactory::createPosGateway($account, $yeni_ayarlar);
示例代码
位于./pos/examples
目录中。
使用Docker进行测试环境
您的机器上需要安装Docker。在项目的根目录中运行docker-compose up
命令即可。**注意**:localhost端口80需要为空。如果没有问题,您可以按https:///akbank/3d/index.php的方式访问代码示例。通过https:/// URL查看项目的examples
目录。
路线图
- 将准备文档
欢迎宝贵的评论、建议和贡献
如果发现问题或有需要添加的POS系统,请创建issue。
许可证
MIT