Skip to content

Commit

Permalink
Added nestpay processor tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Ibrahim Gunduz committed May 3, 2018
1 parent 578f2b4 commit dfbc5bf
Show file tree
Hide file tree
Showing 75 changed files with 1,089 additions and 609 deletions.
24 changes: 14 additions & 10 deletions docs/31-satis-islemi.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ Satış isteği, **Paranoia\Request** tipinde bir nesnenin sipariş ve ödeme a

```php
$request = new \Paranoia\Request();
$request->setCardNumber('5406******675403')
->setSecurityCode('000')
->setExpireMonth(12)
->setExpireYear(2015)
->setOrderId('ORDER000000' . time())
$request->setOrderId('ORDER000000' . time())
->setAmount(100.35)
->setCurrency('TRY');
$card = new \Paranoia\Resource\Card();
$card->setNumber('5406******675403')
->setSecurityCode('000')
->setExpireMonth(12)
->setExpireYear(2015);
$request->setResource($card);
```

## 3.1.3. Satış İsteği Sırasında Beklenen Parametreler
Expand All @@ -36,13 +38,15 @@ $request->setCardNumber('5406******675403')
* Satış işlemi için yeni bir sipariş isteği oluşturuyoruz.
```php
$request = new \Paranoia\Request();
$request->setCardNumber('5406******675403')
->setSecurityCode('000')
->setExpireMonth(12)
->setExpireYear(2015)
->setOrderId('ORDER000000' . time())
$request->setOrderId('ORDER000000' . time())
->setAmount(100.35)
->setCurrency('TRY');
$card = new \Paranoia\Resource\Card();
$card->setNumber('5406******675403')
->setSecurityCode('000')
->setExpireMonth(12)
->setExpireYear(2015);
$request->setResource($card);
```

* Sağlayıcı API'sine bağlantı kurmak için gerekli konfigürasyon bilgilerini dolduruyoruz. Konfigürasyon parametreleri, ödeme sistemi sağlayıcısına göre değişkenlik göstermektedir. Ödeme sağlayıcılarına göre gerekli konfigürasyon tanımlamaları hakkında daha fazla bilgi edinmek için [bu bölümü]() inceleyiniz.
Expand Down
2 changes: 1 addition & 1 deletion src/Builder/AbstractRequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
namespace Paranoia\Builder;

use Paranoia\Configuration\AbstractConfiguration;
use Paranoia\Request;
use Paranoia\Request\Request;

abstract class AbstractRequestBuilder
{
Expand Down
19 changes: 13 additions & 6 deletions src/Builder/Gvp/BaseRequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
use Paranoia\Formatter\IsoNumericCurrencyCodeFormatter;
use Paranoia\Formatter\MoneyFormatter;
use Paranoia\Formatter\SingleDigitInstallmentFormatter;
use Paranoia\Request;
use Paranoia\Request\Request;
use Paranoia\Request\Resource\Card;
use Paranoia\Request\Resource\ResourceInterface;

abstract class BaseRequestBuilder extends AbstractRequestBuilder
{
Expand Down Expand Up @@ -96,19 +98,24 @@ protected function buildTerminal(Request $request)
);
}

