Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

## Minimum Gereksinimler
- PHP >= 7.4
- mews/pos ^1.6
- mews/pos ^1.7
- Symfony 4|5|6|7

## Kurulum
Expand All @@ -29,7 +29,6 @@
estpos: # herhangi unique bir isim
gateway_class: Mews\Pos\Gateways\EstV3Pos
lang: !php/const Mews\Pos\PosInterface::LANG_TR # optional
test_mode: false #optional, default: false;
credentials:
payment_model: !php/const Mews\Pos\PosInterface::MODEL_3D_SECURE
merchant_id: 700xxxxxx
Expand All @@ -40,6 +39,8 @@
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' # optional, 3D Host ödemeler için zorunlu
gateway_configs:
test_mode: false #optional, default: false;
yapikredi:
gateway_class: Mews\Pos\Gateways\PosNet
credentials:
Expand Down Expand Up @@ -192,6 +193,13 @@ class SingleBankThreeDSecurePaymentController extends AbstractController
try {
$this->pos->payment($this->paymentModel, $order, $transaction, $card);
} catch (HashMismatchException $e) {
/**
* Bankadan gelen verilerin bankaya ait olmadığında bu exception oluşur.
* Veya Banka API bilgileriniz hatalı ise de oluşur.
* Eğer kütühaneden dolayı hash doğrulama hatası alıyorsanız, issue oluşturunuz.
* Issue çözülene kadar geçici olarak disable_3d_hash_check: true ayarla hash doğrulamasını devre dışı bırakabilirsiniz.
* Güvenlik açısından disable_3d_hash_check: false olarak kullanılması tavsiye edilmez.
*/
dd($e);
} catch (\Exception|\Error $e) {
dd($e);
Expand Down
6 changes: 5 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@
"email": "nuryagdy@mustapayev.com"
}
],
"scripts": {
"test": "./vendor/bin/simple-phpunit"
},
"require": {
"php": ">=7.4",
"mews/pos": "^1.6",
"mews/pos": "^1.7",
"symfony/config": "^4.0 | ^5.0 | ^6.0 | ^7.0",
"symfony/dependency-injection": "^4.0 | ^5.0 | ^6.0 | ^7.0",
"symfony/event-dispatcher": "^4.0 | ^5.0 | ^6.0 | ^7.0",
Expand All @@ -39,6 +42,7 @@
"psr/http-client": "^1.0",
"symfony/framework-bundle": "^6.4",
"symfony/http-client": "^6.4",
"symfony/monolog-bundle": "^3.10",
"symfony/phpunit-bridge": "^6.4",
"symfony/yaml": "^6.4"
},
Expand Down
31 changes: 29 additions & 2 deletions docs/EXAMPLE_CONFIGURATIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,19 @@ mews_pos:

# GarantiPos: ProvisionPassword
refund_user_password: ~

