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

3D Secure Eklendi. #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea
vendor
*.lock
*.lock
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Composer .lock dosyasını gitignore'a eklemek iyi bir pratik değil diye biliyorum. Uygulamanın her branch'inde composer.lock versiyonlanmalı ve kodla birlikte dağıtılmalı. Bağımlılık olarak bu kütüphaneyi kullanan uygulamalar, composer install ile kurulum yaptıklarında lock file spesifik (son commit edilen) versiyona işaret ediyor olmalı.

**/.DS_Store
19 changes: 19 additions & 0 deletions docs/pesin_satis.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ $configuration = new Configuration();
$configuration->setMerchantId('MY_MERCHANT_01')
->setSecretKey('SECRET_KEY')
->setPaymentEndpointUrl('https://secure.payu.com.tr/order/alu/v3');
->setReturnUrl('http://payu/cs/payu_3dreturn.php');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Döküman son kullanıcı tarafından değerlendirileceği için buradaki alan adının örnek olduğunu anlamayabilirler. example.com/3d_return.php şeklinde birşeyler olursa sanki biraz daha anlamlı olur gibi duruyor.


$client = new Client($configuration);
```
Expand Down Expand Up @@ -91,6 +92,15 @@ if($response->getStatus() == ResponseAbstract::STATUS_APPROVED) {
echo $response->getTransactionId()
*/
} else {
/*
// Eğer Kredi Kartı 3D Secure korumalıysa
if (($response->getCode() == ResponseAbstract::SECURE3D)) {

header("Location:" . $response->getUrl_3ds());
exit();
}
*/

/*
// Odeme islemi hatali oldu

Expand All @@ -112,6 +122,7 @@ $configuration = new Configuration();
$configuration->setMerchantId('MY_MERCHANT_01')
->setSecretKey('SECRET_KEY')
->setPaymentEndpointUrl('https://secure.payu.com.tr/order/alu/v3');
->setReturnUrl('http://payu/cs/payu_3dreturn.php');

$client = new Client($configuration);

Expand All @@ -131,6 +142,14 @@ if($response->getStatus() == ResponseAbstract::STATUS_APPROVED) {
echo $response->getTransactionId()
*/
} else {
/*
// Eğer Kredi Kartı 3D Secure korumalıysa
if (($response->getCode() == ResponseAbstract::SECURE3D)) {

header("Location:" . $response->getUrl_3ds());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normal şartlarda banka, 3d Secure authorizasyonu sırasında kart formundan gelen bilgilerin kendisine HTTP/POST olarak gönderilmesini bekliyor. Bu implementasyonda kartın 3d secure olması durumunda yönlendiğiniz sayfaya herhangibir parametre taşındığını göremiyorum. Bunun doğru olduğundan emin misiniz ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Evet. Taşıyor.

exit();
}
*/
/*
// Odeme islemi hatali oldu

Expand Down
26 changes: 25 additions & 1 deletion src/Payu/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,24 @@ class Configuration
*/
private $paymentEndpointUrl;

/**
* @var string
*/
private $returnUrl;

/**
* @var string
*/
private $loyaltyInquiryEndPointUrl;

public function __construct($merchantId = null, $secretKey = null, $paymentEndpointUrl = null,
$loyaltyInquiryEndPointUrl = null)
$loyaltyInquiryEndPointUrl = null, $returnUrl = null)
{
$this->merchantId = $merchantId;
$this->secretKey = $secretKey;
$this->paymentEndpointUrl = $paymentEndpointUrl;
$this->loyaltyInquiryEndPointUrl = $loyaltyInquiryEndPointUrl;
$this->returnUrl = $returnUrl;
}

/**
Expand Down Expand Up @@ -103,4 +109,22 @@ public function getSecretKey()
{
return $this->secretKey;
}

/**
* @param string $returnUrl
* @return $this
*/
public function setReturnUrl($returnUrl)
{
$this->returnUrl = $returnUrl;
return $this;
}

/**
* @return string
*/
public function getReturnUrl()
{
return $this->returnUrl;
}
}
3 changes: 2 additions & 1 deletion src/Payu/Parser/PaymentResponseParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ public function parse($rawData)
$status = (string) $xml->STATUS;
$code = (string) $xml->RETURN_CODE;
$message = (string) $xml->RETURN_MESSAGE;
$url_3ds = (string) $xml->URL_3DS;
$statusCode = $status == 'SUCCESS' && $code == 'AUTHORIZED' ?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Burada kartın 3d secure gerekliliği ile ilgili herhangibir kontrol eklenmemiş. Normalde 3D_SECURE_ENROLLED gibi bir bilgi dönüyor olması lazım.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

URL_3DS her sorguda dönüyor.

ResponseAbstract::STATUS_APPROVED : ResponseAbstract::STATUS_DECLINED;
$transactionId = $statusCode == ResponseAbstract::STATUS_APPROVED ? (string) $xml->REFNO : null;
return new PaymentResponse($statusCode, $code, $message, $transactionId);
return new PaymentResponse($statusCode, $code, $message, $transactionId, $url_3ds);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sınıf özellikleri, metod isimleri, metod argümanları ve değişkenler camelCase olarak isimlendirilmeli.

}
}
26 changes: 25 additions & 1 deletion src/Payu/Response/PaymentResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,28 @@ class PaymentResponse extends ResponseAbstract
*/
protected $transactionId;

/**
* @var string
*/
protected $url_3ds;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sınıf özellikleri, metod isimleri, metod argümanları ve değişkenler camelCase olarak isimlendirilmeli.


/**
* @param string $url_3ds
* @return $this;
*/
public function setUrl_3ds($url_3ds)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sınıf özellikleri, metod isimleri, metod argümanları ve değişkenler camelCase olarak isimlendirilmeli.

{
$this->url_3ds = $url_3ds;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sınıf özellikleri, metod isimleri, metod argümanları ve değişkenler camelCase olarak isimlendirilmeli.

}

/**
* @return string
*/
public function getUrl_3ds()
{
return $this->url_3ds;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sınıf özellikleri, metod isimleri, metod argümanları ve değişkenler camelCase olarak isimlendirilmeli.

}

/**
* @param string $transactionId
* @return $this;
Expand All @@ -30,10 +52,12 @@ public function getTransactionId()
* @param string $code
* @param string $message
* @param string $transactionId
* @param string $url_3ds
*/
public function __construct($status, $code, $message, $transactionId)
public function __construct($status, $code, $message, $transactionId, $url_3ds)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sınıf özellikleri, metod isimleri, metod argümanları ve değişkenler camelCase olarak isimlendirilmeli.

{
parent::__construct($status, $code, $message);
$this->setTransactionId($transactionId);
$this->setUrl_3ds($url_3ds);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sınıf özellikleri, metod isimleri, metod argümanları ve değişkenler camelCase olarak isimlendirilmeli.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

camelCase leri birisi düzeltemez mi? Çok vaktim olmuyor.

}
}
1 change: 1 addition & 0 deletions src/Payu/Response/ResponseAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ abstract class ResponseAbstract
{
const STATUS_APPROVED = 200;
const STATUS_DECLINED = 500;
const SECURE3D = "3DS_ENROLLED";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

İsimlendirme konusu biraz sıkıntılı görünüyor. Aslında kartın 3D Secure enrolled olma durumu, kartın 3d secure gerektiren bir kart olması nedeniyle para çekilemediği anlamına gelir dolaysıyla bu da success ve fail olmak gibi bir durumdur. Bu noktada başında STATUS_ önekinin olması daha doğru olur. Ayrıca diğer sabitler sayısal olarak değerlendirilmişken SECURED değişkeninin string olarak değerlendirilmesi de yine standard dışı bir durum. Ya diğerleri de string olmalı ya da buna da 4xx şeklinde bir değerlendirme yapılmalı. Seçim sizin.


/**
* @var integer
Expand Down
1 change: 1 addition & 0 deletions src/Payu/Serializer/PaymentRequestSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ public function serialize()

$filteredData = array_filter($concatenatedData);
$filteredData['MERCHANT'] = $this->configuration->getMerchantId();
$filteredData['BACK_REF'] = $this->configuration->getReturnUrl();
$filteredData['ORDER_HASH'] = $this->calculateHash($filteredData);

return $filteredData;
Expand Down
1 change: 1 addition & 0 deletions tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public function setUp()
->setSecretKey('SECRET_KEY')
->setPaymentEndpointUrl('https://secure.payu.com.tr/order/alu/v3')
->setLoyaltyInquiryEndPointUrl('https://secure.payu.com.tr/api/loyalty-points/check');
->setReturnUrl('http://payu/cs/payu_3dreturn.php');
$this->configuration = $configuration;
$this->client = new Client($configuration);
}
Expand Down
9 changes: 8 additions & 1 deletion tests/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase

public function setUp() {
$this->configuration = new Configuration('TestMerchantId', 'TestSecretKey', 'TestPaymentEndpointUrl',
'TestLoyaltyInquiryEndPointUrl');
'TestLoyaltyInquiryEndPointUrl', 'Test3DReturnUrl');
}

public function testConstructor() {
$this->assertEquals('TestMerchantId', $this->configuration->getMerchantId());
$this->assertEquals('TestSecretKey', $this->configuration->getSecretKey());
$this->assertEquals('TestPaymentEndpointUrl', $this->configuration->getPaymentEndpointUrl());
$this->assertEquals('TestLoyaltyInquiryEndPointUrl', $this->configuration->getLoyaltyInquiryEndPointUrl());
$this->assertEquals('Test3DReturnUrl', $this->configuration->getReturnUrl());
}

public function testSetMerchantId() {
Expand All @@ -40,4 +41,10 @@ public function testSetLoyaltyInquiryEndPointUrl() {
$this->configuration->setLoyaltyInquiryEndPointUrl('TestLoyaltyInquiryEndPointUrlSetter');
$this->assertEquals('TestLoyaltyInquiryEndPointUrlSetter', $this->configuration->getLoyaltyInquiryEndPointUrl());
}

public function testSet3DReturnUrl() {
$this->configuration->setReturnUrl('Test3DReturnUrlSetter');
$this->assertEquals('Test3DReturnUrlSetter', $this->configuration->getReturnUrl());
}

}