protected function buildCard(Request $request)
protected function buildCard(ResourceInterface $card)
{
assert($card instanceof Card);

/** @var Card $_card */
$_card = $card;

$expireMonth = $this->expireDateFormatter->format(
[
$request->getExpireMonth(),
$request->getExpireYear()
$_card->getExpireMonth(),
$_card->getExpireYear()
]
);

return array(
'Number' => $request->getCardNumber(),
'Number' => $_card->getNumber(),
'ExpireDate' => $expireMonth,
'CVV2' => $request->getSecurityCode()
'CVV2' => $_card->getSecurityCode()
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Builder/Gvp/CancelRequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use Paranoia\Common\Serializer\Serializer;
use Paranoia\Configuration\Gvp;
use Paranoia\Request;
use Paranoia\Request\Request;

class CancelRequestBuilder extends BaseRequestBuilder
{
Expand Down
2 changes: 1 addition & 1 deletion src/Builder/Gvp/PostAuthorizationRequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use Paranoia\Common\Serializer\Serializer;
use Paranoia\Configuration\Gvp;
use Paranoia\Request;
use Paranoia\Request\Request;

class PostAuthorizationRequestBuilder extends BaseRequestBuilder
{
Expand Down
6 changes: 3 additions & 3 deletions src/Builder/Gvp/PreAuthorizationRequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use Paranoia\Common\Serializer\Serializer;
use Paranoia\Configuration\Gvp;
use Paranoia\Request;
use Paranoia\Request\Request;

class PreAuthorizationRequestBuilder extends BaseRequestBuilder
{
Expand All @@ -14,7 +14,7 @@ public function build(Request $request)
{
$data = array_merge(
$this->buildBaseRequest($request),
['Card' => $this->buildCard($request)]
['Card' => $this->buildCard($request->getResource())]
);

$serializer = new Serializer(Serializer::XML);
Expand Down Expand Up @@ -53,7 +53,7 @@ protected function buildHash(Request $request, $password)
'%s%s%s%s%s',
$request->getOrderId(),
$configuration->getTerminalId(),
$request->getCardNumber(),
$request->getResource()->getNumber(),
$this->amountFormatter->format($request->getAmount()),
$this->generateSecurityHash($password)
)
Expand Down
2 changes: 1 addition & 1 deletion src/Builder/Gvp/RefundRequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use Paranoia\Common\Serializer\Serializer;
use Paranoia\Configuration\Gvp;
use Paranoia\Request;
use Paranoia\Request\Request;

class RefundRequestBuilder extends BaseRequestBuilder
{
Expand Down
6 changes: 3 additions & 3 deletions src/Builder/Gvp/SaleRequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use Paranoia\Common\Serializer\Serializer;
use Paranoia\Configuration\Gvp;
use Paranoia\Request;
use Paranoia\Request\Request;

class SaleRequestBuilder extends BaseRequestBuilder
{
Expand All @@ -14,7 +14,7 @@ public function build(Request $request)
{
$data = array_merge(
$this->buildBaseRequest($request),
['Card' => $this->buildCard($request)]
['Card' => $this->buildCard($request->getResource())]
);

$serializer = new Serializer(Serializer::XML);
Expand Down Expand Up @@ -54,7 +54,7 @@ protected function buildHash(Request $request, $password)
'%s%s%s%s%s',
$request->getOrderId(),
$configuration->getTerminalId(),
$request->getCardNumber(),
$request->getResource()->getNumber(),
$this->amountFormatter->format($request->getAmount()),
$this->generateSecurityHash($password)
)
Expand Down
23 changes: 23 additions & 0 deletions src/Builder/NestPay/BaseRequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
use Paranoia\Formatter\IsoNumericCurrencyCodeFormatter;
use Paranoia\Formatter\NestPay\ExpireDateFormatter;
use Paranoia\Formatter\SingleDigitInstallmentFormatter;
use Paranoia\Request\Resource\Card;
use Paranoia\Request\Resource\ResourceInterface;

abstract class BaseRequestBuilder extends AbstractRequestBuilder
{
Expand Down Expand Up @@ -48,4 +50,25 @@ protected function buildBaseRequest($type)
'Type' => $type,
];
}

protected function buildCard(ResourceInterface $card)
{
assert($card instanceof Card);

/** @var Card $_card */
$_card = $card;

$expireDate = $this->expireDateFormatter->format(
[
$_card->getExpireMonth(),
$_card->getExpireYear()
]
);

return array(
'Number' => $_card->getNumber(),
'Cvv2Val' => $_card->getSecurityCode(),
'Expires' => $expireDate
);
}
}
2 changes: 1 addition & 1 deletion src/Builder/NestPay/CancelRequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
namespace Paranoia\Builder\NestPay;

use Paranoia\Common\Serializer\Serializer;
use Paranoia\Request;
use Paranoia\Request\Request;

class CancelRequestBuilder extends BaseRequestBuilder
{
Expand Down
2 changes: 1 addition & 1 deletion src/Builder/NestPay/PostAuthorizationRequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
namespace Paranoia\Builder\NestPay;

use Paranoia\Common\Serializer\Serializer;
use Paranoia\Request;
use Paranoia\Request\Request;

class PostAuthorizationRequestBuilder extends BaseRequestBuilder
{
Expand Down
13 changes: 3 additions & 10 deletions src/Builder/NestPay/PreAuthorizationRequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
namespace Paranoia\Builder\NestPay;

use Paranoia\Common\Serializer\Serializer;
use Paranoia\Request;
use Paranoia\Request\Request;

class PreAuthorizationRequestBuilder extends BaseRequestBuilder
{
Expand All @@ -17,15 +17,8 @@ public function build(Request $request)
'OrderId' => $request->getOrderId(),
'Total' => $this->amountFormatter->format($request->getAmount()),
'Currency' => $this->currencyCodeFormatter->format($request->getCurrency()),
'Number' => $request->getCardNumber(),
'Cvv2Val' => $request->getSecurityCode(),
'Expires' => $this->expireDateFormatter->format(
[
$request->getExpireMonth(),
$request->getExpireYear()
]
),
]
],
$this->buildCard($request->getResource())
);

$serializer = new Serializer(Serializer::XML);
Expand Down
2 changes: 1 addition & 1 deletion src/Builder/NestPay/RefundRequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
namespace Paranoia\Builder\NestPay;

use Paranoia\Common\Serializer\Serializer;
use Paranoia\Request;
use Paranoia\Request\Request;

class RefundRequestBuilder extends BaseRequestBuilder
{
Expand Down
13 changes: 3 additions & 10 deletions src/Builder/NestPay/SaleRequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
namespace Paranoia\Builder\NestPay;

use Paranoia\Common\Serializer\Serializer;
use Paranoia\Request;
use Paranoia\Request\Request;

class SaleRequestBuilder extends BaseRequestBuilder
{
Expand All @@ -17,15 +17,8 @@ public function build(Request $request)
'OrderId' => $request->getOrderId(),
'Total' => $this->amountFormatter->format($request->getAmount()),
'Currency' => $this->currencyCodeFormatter->format($request->getCurrency()),
'Number' => $request->getCardNumber(),
'Cvv2Val' => $request->getSecurityCode(),
'Expires' => $this->expireDateFormatter->format(
[
$request->getExpireMonth(),
$request->getExpireYear()
]
),
]
],
$this->buildCard($request->getResource())
);

if ($request->getInstallment()) {
Expand Down
25 changes: 16 additions & 9 deletions src/Builder/Posnet/BaseRequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,19 @@
use Paranoia\Formatter\Posnet\CustomCurrencyCodeFormatter;
use Paranoia\Formatter\Posnet\ExpireDateFormatter;
use Paranoia\Formatter\Posnet\OrderIdFormatter;
use Paranoia\Request;
use Paranoia\Request\Request;
use Paranoia\Request\Resource\Card;
use Paranoia\Request\Resource\ResourceInterface;

abstract class BaseRequestBuilder extends AbstractRequestBuilder
{
/** @var DecimalFormatter */
/** @var MoneyFormatter */
protected $amountFormatter;

/** @var IsoNumericCurrencyCodeFormatter */
/** @var CustomCurrencyCodeFormatter */
protected $currencyCodeFormatter;

/** @var SingleDigitInstallmentFormatter */
/** @var MultiDigitInstallmentFormatter */
protected $installmentFormatter;

/** @var ExpireDateFormatter */
Expand Down Expand Up @@ -56,15 +58,20 @@ protected function buildBaseRequest(Request $request)
];
}

protected function buildCard(Request $request)
protected function buildCard(ResourceInterface $card)
{
assert($card instanceof Card);

/** @var Card $_card */
$_card = $card;

return [
'ccno' => $request->getCardNumber(),
'cvc' => $request->getSecurityCode(),
'ccno' => $_card->getNumber(),
'cvc' => $_card->getSecurityCode(),
'expDate' => $this->expireDateFormatter->format(
[
$request->getExpireMonth(),
$request->getExpireYear()
$_card->getExpireMonth(),
$_card->getExpireYear()
]
)
];
Expand Down
2 changes: 1 addition & 1 deletion src/Builder/Posnet/CancelRequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
namespace Paranoia\Builder\Posnet;

use Paranoia\Common\Serializer\Serializer;
use Paranoia\Request;
use Paranoia\Request\Request;

class CancelRequestBuilder extends BaseRequestBuilder
{
Expand Down
2 changes: 1 addition & 1 deletion src/Builder/Posnet/PostAuthorizationRequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
namespace Paranoia\Builder\Posnet;

use Paranoia\Common\Serializer\Serializer;
use Paranoia\Request;
use Paranoia\Request\Request;

class PostAuthorizationRequestBuilder extends BaseRequestBuilder
{
Expand Down
4 changes: 2 additions & 2 deletions src/Builder/Posnet/PreAuthorizationRequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
namespace Paranoia\Builder\Posnet;

use Paranoia\Common\Serializer\Serializer;
use Paranoia\Request;
use Paranoia\Request\Request;

class PreAuthorizationRequestBuilder extends BaseRequestBuilder
{
Expand All @@ -20,7 +20,7 @@ public function build(Request $request)
'currencyCode' => $this->currencyCodeFormatter->format($request->getCurrency()),
'orderID' => $this->orderIdFormatter->format($request->getOrderId())
],
$this->buildCard($request)
$this->buildCard($request->getResource())
)
]
);
Expand Down
2 changes: 1 addition & 1 deletion src/Builder/Posnet/RefundRequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
namespace Paranoia\Builder\Posnet;

use Paranoia\Common\Serializer\Serializer;
use Paranoia\Request;
use Paranoia\Request\Request;

class RefundRequestBuilder extends BaseRequestBuilder
{
Expand Down
Loading

0 comments on commit dfbc5bf

Please sign in to comment.