Skip to content

Commit

Permalink
issue #258 param integration
Browse files Browse the repository at this point in the history
  • Loading branch information
mustapayev committed Jan 25, 2025
1 parent 5b2313a commit c8bc801
Show file tree
Hide file tree
Showing 84 changed files with 10,081 additions and 105 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ http://localhost/ URL projenin `examples` klasörünün içine bakar.
Projenin root klasoründe bu satırı çalıştırmanız gerekiyor

```sh
$ ./vendor/bin/phpunit
$ composer test
```

> Değerli yorum, öneri ve katkılarınızı
Expand Down
11 changes: 9 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
"squizlabs/php_codesniffer": "^3.5",
"symfony/event-dispatcher": "^5.4",
"symfony/http-client": "^5.4",
"symfony/var-dumper": "^5.1"
"symfony/var-dumper": "^5.1",
"symfony/var-exporter": "^5.4"
},
"suggest": {
"ext-soap": "KuveytPos ile iptal/iade gibi ödeme olmayan işlemleri yapacaksanız."
Expand All @@ -61,10 +62,16 @@
},
"scripts": {
"test": "./vendor/bin/phpunit --testsuite=unit",
"coverage": "XDEBUG_MODE=coverage ./vendor/bin/phpunit --testsuite=unit",
"phpstan": "./vendor/bin/phpstan",
"baseline": "./vendor/bin/phpstan --generate-baseline",
"rector": "./vendor/bin/rector",
"cs-fix": "./vendor/bin/php-cs-fixer fix",
"cs-check": "./vendor/bin/php-cs-fixer fix --dry-run --diff"
"cs-check": "./vendor/bin/php-cs-fixer fix --dry-run --diff",
"do-checks": [
"@cs-check",
"@phpstan",
"@test"
]
}
}
10 changes: 10 additions & 0 deletions config/pos_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@
'gateway_3d_host' => 'https://virtualpospaymentgatewaypre.akbank.com/payhosting',
],
],
'param-pos' => [
'name' => 'TURK Elektronik Para A.Ş',
'class' => Mews\Pos\Gateways\ParamPos::class,
'gateway_endpoints' => [
'payment_api' => 'https://test-dmz.param.com.tr/turkpos.ws/service_turkpos_test.asmx',
// API URL for 3D host payment
'payment_api_2' => 'https://test-pos.param.com.tr/to.ws/Service_Odeme.asmx',
'gateway_3d_host' => 'https://test-pos.param.com.tr/default.aspx',
],
],
'payten_v3_hash' => [
'name' => 'AKBANK T.A.S.',
'class' => Mews\Pos\Gateways\EstV3Pos::class,
Expand Down
31 changes: 18 additions & 13 deletions docs/PRE-AUTH-POST-EXAMPLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ $order = [
// lang degeri verilmezse account (EstPosAccount) dili kullanılacak
'lang' => \Mews\Pos\Gateways\PosInterface::LANG_TR, // Kullanıcının yönlendirileceği banka gateway sayfasının ve gateway'den dönen mesajların dili.
];
if (in_array($paymentModel, [
if ($pos instanceof \Mews\Pos\Gateways\ParamPos
|| in_array($paymentModel, [
PosInterface::MODEL_3D_SECURE,
PosInterface::MODEL_3D_PAY,
PosInterface::MODEL_3D_HOST,
Expand Down Expand Up @@ -123,18 +124,22 @@ try {
exit;
}
```
```html
<!-- $formData içeriği HTML forma render ediyoruz ve kullanıcıyı banka gateway'ine yönlendiriyoruz. -->
<form method="<?= $formData['method']; ?>" action="<?= $formData['gateway']; ?>" class="redirect-form" role="form">
<?php foreach ($formData['inputs'] as $key => $value) : ?>
<input type="hidden" name="<?= $key; ?>" value="<?= $value; ?>">
<?php endforeach; ?>
<div class="text-center">Redirecting...</div>
<hr>
<div class="form-group text-center">
<button type="submit" class="btn btn-lg btn-block btn-success">Submit</button>
</div>
</form>
```php
<?php if (is_string($formData)): ?>
<?= $formData ?>
<?php else: ?>
<!-- $formData içeriği HTML forma render ediyoruz ve kullanıcıyı banka gateway'ine yönlendiriyoruz. -->
<form method="<?= $formData['method']; ?>" action="<?= $formData['gateway']; ?>" class="redirect-form" role="form">
<?php foreach ($formData['inputs'] as $key => $value) : ?>
<input type="hidden" name="<?= $key; ?>" value="<?= $value; ?>">
<?php endforeach; ?>
<div class="text-center">Redirecting...</div>
<hr>
<div class="form-group text-center">
<button type="submit" class="btn btn-lg btn-block btn-success">Submit</button>
</div>
</form>
<?php endif; ?>
```
**response.php (gateway'den döndükten sonra çalışacak kod)**

Expand Down
4 changes: 2 additions & 2 deletions docs/THREED-PAYMENT-EXAMPLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,8 @@ try {
exit;
}
```
```html
<!-- $formData içeriği HTML forma render ediyoruz ve kullanıcıyı banka gateway'ine yönlendiriyoruz. -->
```php
// $formData içeriği HTML forma render ediyoruz ve kullanıcıyı banka gateway'ine yönlendiriyoruz.
<form method="<?= $formData['method']; ?>" action="<?= $formData['gateway']; ?>" class="redirect-form" role="form">
<?php foreach ($formData['inputs'] as $key => $value) : ?>
<input type="hidden" name="<?= $key; ?>" value="<?= $value; ?>">
Expand Down
12 changes: 8 additions & 4 deletions docs/THREED-SECURE-AND-PAY-PAYMENT-IN-MODALBOX-EXAMPLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ try {
```

**_iframe_form.php** (form.php icinde kullanilacak)
```html
```php
<!DOCTYPE HTML>
<html>
<head>
Expand Down Expand Up @@ -158,9 +158,13 @@ try {
exit;
}
ob_start();
include('_iframe_form.php');
$renderedForm = ob_get_clean();
if (is_string($formData)) {
$renderedForm = $formData;
} else {
ob_start();
include('_iframe_form.php');
$renderedForm = ob_get_clean();
}
?>
Expand Down
103 changes: 50 additions & 53 deletions examples/_common-codes/3d/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
// ornegin /examples/finansbank-payfor/3d/_config.php
require '_config.php';

require '../../_templates/_header.php';

if ($request->getMethod() !== 'POST') {
echo new RedirectResponse($baseUrl.'index.php');
exit();
Expand Down Expand Up @@ -75,7 +73,7 @@ function (RequestDataPreparedEvent $requestDataPreparedEvent): void {
}
// KuveytPos TDV2.0.0 icin zorunlu eklenmesi gereken ekstra alanlar:
$additionalRequestDataForKuveyt = [
'DeviceData' => [
'DeviceData' => [
/**
* DeviceChannel : DeviceData alanı içerisinde gönderilmesi beklenen işlemin yapıldığı cihaz bilgisi.
* 2 karakter olmalıdır. 01-Mobil, 02-Web Browser için kullanılmalıdır.
Expand All @@ -87,18 +85,18 @@ function (RequestDataPreparedEvent $requestDataPreparedEvent): void {
* BillAddrCity: Kullanılan kart ile ilişkili kart hamilinin fatura adres şehri.
* Maksimum 50 karakter uzunluğunda olmalıdır.
*/
'BillAddrCity' => 'İstanbul',
'BillAddrCity' => 'İstanbul',
/**
* BillAddrCountry Kullanılan kart ile ilişkili kart hamilinin fatura adresindeki ülke kodu.
* Maksimum 3 karakter uzunluğunda olmalıdır.
* ISO 3166-1 sayısal üç haneli ülke kodu standardı kullanılmalıdır.
*/
'BillAddrCountry' => '792',
'BillAddrCountry' => '792',
/**
* BillAddrLine1: Kullanılan kart ile ilişkili kart hamilinin teslimat adresinde yer alan sokak vb. bilgileri içeren açık adresi.
* Maksimum 150 karakter uzunluğunda olmalıdır.
*/
'BillAddrLine1' => 'XXX Mahallesi XXX Caddesi No 55 Daire 1',
'BillAddrLine1' => 'XXX Mahallesi XXX Caddesi No 55 Daire 1',
/**
* BillAddrPostCode: Kullanılan kart ile ilişkili kart hamilinin fatura adresindeki posta kodu.
*/
Expand All @@ -107,17 +105,17 @@ function (RequestDataPreparedEvent $requestDataPreparedEvent): void {
* BillAddrState: CardHolderData alanı içerisinde gönderilmesi beklenen ödemede kullanılan kart ile ilişkili kart hamilinin fatura adresindeki il veya eyalet bilgisi kodu.
* ISO 3166-2'de tanımlı olan il/eyalet kodu olmalıdır.
*/
'BillAddrState' => '40',
'BillAddrState' => '40',
/**
* Email: Kullanılan kart ile ilişkili kart hamilinin iş yerinde oluşturduğu hesapta kullandığı email adresi.
* Maksimum 254 karakter uzunluğunda olmalıdır.
*/
'Email' => '[email protected]',
'MobilePhone' => [
'Email' => '[email protected]',
'MobilePhone' => [
/**
* Cc: Kullanılan kart ile ilişkili kart hamilinin cep telefonuna ait ülke kodu. 1-3 karakter uzunluğunda olmalıdır.
*/
'Cc' => '90',
'Cc' => '90',
/**
* Subscriber: Kullanılan kart ile ilişkili kart hamilinin cep telefonuna ait abone numarası.
* Maksimum 15 karakter uzunluğunda olmalıdır.
Expand All @@ -126,18 +124,19 @@ function (RequestDataPreparedEvent $requestDataPreparedEvent): void {
],
],
];

$requestData = $requestDataPreparedEvent->getRequestData();
$requestData = array_merge_recursive($requestData, $additionalRequestDataForKuveyt);
$requestDataPreparedEvent->setRequestData($requestData);
});

/**
* Bu Event'i dinleyerek 3D formun hash verisi hesaplanmadan önce formun input array içireğini güncelleyebilirsiniz.
* Eger ekleyeceginiz veri hash hesaplamada kullanilmiyorsa form verisi olusturduktan sonra da ekleyebilirsiniz.
*/
$eventDispatcher->addListener(Before3DFormHashCalculatedEvent::class, function (Before3DFormHashCalculatedEvent $event): void {
if ($event->getGatewayClass() === \Mews\Pos\Gateways\EstPos::class || $event->getGatewayClass() === \Mews\Pos\Gateways\EstV3Pos::class) {
//Örnek 1: İşbank İmece Kart ile ödeme yaparken aşağıdaki verilerin eklenmesi gerekiyor:
/**
* Bu Event'i dinleyerek 3D formun hash verisi hesaplanmadan önce formun input array içireğini güncelleyebilirsiniz.
* Eger ekleyeceginiz veri hash hesaplamada kullanilmiyorsa form verisi olusturduktan sonra da ekleyebilirsiniz.
*/
$eventDispatcher->addListener(Before3DFormHashCalculatedEvent::class, function (Before3DFormHashCalculatedEvent $event): void {
if ($event->getGatewayClass() === \Mews\Pos\Gateways\EstPos::class || $event->getGatewayClass() === \Mews\Pos\Gateways\EstV3Pos::class) {
//Örnek 1: İşbank İmece Kart ile ödeme yaparken aşağıdaki verilerin eklenmesi gerekiyor:
// $supportedPaymentModels = [
// \Mews\Pos\PosInterface::MODEL_3D_PAY,
// \Mews\Pos\PosInterface::MODEL_3D_PAY_HOSTING,
Expand All @@ -149,22 +148,21 @@ function (RequestDataPreparedEvent $requestDataPreparedEvent): void {
// $formInputs['FDONEM'] = '5'; // Ödemenin faizsiz ertelenmesini istediğiniz dönem sayısı.
// $event->setFormInputs($formInputs);
// }
}
if ($event->getGatewayClass() === \Mews\Pos\Gateways\EstV3Pos::class) {
}
if ($event->getGatewayClass() === \Mews\Pos\Gateways\EstV3Pos::class) {
// // Örnek 2: callbackUrl eklenmesi
// $formInputs = $event->getFormInputs();
// $formInputs['callbackUrl'] = $formInputs['failUrl'];
// $formInputs['refreshTime'] = '10'; // birim: saniye; callbackUrl sisteminin doğru çalışması için eklenmesi gereken parametre
// $event->setFormInputs($formInputs);
}
});
}
});
// ============================================================================================
// OZEL DURUMLAR ICIN KODLAR END
// ============================================================================================

try {
$formData = $pos->get3DFormData($order, $paymentModel, $transaction, $card, false);
//dd($formData);
} catch (\InvalidArgumentException $e) {
// örneğin kart bilgisi sağlanmadığında bu exception'i alırsınız.
dd($e);
Expand Down Expand Up @@ -215,7 +213,6 @@ function (RequestDataPreparedEvent $requestDataPreparedEvent): void {
// OZEL DURUMLAR ICIN KODLAR END
// ============================================================================================


$flowType = $request->get('payment_flow_type');
?>

Expand All @@ -232,32 +229,36 @@ function (RequestDataPreparedEvent $requestDataPreparedEvent): void {
<!------------------------------------------------------------------------------------------------------------->

<?php if ('by_redirection' === $flowType) : ?>
<!--
Sık kullanılan yöntem, 3D form verisini bir HTML form içine basıp JS ile otomatik submit ediyoruz.
Submit sonucu kullanıcı banka sayfasıne yönlendirilir, işlem sonucundan ise duruma göre websitinizin
success veya fail URL'na geri yönlendilir.
-->
<?php require '../../_templates/_redirect_form.php'; ?>
<script>
// Formu JS ile otomatik submit ederek kullaniciyi banka gatewayine yonlendiriyoruz.
let redirectForm = document.querySelector('form.redirect-form');
if (redirectForm) {
redirectForm.submit();
}
</script>




<?php elseif ('by_iframe' === $flowType || 'by_popup_window' === $flowType) :
ob_start();
include('../../_templates/_redirect_iframe_or_popup_window_form.php');
$renderedForm = ob_get_clean();
<?php if (is_string($formData)) : ?>
<?= $formData; ?>
<?php else: ?>
<!--
Sık kullanılan yöntem, 3D form verisini bir HTML form içine basıp JS ile otomatik submit ediyoruz.
Submit sonucu kullanıcı banka sayfasıne yönlendirilir, işlem sonucundan ise duruma göre websitinizin
success veya fail URL'na geri yönlendilir.
-->
<?php require '../../_templates/_redirect_form.php'; ?>
<script>
// Formu JS ile otomatik submit ederek kullaniciyi banka gatewayine yonlendiriyoruz.
let redirectForm = document.querySelector('form.redirect-form');
if (redirectForm) {
redirectForm.submit();
}
</script>
<?php endif; ?>
<?php elseif ('by_iframe' === $flowType || 'by_popup_window' === $flowType):
if (is_string($formData)) {
$renderedForm = $formData;
} else {
ob_start();
include('../../_templates/_redirect_iframe_or_popup_window_form.php');
$renderedForm = ob_get_clean();
}
?>
<!--
$renderedForm içinde 3D formun verileriyle oluşturulan HTML form bulunur.
alttaki kodlar ise bu $renderedForm verisini seçilen $flowType'a göre iframe modal box içine veya pop up window içine basar.
-->
<!--
$renderedForm içinde 3D formun verileriyle oluşturulan HTML form bulunur.
alttaki kodlar ise bu $renderedForm verisini seçilen $flowType'a göre iframe modal box içine veya pop up window içine basar.
-->
<div class="alert alert-dismissible" role="alert" id="result-alert">
<!-- buraya odeme basarili olup olmadini alttaki JS kodlariyla basiyoruz. -->
</div>
Expand Down Expand Up @@ -293,16 +294,14 @@ function (RequestDataPreparedEvent $requestDataPreparedEvent): void {
<?php endif; ?>




<?php if ('by_iframe' === $flowType) : ?>
<div class="modal fade" tabindex="-1" role="dialog" id="iframe-modal" data-keyboard="false" data-backdrop="static">
<div class="modal-dialog" role="document" style="width: 426px;">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body" id="iframe-modal-body">
<div class="modal-body" id="iframe-modal-body">
</div>
</div>
</div>
Expand Down Expand Up @@ -349,8 +348,6 @@ function (RequestDataPreparedEvent $requestDataPreparedEvent): void {
</script>




<?php elseif ('by_popup_window' === $flowType) : ?>
<script>

Expand Down
4 changes: 4 additions & 0 deletions examples/_common-codes/regular/cancel.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ function createCancelOrder(string $gatewayClass, array $lastResponse, string $ip

if (\Mews\Pos\Gateways\GarantiPos::class === $gatewayClass) {
$cancelOrder['amount'] = $lastResponse['amount'];
} elseif (\Mews\Pos\Gateways\ParamPos::class === $gatewayClass) {
$cancelOrder['amount'] = $lastResponse['amount'];
// on otorizasyon islemin iptali icin PosInterface::TX_TYPE_PAY_PRE_AUTH saglanmasi gerekiyor
$cancelOrder['transaction_type'] = $lastResponse['transaction_type'] ?? PosInterface::TX_TYPE_PAY_AUTH;
} elseif (\Mews\Pos\Gateways\KuveytPos::class === $gatewayClass) {
$cancelOrder['remote_order_id'] = $lastResponse['remote_order_id']; // banka tarafındaki order id
$cancelOrder['auth_code'] = $lastResponse['auth_code'];
Expand Down
Loading

0 comments on commit c8bc801

Please sign in to comment.