[GH-ISSUE #252] PayFlexV4Pos Kredi kartı bilgileri eksik #131

Closed
opened 2026-03-03 15:43:21 +03:00 by kerem · 9 comments
Owner

Originally created by @lansas on GitHub (Nov 23, 2024).
Original GitHub issue: https://github.com/mewebstudio/pos/issues/252

Hatanın özeti

Merhabalar, formun ilk açılacağı sayfada kredi kartı bilgilerinin eksik olduğu hatasını alıyorum. Daha değerleri gireceğim kredi kartı formu sayfası açılmadan bu hatayı almam normal mi?

Type: LogicException
Message: Kredi kartı bilgileri eksik!
File: /mews/pos/src/Gateways/PayFlexV4Pos.php
Line: 163

`
use \Mews\Pos\Factory\AccountFactory;

use \Mews\Pos\Factory\PosFactory;

use Mews\Pos\PosInterface;
$eventDispatcher = new Symfony\Component\EventDispatcher\EventDispatcher();
$s_model = PosInterface::MODEL_NON_SECURE;
$account = AccountFactory::createPayFlexAccount("ziraat-vpos", "XXXXXXXXXX", "XXXXXXXXXX", "XXXXXXXXXX", $s_model, 0);
$pos = PosFactory::createPosGateway($account, st_TurkBanks_pos::SANAL_POS_CONFIG_CUSTOM, $eventDispatcher);//SANAL_POS_CONFIG_CUSTOM: bir değişken olarak banka urllerini çektiği yer.
$pos->setTestMode(false);
$rand = microtime();
$f_amount = 1.0;
$order = [
'id' => DATE("YmdHis"),//$orderId
'email' => "customer@gmail.com", // optional
'name' => 'First Last', // optional
'amount' => floor($f_amount * 100) / 100,
'installment' => '0',
'currency' => 'TRY',
'ip' => "192.168.1.1",
'success_url' => "https://BLABLA.COM/set_payment/",
'fail_url' => "https://BLABLA.COM/set_payment/",
'transaction' => 'pay', // pay => Auth, pre PreAuth,
'lang' => PosInterface::LANG_TR,
'rand' => $rand,
'pos_option' => 7//sadeleşmiş kod attığımdan anlamsız gelebilir. Kendi kodumdaki fonksiyonlarda seçili posu anlamak için gönderdiğim bir değer.
];
$form_data = $pos->get3dFormData($order, PosInterface::MODEL_3D_SECURE, PosInterface::TX_TYPE_PAY_AUTH);//hatanın gerçekleştiği line
`

Banka ismi

ziraat

Gateway PHP sınıfı

PayFlexV4Pos

İşlem Tipi

MODEL_3D_SECURE ödeme

Kütüphane versiyonu

1.5

Checks

  • Bu konuda zaten bir hata bildirimi olmadığından eminim.
  • Hatayı yeniden oluşturmak için gereken detayları ekledim.
Originally created by @lansas on GitHub (Nov 23, 2024). Original GitHub issue: https://github.com/mewebstudio/pos/issues/252 ### Hatanın özeti Merhabalar, formun ilk açılacağı sayfada kredi kartı bilgilerinin eksik olduğu hatasını alıyorum. Daha değerleri gireceğim kredi kartı formu sayfası açılmadan bu hatayı almam normal mi? Type: LogicException Message: Kredi kartı bilgileri eksik! File: /mews/pos/src/Gateways/PayFlexV4Pos.php Line: 163 ` use \Mews\Pos\Factory\AccountFactory; use \Mews\Pos\Factory\PosFactory; use Mews\Pos\PosInterface; $eventDispatcher = new Symfony\Component\EventDispatcher\EventDispatcher(); $s_model = PosInterface::MODEL_NON_SECURE; $account = AccountFactory::createPayFlexAccount("ziraat-vpos", "XXXXXXXXXX", "XXXXXXXXXX", "XXXXXXXXXX", $s_model, 0); $pos = PosFactory::createPosGateway($account, st_TurkBanks_pos::SANAL_POS_CONFIG_CUSTOM, $eventDispatcher);//SANAL_POS_CONFIG_CUSTOM: bir değişken olarak banka urllerini çektiği yer. $pos->setTestMode(false); $rand = microtime(); $f_amount = 1.0; $order = [ 'id' => DATE("YmdHis"),//$orderId 'email' => "customer@gmail.com", // optional 'name' => 'First Last', // optional 'amount' => floor($f_amount * 100) / 100, 'installment' => '0', 'currency' => 'TRY', 'ip' => "192.168.1.1", 'success_url' => "https://BLABLA.COM/set_payment/", 'fail_url' => "https://BLABLA.COM/set_payment/", 'transaction' => 'pay', // pay => Auth, pre PreAuth, 'lang' => PosInterface::LANG_TR, 'rand' => $rand, 'pos_option' => 7//sadeleşmiş kod attığımdan anlamsız gelebilir. Kendi kodumdaki fonksiyonlarda seçili posu anlamak için gönderdiğim bir değer. ]; $form_data = $pos->get3dFormData($order, PosInterface::MODEL_3D_SECURE, PosInterface::TX_TYPE_PAY_AUTH);//hatanın gerçekleştiği line ` ### Banka ismi ziraat ### Gateway PHP sınıfı PayFlexV4Pos ### İşlem Tipi MODEL_3D_SECURE ödeme ### Kütüphane versiyonu 1.5 ### Checks - [X] Bu konuda zaten bir hata bildirimi olmadığından eminim. - [X] Hatayı yeniden oluşturmak için gereken detayları ekledim.
kerem 2026-03-03 15:43:21 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@nuryagdym commented on GitHub (Nov 23, 2024):

Merhabalar,
dokumantasyonda (https://github.com/mewebstudio/pos/blob/master/docs/THREED-SECURE-AND-PAY-PAYMENT-IN-MODALBOX-EXAMPLE.md) berlitilen akisa gore 3D secure modeli icin get3dFormData cagrilmadan once kart bilgilier elinizde olmasi gerekiyor.

Cogu gatewaylerde kredi karti yerine NULL vererek de form verisi olusturabilirsiniz, ama bu durumda sonradan kendiniz manuel olarak form verisinin icine kredi kart bilgileri eklemeniz gerekiyor.

Fakat bazi gatewaylerde form verisini olusturmak icin kredi kart bilgileri zorunlu. PayFlexV4'de onlardan biri: github.com/mewebstudio/pos@399ce801b9/src/Gateways/PayFlexV4Pos.php (L163)
Payflex bu istekle 3d form verisi olusturmadan once kartta 3D ozellik aktif mi diye sorguluyor.

<!-- gh-comment-id:2495377482 --> @nuryagdym commented on GitHub (Nov 23, 2024): Merhabalar, dokumantasyonda (https://github.com/mewebstudio/pos/blob/master/docs/THREED-SECURE-AND-PAY-PAYMENT-IN-MODALBOX-EXAMPLE.md) berlitilen akisa gore 3D secure modeli icin get3dFormData cagrilmadan once kart bilgilier elinizde olmasi gerekiyor. Cogu gatewaylerde kredi karti yerine NULL vererek de form verisi olusturabilirsiniz, ama bu durumda sonradan kendiniz manuel olarak form verisinin icine kredi kart bilgileri eklemeniz gerekiyor. Fakat bazi gatewaylerde form verisini olusturmak icin kredi kart bilgileri zorunlu. PayFlexV4'de onlardan biri: https://github.com/mewebstudio/pos/blob/399ce801b9957d61b42884dde031f8bef626e5e9/src/Gateways/PayFlexV4Pos.php#L163 Payflex bu istekle 3d form verisi olusturmadan once kartta 3D ozellik aktif mi diye sorguluyor.
Author
Owner

@nuryagdym commented on GitHub (Nov 23, 2024):

Bir derand degerini sizin olusturmanize gerek yok, kutuphane artik kendisi olusuturuyor.

<!-- gh-comment-id:2495377867 --> @nuryagdym commented on GitHub (Nov 23, 2024): Bir de`rand` degerini sizin olusturmanize gerek yok, kutuphane artik kendisi olusuturuyor.
Author
Owner

@lansas commented on GitHub (Nov 27, 2024):

Payflex in oluşturduğu VerifyEnrollmentRequestId ile benim oluşturduğum order_id haliyle farklı. Birçok uygulamada benim oluşturduğum order_id ile işlem yapabiliyorken Payflex geri dönüşte sadece VerifyEnrollmentRequestId değerini dönüyor. Bu değeri bankaya göndermeden evvel elde edebiliyor muyuz ki anlayalım hangi sipariş için ödeme isteğini tekrar gönderelim?

`
$pos->payment(
$s_model,
$ORDER,
PosInterface::TX_TYPE_PAY_AUTH,
$o_card
);

`

//public function get3DFormData $data = $this->sendEnrollmentRequest($order, $creditCard, $txType, $paymentModel); return $data["VerifyEnrollmentRequestId"]

VerifyEnrollmentRequestId değerini get3DFormData yı çağırdığımız yerde elde edebilmeliyiz. Şu anda Return sadece form inputları oluşturuyor. Ekstra data olarak eklenebilir mi yoksa bunun başka bir yolu var mı?

<!-- gh-comment-id:2503852089 --> @lansas commented on GitHub (Nov 27, 2024): Payflex in oluşturduğu VerifyEnrollmentRequestId ile benim oluşturduğum order_id haliyle farklı. Birçok uygulamada benim oluşturduğum order_id ile işlem yapabiliyorken Payflex geri dönüşte sadece VerifyEnrollmentRequestId değerini dönüyor. Bu değeri bankaya göndermeden evvel elde edebiliyor muyuz ki anlayalım hangi sipariş için ödeme isteğini tekrar gönderelim? ` $pos->payment( $s_model, $ORDER, PosInterface::TX_TYPE_PAY_AUTH, $o_card ); ` ` //public function get3DFormData $data = $this->sendEnrollmentRequest($order, $creditCard, $txType, $paymentModel); return $data["VerifyEnrollmentRequestId"] ` VerifyEnrollmentRequestId değerini get3DFormData yı çağırdığımız yerde elde edebilmeliyiz. Şu anda Return sadece form inputları oluşturuyor. Ekstra data olarak eklenebilir mi yoksa bunun başka bir yolu var mı?
Author
Owner

@nuryagdym commented on GitHub (Nov 27, 2024):

PayFlex kodu ve dokumentasyonu inceledim.
Kodda 3d form verisini olustururken, ve form verisi icin gonderilen API istekte de $order['id'] degeri kullanilmiyor, dokumantasyonda da order id gonderilmesi gerektigini belirtmemisler.

VerifyEnrollmentRequestId degerine ise random string ataniyor:
github.com/mewebstudio/pos@399ce801b9/src/DataMapper/RequestDataMapper/PayFlexV4PosRequestDataMapper.php (L113)

Dokumentasyonda ise bu alan hakkinda soyle demis:
image

order id ise sadece $pos->payment() calisitiginda kullaniliyor:
github.com/mewebstudio/pos@399ce801b9/src/DataMapper/RequestDataMapper/PayFlexV4PosRequestDataMapper.php (L80-L81)
Dokumantasyonlarina gore de VerifyEnrollmentRequestId ile order id ayni sey degil ve ayni olmasi sorun cikarabilir diye dusunuyorum.

Ornegin, ilk odeme basirisiz olursa, ayni siparis numarasi icin ikinci kere odemeye calisirsaniz VerifyEnrollmentRequestId'nin ayni olmasi sorun cikarir diye dusunuyorum.

Ekstra veri olarak neleri eklemek istiyorsunuz ve ne icin?

<!-- gh-comment-id:2504055852 --> @nuryagdym commented on GitHub (Nov 27, 2024): PayFlex kodu ve dokumentasyonu inceledim. Kodda 3d form verisini olustururken, ve form verisi icin gonderilen API istekte de `$order['id']` degeri kullanilmiyor, dokumantasyonda da order id gonderilmesi gerektigini belirtmemisler. `VerifyEnrollmentRequestId` degerine ise random string ataniyor: https://github.com/mewebstudio/pos/blob/399ce801b9957d61b42884dde031f8bef626e5e9/src/DataMapper/RequestDataMapper/PayFlexV4PosRequestDataMapper.php#L113 Dokumentasyonda ise bu alan hakkinda soyle demis: <img width="1377" alt="image" src="https://github.com/user-attachments/assets/94d330b1-c515-4ad2-9d8a-a6682e544f85"> order id ise sadece `$pos->payment()` calisitiginda kullaniliyor: https://github.com/mewebstudio/pos/blob/399ce801b9957d61b42884dde031f8bef626e5e9/src/DataMapper/RequestDataMapper/PayFlexV4PosRequestDataMapper.php#L80-L81 Dokumantasyonlarina gore de `VerifyEnrollmentRequestId` ile order id ayni sey degil ve ayni olmasi sorun cikarabilir diye dusunuyorum. Ornegin, ilk odeme basirisiz olursa, ayni siparis numarasi icin ikinci kere odemeye calisirsaniz `VerifyEnrollmentRequestId`'nin ayni olmasi sorun cikarir diye dusunuyorum. Ekstra veri olarak neleri eklemek istiyorsunuz ve ne icin?
Author
Owner

@lansas commented on GitHub (Nov 27, 2024):

Bankanin donusunde tekrardan islenebilmesi icin olusturulan order bu projede session Ile tutuluyor. Ama benim projemde return sayfasi banka formunun oldugu firma sayfasindan ayri bir hostta. Bu yuzden session tutamam. Bu yuzden dB veya redis kullanmam gerekiyor. Bu bilgiyi de depolarken tekrardan islenecek order bir key Ile saklanmakta. Cogu zaman bu payten deki oid gibi bir eleman. Fakat payflex de paytendeki gibi form data in icinde gonderilen verinin belli kismini banka geri donmemekte. Payflexde VerifyEnrollmentRequestId form inputs olarak geri donerse cozum olur. Zaten ben VerifyEnrollmentRequestId olusturuldugunda order array verisini key Ile saklayabildim projeye ilave kod ekleyerek. Fakat ben bu sekilde projeye ilave kod eklemek istemiyorum. Bu projenin Update lerinde bu sefer kaybolacak.

Bu arada evet her odeme isteginde yani her form acilisinda VerifyEnrollmentRequestId guncelleniyor lakin order verisinin key degerini de kendi proje kodumda guncellerim. Esas dikkat edilmesi gereken bu extra data yi form input ta donmemeli, kendi proje kodumuz icerisinden cagirmaliyiz.

<!-- gh-comment-id:2504704267 --> @lansas commented on GitHub (Nov 27, 2024): Bankanin donusunde tekrardan islenebilmesi icin olusturulan order bu projede session Ile tutuluyor. Ama benim projemde return sayfasi banka formunun oldugu firma sayfasindan ayri bir hostta. Bu yuzden session tutamam. Bu yuzden dB veya redis kullanmam gerekiyor. Bu bilgiyi de depolarken tekrardan islenecek order bir key Ile saklanmakta. Cogu zaman bu payten deki oid gibi bir eleman. Fakat payflex de paytendeki gibi form data in icinde gonderilen verinin belli kismini banka geri donmemekte. Payflexde VerifyEnrollmentRequestId form inputs olarak geri donerse cozum olur. Zaten ben VerifyEnrollmentRequestId olusturuldugunda order array verisini key Ile saklayabildim projeye ilave kod ekleyerek. Fakat ben bu sekilde projeye ilave kod eklemek istemiyorum. Bu projenin Update lerinde bu sefer kaybolacak. Bu arada evet her odeme isteginde yani her form acilisinda VerifyEnrollmentRequestId guncelleniyor lakin order verisinin key degerini de kendi proje kodumda guncellerim. Esas dikkat edilmesi gereken bu extra data yi form input ta donmemeli, kendi proje kodumuz icerisinden cagirmaliyiz.
Author
Owner

@nuryagdym commented on GitHub (Nov 28, 2024):

Kod ornegi basit olsun diye session ile yapildi. Gercek uygulamada beklentim bu durumlar icin session'i cok ta kullanilmamasi.

Burda ornek kodlarda gosterildigi gibi kutuphane kodunu degistirmeden VerifyEnrollmentRequestId degerine erisebilirsiniz:

    $id = null;
    /** @var \Symfony\Component\EventDispatcher\EventDispatcher $eventDispatcher */
    $eventDispatcher->addListener(RequestDataPreparedEvent::class,
      function (RequestDataPreparedEvent $event) use (&$id) {
       $id = $event->getRequestData()['VerifyEnrollmentRequestId'];

       // isterseniz de farkli deger atayabilirisiniz:
       $data = $event->getRequestData();
       $data['VerifyEnrollmentRequestId'] = '1234';
       $event->setRequestData($data);
    });

    $pos->get3DFormData(...);
<!-- gh-comment-id:2505489535 --> @nuryagdym commented on GitHub (Nov 28, 2024): Kod ornegi basit olsun diye session ile yapildi. Gercek uygulamada beklentim bu durumlar icin session'i cok ta kullanilmamasi. Burda [ornek kodlarda](https://github.com/mewebstudio/pos/blob/master/docs/THREED-PAYMENT-EXAMPLE.md) gosterildigi gibi kutuphane kodunu degistirmeden `VerifyEnrollmentRequestId` degerine erisebilirsiniz: ```php $id = null; /** @var \Symfony\Component\EventDispatcher\EventDispatcher $eventDispatcher */ $eventDispatcher->addListener(RequestDataPreparedEvent::class, function (RequestDataPreparedEvent $event) use (&$id) { $id = $event->getRequestData()['VerifyEnrollmentRequestId']; // isterseniz de farkli deger atayabilirisiniz: $data = $event->getRequestData(); $data['VerifyEnrollmentRequestId'] = '1234'; $event->setRequestData($data); }); $pos->get3DFormData(...); ```
Author
Owner

@lansas commented on GitHub (Nov 29, 2024):

Teşekkürler. Kodu ancak bu haliyle çalıştırabildim.

  $eventDispatcher = new Symfony\Component\EventDispatcher\EventDispatcher();
   $order=[.....];
            $VerifyEnrollmentRequestId = null;
            $eventDispatcher->addListener(
                RequestDataPreparedEvent::class,
                function (RequestDataPreparedEvent $event) use (&$VerifyEnrollmentRequestId) {
                    $VerifyEnrollmentRequestId = $event->getRequestData()['VerifyEnrollmentRequestId'];
                }
            );
            $requestData = ['nonelansas' => '123456']; // Örnek veri
            $event = new RequestDataPreparedEvent($requestData, "ziraat-vpos", AbstractGateway::TX_TYPE_PAY_AUTH, AbstractGateway::class, $order, AbstractGateway::MODEL_3D_SECURE);
            $eventDispatcher->dispatch($event, RequestDataPreparedEvent::class);

  $form_data = $pos->get3DFormData(
                $order,
                AbstractGateway::MODEL_3D_SECURE,
                AbstractGateway::TX_TYPE_PAY_AUTH,
                $o_card
            );

<!-- gh-comment-id:2507571367 --> @lansas commented on GitHub (Nov 29, 2024): Teşekkürler. Kodu ancak bu haliyle çalıştırabildim. ```php $eventDispatcher = new Symfony\Component\EventDispatcher\EventDispatcher(); $order=[.....]; $VerifyEnrollmentRequestId = null; $eventDispatcher->addListener( RequestDataPreparedEvent::class, function (RequestDataPreparedEvent $event) use (&$VerifyEnrollmentRequestId) { $VerifyEnrollmentRequestId = $event->getRequestData()['VerifyEnrollmentRequestId']; } ); $requestData = ['nonelansas' => '123456']; // Örnek veri $event = new RequestDataPreparedEvent($requestData, "ziraat-vpos", AbstractGateway::TX_TYPE_PAY_AUTH, AbstractGateway::class, $order, AbstractGateway::MODEL_3D_SECURE); $eventDispatcher->dispatch($event, RequestDataPreparedEvent::class); $form_data = $pos->get3DFormData( $order, AbstractGateway::MODEL_3D_SECURE, AbstractGateway::TX_TYPE_PAY_AUTH, $o_card ); ```
Author
Owner

@nuryagdym commented on GitHub (Nov 29, 2024):

bu kodun ise yaradigini dusunmuyorum.
Kullanilan $eventDispatcher, $pos nesnesi olustururken kullanilan $pos ile ayni olmasi gerekiyor. Siz ise yenisini olusturmussunuz

$eventDispatcher = new Symfony\Component\EventDispatcher\EventDispatcher();
$pos = \Mews\Pos\Factory\PosFactory::createPosGateway($account, $config, $eventDispatcher, null, $logger);

            $VerifyEnrollmentRequestId = null;
            $eventDispatcher->addListener(
                RequestDataPreparedEvent::class,
                function (RequestDataPreparedEvent $event) use (&$VerifyEnrollmentRequestId) {
                    $VerifyEnrollmentRequestId = $event->getRequestData()['VerifyEnrollmentRequestId'];
                }
            );


  $form_data = $pos->get3DFormData(
                $order,
                AbstractGateway::MODEL_3D_SECURE,
                AbstractGateway::TX_TYPE_PAY_AUTH,
                $o_card
            );

dispatch'i kutuphane yapiyor:
github.com/mewebstudio/pos@399ce801b9/src/Gateways/PayFlexV4Pos.php (L250)

sizin yapmaniz hatali.

<!-- gh-comment-id:2507583886 --> @nuryagdym commented on GitHub (Nov 29, 2024): bu kodun ise yaradigini dusunmuyorum. Kullanilan `$eventDispatcher`, $pos nesnesi olustururken kullanilan $pos ile ayni olmasi gerekiyor. Siz ise yenisini olusturmussunuz ```php $eventDispatcher = new Symfony\Component\EventDispatcher\EventDispatcher(); $pos = \Mews\Pos\Factory\PosFactory::createPosGateway($account, $config, $eventDispatcher, null, $logger); $VerifyEnrollmentRequestId = null; $eventDispatcher->addListener( RequestDataPreparedEvent::class, function (RequestDataPreparedEvent $event) use (&$VerifyEnrollmentRequestId) { $VerifyEnrollmentRequestId = $event->getRequestData()['VerifyEnrollmentRequestId']; } ); $form_data = $pos->get3DFormData( $order, AbstractGateway::MODEL_3D_SECURE, AbstractGateway::TX_TYPE_PAY_AUTH, $o_card ); ``` dispatch'i kutuphane yapiyor: https://github.com/mewebstudio/pos/blob/399ce801b9957d61b42884dde031f8bef626e5e9/src/Gateways/PayFlexV4Pos.php#L250 sizin yapmaniz hatali.
Author
Owner

@lansas commented on GitHub (Nov 29, 2024):

Evet bu şekil doğru. Benimki hatalı. Aslında ilk yazdığın da doğruydu. Sadece use kısmında
use Mews\Pos\Event\RequestDataPreparedEvent;
belirtmemişim.

<!-- gh-comment-id:2507927579 --> @lansas commented on GitHub (Nov 29, 2024): Evet bu şekil doğru. Benimki hatalı. Aslında ilk yazdığın da doğruydu. Sadece use kısmında ` use Mews\Pos\Event\RequestDataPreparedEvent; ` belirtmemişim.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/pos#131
No description provided.