Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding tests and renamed tag name #2

Merged
merged 10 commits into from
May 19, 2024
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
6 changes: 6 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.gitattributes export-ignore
.gitignore export-ignore
.editorconfig export-ignore
phpunit.xml export-ignore
tests/ export-ignore
var/
21 changes: 21 additions & 0 deletions .github/workflows/ci-php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Unit Tests

on: [push, pull_request]

jobs:
test:

runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
php: ['7.4', '8.2']
dependency-version: [prefer-stable]
steps:
- uses: actions/checkout@v1

- name: Install dependencies
run: composer install --no-suggest

- name: Run integration test suite
run: vendor/bin/simple-phpunit --testsuite=integration
24 changes: 5 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

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

## Kurulum
Expand All @@ -28,6 +28,7 @@
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 @@ -38,7 +39,6 @@
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
test_mode: false #optional, default: false;
yapikredi:
gateway_class: Mews\Pos\Gateways\PosNet
credentials:
Expand All @@ -50,7 +50,6 @@
gateway_endpoints:
payment_api: 'https://setmpos.ykb.com/PosnetWebService/XML'
gateway_3d: 'https://setmpos.ykb.com/3DSWebService/YKBPaymentService'
test_mode: false
```

### Ornek 3D Secure Odeme
Expand Down Expand Up @@ -96,7 +95,7 @@ class SingleBankThreeDSecurePaymentController extends AbstractController
* birden fazla banka oldugunda bu sekilde hepsine erisebilirsiniz
* @var PosInterface[]
*/
#[TaggedIterator('mews_pos.gateway.bank')]
#[TaggedIterator('mews_pos.gateway')]
private iterable $banks,
)
{
Expand Down Expand Up @@ -129,15 +128,7 @@ class SingleBankThreeDSecurePaymentController extends AbstractController
);
$session->set('order', $order);

//$card = $this->createCard($this->pos, $request->request->all());
$card = $this->createCard($this->pos, [ // normalde POST ile kart bilgileri gelecek
'number' => '4546xxxxyyyywwwwzzzz',
'year' => '26',
'month' => '12',
'cvv' => '000',
'name' => 'John Doe',
'type' => CreditCardInterface::CARD_TYPE_VISA,
]);
$card = $this->createCard($this->pos, $request->request->all());

/**
* PayFlex'te provizyonu (odemeyi) tamamlamak icin tekrar kredi kart bilgileri isteniyor,
Expand Down Expand Up @@ -285,14 +276,9 @@ class SingleBankThreeDSecurePaymentController extends AbstractController
dd($e);
}

$response = $this->pos->getResponse();

// iptal, iade, siparis durum sorgulama islemleri yapabilmek icin $response'u kaydediyoruz
$session->set('last_response', $response);

if ($this->pos->isSuccess()) {
echo 'success';
exit;
dd($this->pos->getResponse());
} else {
dd($response);
}
Expand Down
12 changes: 10 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
],
"require": {
"php": ">=7.4",
"mews/pos": "^1.1",
"mews/pos": "^1.2",
"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 @@ -37,11 +37,19 @@
"require-dev": {
"nyholm/psr7": "^1.8",
"psr/http-client": "^1.0",
"symfony/http-client": "^7.0"
"symfony/framework-bundle": "^6.4",
"symfony/http-client": "^6.4",
"symfony/phpunit-bridge": "^6.4",
"symfony/yaml": "^6.4"
},
"autoload": {
"psr-4": {
"Mews\\PosBundle\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Mews\\PosBundle\\Tests\\": "tests/"
}
}
}
22 changes: 4 additions & 18 deletions docs/EXAMPLE_CONFIGURATIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ 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 All @@ -93,7 +94,6 @@ mews_pos:
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'
test_mode: true
yapikredi:
gateway_class: Mews\Pos\Gateways\PosNet
credentials:
Expand All @@ -105,7 +105,6 @@ mews_pos:
gateway_endpoints:
payment_api: 'https://setmpos.ykb.com/PosnetWebService/XML'
gateway_3d: 'https://setmpos.ykb.com/3DSWebService/YKBPaymentService'
test_mode: true
albaraka:
gateway_class: Mews\Pos\Gateways\PosNetV1Pos
credentials:
Expand All @@ -115,9 +114,8 @@ mews_pos:
user_name: 10100628XXXXXXX # 16 haneli üye işyeri EPOS numarası.
enc_key: 10,43,43,45,65,56,76,08 # Şifreleme anahtar
gateway_endpoints:
payment_api: 'https://setmpos.ykb.com/PosnetWebService/XML'
gateway_3d: 'https://setmpos.ykb.com/3DSWebService/YKBPaymentService'
test_mode: true
payment_api: 'https://epostest.albarakaturk.com.tr/ALBMerchantService/MerchantJSONAPI.svc'
gateway_3d: 'https://epostest.albarakaturk.com.tr/ALBSecurePaymentUI/SecureProcess/SecureVerification.aspx'
payfor_finansbank:
gateway_class: Mews\Pos\Gateways\PayForPos
credentials:
Expand All @@ -130,7 +128,6 @@ mews_pos:
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'
test_mode: true
garanti:
gateway_class: Mews\Pos\Gateways\GarantiPos
credentials:
Expand All @@ -145,12 +142,10 @@ mews_pos:
gateway_endpoints:
payment_api: 'https://sanalposprovtest.garantibbva.com.tr/VPServlet'
gateway_3d: 'https://sanalposprovtest.garantibbva.com.tr/servlet/gt3dengine'
test_mode: true
interpos_denizbank:
gateway_class: Mews\Pos\Gateways\InterPos
credentials:
#payment_model: !php/const Mews\Pos\PosInterface::MODEL_3D_SECURE
payment_model: !php/const Mews\Pos\PosInterface::MODEL_3D_HOST
payment_model: !php/const Mews\Pos\PosInterface::MODEL_3D_SECURE
merchant_id: InterXXXXXXXX # ShopCode
user_name: 31XXXXXXXX # UserCode
user_password: 3XXXXXXXX # UserPass
Expand All @@ -159,7 +154,6 @@ mews_pos:
payment_api: 'https://test.inter-vpos.com.tr/mpi/Default.aspx'
gateway_3d: 'https://test.inter-vpos.com.tr/mpi/Default.aspx'
gateway_3d_host: 'https://test.inter-vpos.com.tr/mpi/3DHost.aspx'
test_mode: true
kuveytpos:
gateway_class: Mews\Pos\Gateways\KuveytPos
credentials:
Expand All @@ -172,7 +166,6 @@ 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'
test_mode: true
vakifkatilim:
gateway_class: Mews\Pos\Gateways\VakifKatilimPos
credentials:
Expand All @@ -185,7 +178,6 @@ mews_pos:
payment_api: 'https://boa.vakifkatilim.com.tr/VirtualPOS.Gateway/Home'
gateway_3d: 'https://boa.vakifkatilim.com.tr/VirtualPOS.Gateway/Home/ThreeDModelPayGate'
gateway_3d_host: 'https://boa.vakifkatilim.com.tr/VirtualPOS.Gateway/CommonPaymentPage/CommonPaymentPage'
test_mode: true
payflexv4_ziraat:
gateway_class: Mews\Pos\Gateways\PayFlexV4Pos
credentials:
Expand All @@ -197,7 +189,6 @@ mews_pos:
payment_api: 'https://preprod.payflex.com.tr/Ziraatbank/VposWeb/v3/Vposreq.aspx'
gateway_3d: 'https://preprod.payflex.com.tr/ZiraatBank/MpiWeb/MPI_Enrollment.aspx'
query_api: 'https://sanalpos.ziraatbank.com.tr/v4/UIWebService/Search.aspx'
test_mode: true
payflexcpv4_vakifbank:
gateway_class: Mews\Pos\Gateways\PayFlexCPV4Pos
credentials:
Expand All @@ -209,7 +200,6 @@ mews_pos:
payment_api: 'https://cptest.vakifbank.com.tr/CommonPayment/api/RegisterTransaction'
gateway_3d: 'https://cptest.vakifbank.com.tr/CommonPayment/api/VposTransaction'
query_api: 'https://cptest.vakifbank.com.tr/CommonPayment/SecurePayment'
test_mode: true
akbankpos:
gateway_class: Mews\Pos\Gateways\AkbankPos
credentials:
Expand All @@ -222,7 +212,6 @@ mews_pos:
payment_api: 'https://apipre.akbank.com/api/v1/payment/virtualpos'
gateway_3d: 'https://virtualpospaymentgatewaypre.akbank.com/securepay'
gateway_3d_host: 'https://virtualpospaymentgatewaypre.akbank.com/payhosting'
test_mode: true
toslapos:
gateway_class: Mews\Pos\Gateways\ToslaPos
credentials:
Expand All @@ -234,7 +223,4 @@ mews_pos:
payment_api: 'https://prepentegrasyon.tosla.com/api/Payment'
gateway_3d: 'https://prepentegrasyon.tosla.com/api/Payment/ProcessCardForm'
gateway_3d_host: 'https://prepentegrasyon.tosla.com/api/Payment/threeDSecure'
test_mode: true


```
30 changes: 30 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd"
bootstrap="tests/bootstrap.php"
executionOrder="depends,defects"
forceCoversAnnotation="true"
beStrictAboutCoversAnnotation="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
convertDeprecationsToExceptions="true"
failOnRisky="true"
failOnWarning="true"
cacheResultFile="./var/.phpunit.result.cache"
verbose="true">
<testsuites>
<testsuite name="default">
<directory>tests</directory>
</testsuite>
<testsuite name="integration">
<directory>tests/Integration</directory>
</testsuite>
</testsuites>