# PayFor: MbrId
mbr_id: ~
gateway_endpoints: # Required
payment_api: ~ # Required
gateway_3d: ~ # Required
gateway_3d_host: ~
query_api: ~
test_mode: false
gateway_configs:
test_mode: false
# Hash kontrolü kütühaneden dolayı başarısız sonuçlanıyorsa bu ayarla devre dışı bırakılabilir.
# Ancak hash kontrolünün devre dışı bırakılması güvenlik açığı oluşturabilir.
disable_3d_hash_check: false
```

Parametrelerin açıklamalarında hangi gateway'de neye karşılık geldiğini yazar.
Expand All @@ -83,7 +90,6 @@ mews_pos:
estpos_payten:
gateway_class: Mews\Pos\Gateways\EstV3Pos
lang: !php/const Mews\Pos\PosInterface::LANG_TR #optional
test_mode: true # optional
credentials:
payment_model: !php/const Mews\Pos\PosInterface::MODEL_3D_SECURE
merchant_id: 700XXXXXXX
Expand Down Expand Up @@ -124,10 +130,27 @@ mews_pos:
user_name: QNB_API_XXXXXXXX # UserCode: Otorizasyon sistemi kullanıcı kodu.
user_password: XXXXXXXX # Otorizasyon sistemi kullanıcı şifresi.
enc_key: XXXXXXXX # MerchantPass: 3D Secure şifresidir.
mbr_id: !php/const Mews\Pos\Entity\Account\PayForAccount::MBR_ID_FINANSBANK
gateway_endpoints:
payment_api: 'https://vpostest.qnbfinansbank.com/Gateway/XMLGate.aspx'
gateway_3d: 'https://vpostest.qnbfinansbank.com/Gateway/Default.aspx'
gateway_3d_host: 'https://vpostest.qnbfinansbank.com/Gateway/3DHost.aspx'
payfor_ziraat_katilim:
gateway_class: Mews\Pos\Gateways\PayForPos
credentials:
payment_model: !php/const Mews\Pos\PosInterface::MODEL_3D_SECURE
merchant_id: 08530000XXXXXXXX # Üye İşyeri Numarası.
user_name: QNB_API_XXXXXXXX # UserCode: Otorizasyon sistemi kullanıcı kodu.
user_password: XXXXXXXX # Otorizasyon sistemi kullanıcı şifresi.
enc_key: XXXXXXXX # MerchantPass: 3D Secure şifresidir.
mbr_id: !php/const Mews\Pos\Entity\Account\PayForAccount::MBR_ID_ZIRAAT_KATILIM
gateway_configs:
# Ziraat Katilim için hash kontrolü çalışmıyor. O yüzden devre dışı bırakıyoruz.
disable_3d_hash_check: true
gateway_endpoints:
payment_api: 'https://payfortestziraatkatilim.cordisnetwork.com/Mpi/XMLGate.aspx'
gateway_3d: 'https://payfortestziraatkatilim.cordisnetwork.com/Mpi/Default.aspx'
gateway_3d_host: 'https://payfortestziraatkatilim.cordisnetwork.com/Mpi/3DHost.aspx'
garanti:
gateway_class: Mews\Pos\Gateways\GarantiPos
credentials:
Expand All @@ -142,6 +165,8 @@ mews_pos:
gateway_endpoints:
payment_api: 'https://sanalposprovtest.garantibbva.com.tr/VPServlet'
gateway_3d: 'https://sanalposprovtest.garantibbva.com.tr/servlet/gt3dengine'
gateway_configs:
test_mode: false # Test ortamı için true yapılması gerekir.
interpos_denizbank:
gateway_class: Mews\Pos\Gateways\InterPos
credentials:
Expand All @@ -166,6 +191,8 @@ mews_pos:
payment_api: 'https://boatest.kuveytturk.com.tr/boa.virtualpos.services/Home'
gateway_3d: 'https://boatest.kuveytturk.com.tr/boa.virtualpos.services/Home/ThreeDModelPayGate'
query_api: 'https://boatest.kuveytturk.com.tr/BOA.Integration.WCFService/BOA.Integration.VirtualPos/VirtualPosService.svc?wsdl'
gateway_configs:
test_mode: false # Testlerinizi SSL olmayan ortamda yapıyorsanız true yapmanız gerekir.
vakifkatilim:
gateway_class: Mews\Pos\Gateways\VakifKatilimPos
credentials:
Expand Down
9 changes: 7 additions & 2 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
beStrictAboutCoversAnnotation="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
convertDeprecationsToExceptions="true"
convertDeprecationsToExceptions="false"
failOnRisky="true"
failOnWarning="true"
cacheResultFile="./var/.phpunit.result.cache"
verbose="true">
<testsuites>
Expand All @@ -20,6 +19,12 @@
<directory>tests/Integration</directory>
</testsuite>
</testsuites>
<php>
<env name="KERNEL_CLASS" value="Mews\PosBundle\Tests\Kernel\Kernel"/>
<env name="APP_ENV" value="test"/>
<env name="APP_DEBUG" value="1"/>
<env name="SYMFONY_DEPRECATIONS_HELPER" value="weak"/>
</php>

<!-- <coverage cacheDirectory="var/code-coverage"-->
<!-- processUncoveredFiles="true">-->
Expand Down
16 changes: 15 additions & 1 deletion src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public function getConfigTreeBuilder(): TreeBuilder
->end()
->scalarNode('refund_user_name')->info("GarantiPos: ProvUserID;")->end()
->scalarNode('refund_user_password')->info("GarantiPos: ProvisionPassword")->end()
->scalarNode('mbr_id')->info("PayFor: MbrId")->end()
->end()
->end()
->arrayNode('gateway_endpoints')->isRequired()
Expand All @@ -58,7 +59,20 @@ public function getConfigTreeBuilder(): TreeBuilder
->scalarNode('query_api')->cannotBeEmpty()->end()
->end()
->end()
->booleanNode('test_mode')->defaultFalse()->end()
->booleanNode('test_mode')
->defaultFalse()
->setDeprecated('mews/pos-bundle', '1.2.0', '"test_mode" is deprecated, please define it under "gateway_configs" node.')
->end()
->arrayNode('gateway_configs')
->children()
->booleanNode('test_mode')->defaultFalse()->end()
->booleanNode('disable_3d_hash_check')
->defaultFalse()
->info('Hash kontrolü kütühaneden dolayı başarısız sonuçlanıyorsa bu ayarla devre dışı bırakılabilir.
Ancak hash kontrolünün devre dışı bırakılması güvenlik açığı oluşturabilir.')
->end()
->end()
->end()
->end()
->end()
->defaultValue([])
Expand Down
2 changes: 2 additions & 0 deletions src/Gateway/AccountFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Mews\Pos\Entity\Account\AbstractPosAccount;
use Mews\Pos\Entity\Account\PayFlexAccount;
use Mews\Pos\Entity\Account\PayForAccount;
use Mews\Pos\Exceptions\MissingAccountInfoException;
use Mews\Pos\Factory\AccountFactory as MewsPosAccountFactory;
use Mews\Pos\Gateways\AkbankPos;
Expand Down Expand Up @@ -69,6 +70,7 @@ public static function createAccount(string $gatewayClass, string $name, array $
$credentials['payment_model'],
$credentials['enc_key'] ?? null,
$lang,
$credentials['mbr_id'] ?? PayForAccount::MBR_ID_FINANSBANK,
);
case GarantiPos::class:
return MewsPosAccountFactory::createGarantiPosAccount(
Expand Down
7 changes: 7 additions & 0 deletions src/Gateway/Builder/AbstractGatewayDefinitionBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ protected function configureOptions(OptionsResolver $resolver): void
PosInterface::MODEL_3D_HOST,
]);
});

$resolver->setDefault('gateway_configs', function (OptionsResolver $subResolver): void {
$subResolver->setDefault('test_mode', false)
->setAllowedTypes('test_mode', 'boolean');
$subResolver->setDefault('disable_3d_hash_check', false)
->setAllowedTypes('disable_3d_hash_check', 'boolean');
});
}

protected function require3DGateway(OptionsResolver $resolver): void
Expand Down
5 changes: 5 additions & 0 deletions src/Gateway/Builder/PayForPosDefinitionBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Mews\PosBundle\Gateway\Builder;

use Mews\Pos\Entity\Account\PayForAccount;
use Mews\Pos\Gateways\PayForPos;
use Symfony\Component\OptionsResolver\OptionsResolver;

Expand Down Expand Up @@ -33,6 +34,10 @@ protected function configureOptions(OptionsResolver $resolver): void
$subResolver
->setRequired('user_password')
->setAllowedTypes('user_password', ['int', 'string']);
$subResolver
->setDefined('mbr_id')
->setDefault('mbr_id', PayForAccount::MBR_ID_FINANSBANK)
->setAllowedTypes('mbr_id', ['int', 'string']);
});
}
}
14 changes: 10 additions & 4 deletions src/Gateway/GatewayFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ public static function createPosGateway(
ClientInterface $client
): PosInterface
{
$credentials = $options['credentials'];
$gatewayClass = $options['gateway_class'];
$credentials = $options['credentials'];
$gatewayClass = $options['gateway_class'];
$gatewayConfigs = $options['gateway_configs'] ?? [];
if (!\in_array(PosInterface::class, \class_implements($gatewayClass), true)) {
throw new \InvalidArgumentException(
\sprintf('gateway_class must be implementation of %s', PosInterface::class)
Expand Down Expand Up @@ -51,7 +52,10 @@ public static function createPosGateway(

/** @var PosInterface $gateway */
$gateway = new $gatewayClass(
['gateway_endpoints' => $options['gateway_endpoints']],
[
'gateway_endpoints' => $options['gateway_endpoints'],
'gateway_configs' => $gatewayConfigs,
],
$account,
$requestDataMapper,
$responseDataMapper,
Expand All @@ -61,7 +65,9 @@ public static function createPosGateway(
$logger,
);

$gateway->setTestMode($options['test_mode']);
if (!isset($gatewayConfigs['test_mode']) && isset($options['test_mode'])) {
$gateway->setTestMode($options['test_mode']);
}

return $gateway;
}
Expand Down
44 changes: 31 additions & 13 deletions tests/Integration/GatewaysTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,22 @@

namespace Mews\PosBundle\Tests\Integration;

use Mews\Pos\Entity\Account\PayForAccount;
use Mews\Pos\PosInterface;
use Mews\PosBundle\Tests\Kernel\Kernel;
use PHPUnit\Framework\TestCase;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpKernel\KernelInterface;

/**
* @coversNothing
*/
class GatewaysTest extends TestCase
class GatewaysTest extends KernelTestCase
{
private ContainerInterface $container;
private KernelInterface $kernel;

protected function setUp(): void
{
parent::setUp();
$this->kernel = new Kernel();
$this->kernel->boot();
$this->container = $this->kernel->getContainer();
$this->container = static::getContainer();
}

public function testEstPos(): void
Expand Down Expand Up @@ -57,7 +53,7 @@ public function testPosNet(): void
$this->assertSame(PosInterface::LANG_TR, $pos->getAccount()->getLang());
$this->assertSame('https://setmpos.ykb.com/PosnetWebService/XML', $pos->getApiURL());
$this->assertSame('https://setmpos.ykb.com/3DSWebService/YKBPaymentService', $pos->get3DGatewayURL());
$this->assertSame(true, $pos->isTestMode());
$this->assertSame(false, $pos->isTestMode());
}

public function testPosNetV1(): void
Expand All @@ -76,7 +72,7 @@ public function testPosNetV1(): void
$pos->getApiURL(PosInterface::TX_TYPE_PAY_AUTH)
);
$this->assertSame('https://setmpos.ykb.com/3DSWebService/YKBPaymentService', $pos->get3DGatewayURL());
$this->assertSame(true, $pos->isTestMode());
$this->assertSame(false, $pos->isTestMode());
}

public function testPayForPos(): void
Expand All @@ -90,13 +86,35 @@ public function testPayForPos(): void
$this->assertSame('UXXXXX', $pos->getAccount()->getPassword());
$this->assertSame('12345678', $pos->getAccount()->getStoreKey());
$this->assertSame(PosInterface::LANG_TR, $pos->getAccount()->getLang());
$this->assertSame(PayForAccount::MBR_ID_FINANSBANK, $pos->getAccount()->getMbrId());
$this->assertSame('https://vpostest.qnbfinansbank.com/Gateway/XMLGate.aspx', $pos->getApiURL());
$this->assertSame('https://vpostest.qnbfinansbank.com/Gateway/Default.aspx', $pos->get3DGatewayURL());
$this->assertSame(
'https://vpostest.qnbfinansbank.com/Gateway/3DHost.aspx',
$pos->get3DGatewayURL(PosInterface::MODEL_3D_HOST)
);
$this->assertSame(true, $pos->isTestMode());
$this->assertSame(false, $pos->isTestMode());
}

public function testPayForPosZiraatKatilim(): void
{
$pos = $this->container->get('test.mews_pos.gateway.payfor_ziraat_katilim');
$this->assertInstanceOf(\Mews\Pos\Gateways\PayForPos::class, $pos);

$this->assertSame('payfor_ziraat_katilim', $pos->getAccount()->getBank());
$this->assertSame('08530313141242', $pos->getAccount()->getClientId());
$this->assertSame('QNB_API_USERNAME', $pos->getAccount()->getUsername());
$this->assertSame('UXXXXX', $pos->getAccount()->getPassword());
$this->assertSame('12345678', $pos->getAccount()->getStoreKey());
$this->assertSame(PosInterface::LANG_TR, $pos->getAccount()->getLang());
$this->assertSame(PayForAccount::MBR_ID_ZIRAAT_KATILIM, $pos->getAccount()->getMbrId());
$this->assertSame('https://payfortestziraatkatilim.cordisnetwork.com/Mpi/XMLGate.aspx', $pos->getApiURL());
$this->assertSame('https://payfortestziraatkatilim.cordisnetwork.com/Mpi/Default.aspx', $pos->get3DGatewayURL());
$this->assertSame(
'https://payfortestziraatkatilim.cordisnetwork.com/Mpi/3DHost.aspx',
$pos->get3DGatewayURL(PosInterface::MODEL_3D_HOST)
);
$this->assertSame(false, $pos->isTestMode());
}

public function testGarantiPos(): void
Expand All @@ -115,7 +133,7 @@ public function testGarantiPos(): void
$this->assertSame(PosInterface::LANG_TR, $pos->getAccount()->getLang());
$this->assertSame('https://sanalposprovtest.garantibbva.com.tr/VPServlet', $pos->getApiURL());
$this->assertSame('https://sanalposprovtest.garantibbva.com.tr/servlet/gt3dengine', $pos->get3DGatewayURL());
$this->assertSame(false, $pos->isTestMode());
$this->assertSame(true, $pos->isTestMode());
}

public function testInterPos(): void
Expand Down Expand Up @@ -155,7 +173,7 @@ public function testKuveytPos(): void
);
$this->assertSame('https://boatest.kuveytturk.com.tr/boa.virtualpos.services/Home/ThreeDModelPayGate', $pos->get3DGatewayURL());
$this->assertSame('https://boatest.kuveytturk.com.tr/BOA.Integration.WCFService/BOA.Integration.VirtualPos/VirtualPosService.svc?wsdl', $pos->getQueryAPIUrl());
$this->assertSame(false, $pos->isTestMode());
$this->assertSame(true, $pos->isTestMode());
}

public function testVakifKatilimPos(): void
Expand Down
Loading