Skip to content

Commit

Permalink
payvision-sdk-php v2.1.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
m.vela committed Nov 22, 2019
1 parent c59fcc0 commit 4940364
Show file tree
Hide file tree
Showing 6 changed files with 139 additions and 142 deletions.
12 changes: 6 additions & 6 deletions Troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@

## Connectivity

### Error: wrong signature type
### Error: wrong signature type

Full error message: `error:1414D172:SSL routines:tls12_check_peer_sigalg:wrong signature type`

This error is thrown when there is a connectivity issue with Payvision Payment servers.
Due to compatibility reasons the servers currently only support OpenSSL security level 1.
This error is thown when there is a connectivity issue with the Payvision payment servers.
Due to compatibility reasons the servers currently only support openssl security level 1.

Some newer systems (like Debian Buster) increased their default security level to level 2, which makes it impossible to connect.
See: https://wiki.debian.org/ContinuousIntegration/TriagingTips/openssl-1.1.1

As a temporary workaround, the security level on a Debian Buster system can be lowered by updating a line in the `/etc/ssl/openssl.cnf` file.
Change the line
Change the line

CipherString = DEFAULT@SECLEVEL=2

to

CipherString = DEFAULT@SECLEVEL=1

Revert the change once the Payvision servers are OpenSSL level 2 compatible.
Revert the change once the Payvision servers are openssl level 2 compatible.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "payvision/payvision-sdk-php",
"description": "Payvision PHP SDK",
"type": "library",
"version": "2.0.2",
"version": "2.1.0",
"license": "MIT",
"require": {
"php": "^7.0.13|^7.1",
Expand Down
4 changes: 4 additions & 0 deletions src/etc/brands.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@
</issuer>
</issuers>
</brand>
<brand id="3020">
<name>Sofort</name>
<async>true</async>
</brand>
</category>
<category name="Wallet" id="4">
<brand id="4010">
Expand Down
97 changes: 97 additions & 0 deletions tests/Test/Api/AbstractPaymentTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<?php

declare(strict_types=1);

namespace Payvision\SDK\Test\Api;

use Payvision\SDK\Application\Payments\Service\RequestBuilder;
use Payvision\SDK\Domain\Payments\Service\Builder\Composite\Payment\Request as PaymentRequestBuilder;
use Payvision\SDK\Domain\Payments\Service\Builder\Composite\Refund\Request as RefundRequestBuilder;
use Payvision\SDK\Domain\Payments\ValueObject\Payment\Request as PaymentRequest;
use Payvision\SDK\Domain\Payments\ValueObject\Payment\Response as PaymentResponse;
use Payvision\SDK\Exception\Api\ErrorResponse;
use Payvision\SDK\Exception\DataTypeException;

abstract class AbstractPaymentTest extends AbstractTestCase
{
const BRAND_ID = 0;

/**
* @var PaymentRequestBuilder
*/
protected $paymentRequestBuilder;

/**
* @var RefundRequestBuilder
*/
protected $refundRequestBuilder;

/**
* @return null
* @throws DataTypeException
*/
protected function setUp()
{
parent::setUp();

$this->paymentRequestBuilder = new PaymentRequestBuilder();
$this->refundRequestBuilder = new RefundRequestBuilder();
}

protected function createFakePaymentRequest(): PaymentRequest
{
$this->prepareFakePaymentRequest();
return $this->paymentRequestBuilder->build();
}

/**
* @return null
*/
protected function prepareFakePaymentRequest()
{
$this->paymentRequestBuilder->header()->setBusinessId($this->credentials['businessId']);
$this->paymentRequestBuilder->body()->transaction()
->setAmount(1.00)
->setPurchaseId('1234')
->setTrackingCode($this->generateTrackingCode())
->setReturnUrl('https://www.example.com')
->setBrandId(static::BRAND_ID)
->setDescriptor('DESC')
->setCurrencyCode('EUR');
$this->paymentRequestBuilder->setAction(PaymentRequest::ACTION_PAYMENT);
}

/**
* @return null
*/
public function testPaymentCreationSuccessful()
{
$requestObject = $this->createFakePaymentRequest();
$request = RequestBuilder::newPayment($requestObject);

/** @var PaymentResponse $response */
$response = $this->apiConnection->execute($request);

$this->assertInstanceOf($request->getResponseObjectByStatusCode(200), $response);
$this->assertEquals(PaymentResponse::PENDING, $response->getResult());
}

/**
* @return null
*/
public function testPaymentCreationFailed()
{
$this->prepareFakePaymentRequest();
$this->paymentRequestBuilder->body()->transaction()
->setCurrencyCode('FAKE')
->setCountryCode('ZZ');

$requestObject = $this->paymentRequestBuilder->build();
$request = RequestBuilder::newPayment($requestObject);

$this->expectException(ErrorResponse::class);

/** @var PaymentResponse $response */
$this->apiConnection->execute($request);
}
}
140 changes: 5 additions & 135 deletions tests/Test/Api/IDealTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,149 +9,19 @@

namespace Payvision\SDK\Test\Api;

use Payvision\SDK\Application\Payments\Service\RequestBuilder;
use Payvision\SDK\Domain\Payments\Service\Builder\Composite\Payment\Request as PaymentRequestBuilder;
use Payvision\SDK\Domain\Payments\Service\Builder\Composite\Refund\Request as RefundRequestBuilder;
use Payvision\SDK\Domain\Payments\ValueObject\Payment\Request as PaymentRequest;
use Payvision\SDK\Domain\Payments\ValueObject\Payment\Response as PaymentResponse;
use Payvision\SDK\Domain\Payments\ValueObject\Refund\Response as RefundResponseRequest;
use Payvision\SDK\Exception\Api\ErrorResponse;
use Payvision\SDK\Exception\ApiException;
use Payvision\SDK\Exception\BuilderException;
use Payvision\SDK\Exception\DataTypeException;

class IDealTest extends AbstractTestCase
class IDealTest extends AbstractPaymentTest
{
/**
* @var PaymentRequestBuilder
*/
protected $paymentRequestBuilder;

/**
* @var RefundRequestBuilder
*/
protected $refundRequestBuilder;
const BRAND_ID = 3010;

/**
* @return null
* @throws DataTypeException
*/
protected function setUp()
{
parent::setUp();

$this->paymentRequestBuilder = new PaymentRequestBuilder();
$this->refundRequestBuilder = new RefundRequestBuilder();
}

/**
* @return array
* @throws ApiException
* @throws BuilderException
* @throws ErrorResponse
*/
public function testNewIdealPaymentShouldBePending(): array
protected function prepareFakePaymentRequest()
{
// what to do with the business ID? It is required for the header, so it is required in the builder process,
// but the API adds it automatically. Who's responsibility is it to supply the business ID?
// Is it part of the initialization of the API or part of the request (as specified)?
$requestObject = $this->createFakePaymentRequest();

$request = RequestBuilder::newPayment($requestObject);

/** @var PaymentResponse $response */
$response = $this->apiConnection->execute($request);

$this->assertInstanceOf($request->getResponseObjectByStatusCode(200), $response);
$this->assertEquals(PaymentResponse::PENDING, $response->getResult());
parent::prepareFakePaymentRequest();

return [
'id' => $response->getBody()->getTransaction()->getId(),
'url' => $response->getBody()->getRedirect()->getUrl(),
'trackingCode' => $response->getBody()->getTransaction()->getTrackingCode(),
];
}

/**
* @depends testNewIdealPaymentShouldBePending
* @param array $input
* @throws ApiException
* @throws BuilderException
* @throws ErrorResponse
* @return null
*/
public function testIdealPaymentWith1EuroShouldBeSuccessful(array $input)
{
$request = RequestBuilder::getTransactionStatus($input['id'], $this->credentials['businessId']);

/** @var PaymentResponse $response */
$response = $this->apiConnection->execute($request);
$this->assertInstanceOf($request->getResponseObjectByStatusCode(200), $response);
$this->assertEquals(PaymentResponse::OK, $response->getResult());
}

/**
* @depends testNewIdealPaymentShouldBePending
* @param array $input
* @throws ApiException
* @throws BuilderException
* @throws ErrorResponse
* @return null
*/
public function testIdealPaymentWith1EuroShouldHaveTransactions(array $input)
{
$request = RequestBuilder::getPayments($this->credentials['businessId'], $input['trackingCode']);

$responses = $this->apiConnection->executeAndReturnArray($request);
$this->assertCount(1, $responses);
/** @var PaymentResponse $response */
$response = $responses[0];
$this->assertInstanceOf($request->getResponseObjectByStatusCode(200), $response);
$this->assertEquals(PaymentResponse::OK, $response->getResult());
$this->assertSame($input['id'], $response->getBody()->getTransaction()->getId());
}

/**
* @depends testNewIdealPaymentShouldBePending
* @param array $input
* @throws ApiException
* @throws BuilderException
* @throws ErrorResponse
* @return null
*/
public function testIdealRefund(array $input)
{
$this->refundRequestBuilder->header()->setBusinessId($this->credentials['businessId']);
$this->refundRequestBuilder->body()->transaction()
->setCurrencyCode('EUR')
->setAmount(1.00)
->setTrackingcode($this->generateTrackingCode());
$requestObject = $this->refundRequestBuilder->build();

$request = RequestBuilder::refundTransaction($requestObject, $input['id']);
/** @var RefundResponseRequest $response */
$response = $this->apiConnection->execute($request);
$this->assertInstanceOf($request->getResponseObjectByStatusCode(200), $response);
$this->assertEquals(PaymentResponse::OK, $response->getResult());
$this->assertEquals('refund', $response->getBody()->getTransaction()->getAction());
}

private function createFakePaymentRequest(): PaymentRequest
{
$this->paymentRequestBuilder->header()->setBusinessId($this->credentials['businessId']);
$this->paymentRequestBuilder->body()->bank()
->setCountryCode('NL')
->setIssuerId(20);
$this->paymentRequestBuilder->body()->transaction()
->setAmount(1.00)
->setPurchaseId('1234')
->setTrackingCode($this->generateTrackingCode())
->setReturnUrl('https://www.example.com')
->setBrandId(3010)
->setDescriptor('DESC')
->setCurrencyCode('EUR');
$this->paymentRequestBuilder->setAction(PaymentRequest::ACTION_PAYMENT);
$requestObject = $this->paymentRequestBuilder->build();
return $requestObject;
->setIssuerId(30);
}
}
26 changes: 26 additions & 0 deletions tests/Test/Api/SofortTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

/**
* @copyright Copyright (c) 2018-2019 Payvision B.V. (https://www.payvision.com/)
* @license see LICENCE.TXT
*/

namespace Payvision\SDK\Test\Api;

class SofortTest extends AbstractPaymentTest
{
const BRAND_ID = 3020;

/**
* @return null
*/
protected function prepareFakePaymentRequest()
{
parent::prepareFakePaymentRequest();

$this->paymentRequestBuilder->body()->bank()
->setCountryCode('NL');
}
}

0 comments on commit 4940364

Please sign in to comment.