<!-- <coverage cacheDirectory="var/code-coverage"-->
<!-- processUncoveredFiles="true">-->
<!-- <include>-->
<!-- <directory suffix=".php">src</directory>-->
<!-- </include>-->
<!-- </coverage>-->
</phpunit>
2 changes: 1 addition & 1 deletion src/DependencyInjection/MewsPosExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function load(array $configs, ContainerBuilder $container): void
$container->registerAliasForArgument($serviceId, PosInterface::class, $bank)
->setPublic(false);

$gatewayDefinition->addTag('mews_pos.gateway.bank', ['key' => $serviceId]);
$gatewayDefinition->addTag('mews_pos.gateway', ['key' => $serviceId]);

if ($i === 0) {
// set the first gateway as a default for injection
Expand Down
2 changes: 2 additions & 0 deletions src/Gateway/AccountFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Mews\Pos\Exceptions\MissingAccountInfoException;
use Mews\Pos\Factory\AccountFactory as MewsPosAccountFactory;
use Mews\Pos\Gateways\AkbankPos;
use Mews\Pos\Gateways\EstPos;
use Mews\Pos\Gateways\EstV3Pos;
use Mews\Pos\Gateways\GarantiPos;
use Mews\Pos\Gateways\InterPos;
Expand Down Expand Up @@ -36,6 +37,7 @@ class AccountFactory
public static function createAccount(string $gatewayClass, string $name, array $credentials, string $lang = PosInterface::LANG_TR): AbstractPosAccount
{
switch ($gatewayClass) {
case EstPos::class:
case EstV3Pos::class:
return MewsPosAccountFactory::createEstPosAccount(
$name,
Expand Down
Loading