Skip to content

Commit

Permalink
Merge branch 'master' into feature/woo-66-initiatingSystemUserAgent
Browse files Browse the repository at this point in the history
  • Loading branch information
aait authored Jan 7, 2021
2 parents 0910785 + 497edae commit 1d0eceb
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
use SwedbankPay\Api\Service\Payment\Transaction\Resource\Response\AuthorizationObject;
use SwedbankPay\Api\Service\Request;

/**
* Class CreateAuthorization
* @deprecated Direct Invoice is about to be phased out.
* @package SwedbankPay\Api\Service\Invoice\Transaction\Request
*/
class CreateAuthorization extends Request
{
public function setup()
Expand Down
80 changes: 20 additions & 60 deletions tests/InvoicePaymentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@
*/
class InvoicePaymentTest extends TestCase
{
protected $paymentId = '/psp/invoice/payments/72160e13-6dec-468d-81c9-08d8a4cc1843';

public function testApiCredentails()
{
try {
Expand Down Expand Up @@ -186,7 +188,6 @@ public function testCreateApprovedLegalAddress($paymentId)
/**
* @depends InvoicePaymentTest::testInvoicePaymentRequest
* @param string $paymentId
* @throws \SwedbankPay\Api\Client\Exception
*/
public function testCreateAuthorizationTransaction($paymentId)
{
Expand Down Expand Up @@ -246,32 +247,24 @@ public function testCreateAuthorizationTransaction($paymentId)
return $result['authorization'];
}

/**
* @depends InvoicePaymentTest::testInvoicePaymentRequest
* @depends InvoicePaymentTest::testCreateAuthorizationTransaction
* @param string $paymentId
* @param array $authorization
*/
public function testCapture($paymentId, $authorization)
public function testCapture()
{
$this->assertIsArray($authorization);

$transactionData = new TransactionCapture();
$transactionData->setActivity('FinancingConsumer')
->setAmount(100)
->setAmount(1)
->setVatAmount(0)
->setDescription('Test Capture')
->setPayeeReference($this->generateRandomString(12))
->setReceiptReference($this->generateRandomString(12))
->setItemDescriptions([
[
'amount' => 100,
'amount' => 1,
'description' => 'item description 1'
]
])
->setVatSummary([
[
'amount' => 100,
'amount' => 1,
'vatPercent' => 0,
'vatAmount' => 0
]
Expand All @@ -282,7 +275,7 @@ public function testCapture($paymentId, $authorization)

$requestService = new CreateCapture($transaction);
$requestService->setClient($this->client);
$requestService->setPaymentId($paymentId);
$requestService->setPaymentId($this->paymentId);

/** @var ResponseServiceInterface $responseService */
$responseService = $requestService->send();
Expand All @@ -304,18 +297,17 @@ public function testCapture($paymentId, $authorization)
}

/**
* @depends InvoicePaymentTest::testInvoicePaymentRequest
* @depends InvoicePaymentTest::testCapture
* @param string $paymentId
* @param array $capture
*/
public function testReversal($paymentId, $capture)
public function testReversal($capture)
{
$this->assertIsArray($capture);

$transactionData = new TransactionReversal();
$transactionData->setActivity('FinancingConsumer')
->setAmount(100)
->setAmount(1)
->setVatAmount(0)
->setDescription('Test refund')
->setPayeeReference($this->generateRandomString(12))
Expand All @@ -326,7 +318,7 @@ public function testReversal($paymentId, $capture)

$requestService = new CreateReversal($transaction);
$requestService->setClient($this->client)
->setPaymentId($paymentId);
->setPaymentId($this->paymentId);

/** @var ResponseServiceInterface $responseService */
$responseService = $requestService->send();
Expand All @@ -347,19 +339,11 @@ public function testReversal($paymentId, $capture)
return $result['reversal'];
}

/**
* @depends InvoicePaymentTest::testInvoicePaymentRequest
* @depends InvoicePaymentTest::testCreateAuthorizationTransaction
* @param string $paymentId
* @param array $authorization
*/
public function testGetAuthorizations($paymentId, $authorization)
public function testGetAuthorizations()
{
$this->assertIsArray($authorization);

$requestService = new GetAuthorizations();
$requestService->setClient($this->client)
->setPaymentId($paymentId);
->setPaymentId($this->paymentId);

/** @var ResponseServiceInterface $responseService */
$responseService = $requestService->send();
Expand Down Expand Up @@ -411,19 +395,11 @@ public function testGetAuthorization($authorizations)
}
}

/**
* @depends InvoicePaymentTest::testInvoicePaymentRequest
* @depends InvoicePaymentTest::testCapture
* @param string $paymentId
* @param array $capture
*/
public function testGetCaptures($paymentId, $capture)
public function testGetCaptures()
{
$this->assertIsArray($capture);

$requestService = new GetCaptures();
$requestService->setClient($this->client)
->setPaymentId($paymentId);
->setPaymentId($this->paymentId);

/** @var ResponseServiceInterface $responseService */
$responseService = $requestService->send();
Expand Down Expand Up @@ -475,19 +451,11 @@ public function testGetCapture($capture)
}
}

/**
* @depends InvoicePaymentTest::testInvoicePaymentRequest
* @depends InvoicePaymentTest::testReversal
* @param string $paymentId
* @param array $reversal
*/
public function testGetReversals($paymentId, $reversal)
public function testGetReversals()
{
$this->assertIsArray($reversal);

$requestService = new GetReversals();
$requestService->setClient($this->client)
->setPaymentId($paymentId);
->setPaymentId($this->paymentId);

/** @var ResponseServiceInterface $responseService */
$responseService = $requestService->send();
Expand Down Expand Up @@ -539,15 +507,11 @@ public function testGetReversal($reversals)
}
}

/**
* @depends InvoicePaymentTest::testInvoicePaymentRequest
* @param string $paymentId
*/
public function testGetTransactions($paymentId)
public function testGetTransactions()
{
$requestService = new GetTransactions();
$requestService->setClient($this->client)
->setPaymentId($paymentId);
->setPaymentId($this->paymentId);

/** @var ResponseServiceInterface $responseService */
$responseService = $requestService->send();
Expand Down Expand Up @@ -610,17 +574,13 @@ public function testGetTransaction($transactions)
}
}

/**
* @depends InvoicePaymentTest::testInvoicePaymentRequest
* @param string $paymentId
*/
public function testGetCancellations($paymentId)
public function testGetCancellations()
{
$this->expectException(ClientException::class);

$requestService = new GetCancellations();
$requestService->setClient($this->client)
->setPaymentId($paymentId);
->setPaymentId($this->paymentId);

/** @var ResponseServiceInterface $responseService */
$responseService = $requestService->send();
Expand Down

0 comments on commit 1d0eceb

Please sign in to comment.