Skip to content

Commit

Permalink
Merge branch 'jamieburchell-opayo-urls'
Browse files Browse the repository at this point in the history
  • Loading branch information
judgej committed Nov 4, 2023
2 parents 2925574 + 3db0fbd commit 29b67bd
Show file tree
Hide file tree
Showing 27 changed files with 73 additions and 32 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
composer.lock
composer.phar
phpunit.xml
/.phpunit.result.cache
11 changes: 9 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@
},
"require": {
"php": "^7.3|^8",
"omnipay/common": "~3.0"
"omnipay/common": "~3.0",
"symfony/http-client": "^6.0"
},
"require-dev": {
"omnipay/tests": "^4.1",
"squizlabs/php_codesniffer": "^3",
"phpspec/prophecy-phpunit": "^2.0"
"phpspec/prophecy-phpunit": "^2.0",
"http-interop/http-factory-guzzle": "^1.2"
},
"extra": {
"branch-alias": {
Expand All @@ -51,5 +53,10 @@
"test": "phpunit",
"check-style": "phpcs -p --standard=PSR2 src/",
"fix-style": "phpcbf -p --standard=PSR2 src/"
},
"config": {
"allow-plugins": {
"php-http/discovery": true
}
}
}
9 changes: 4 additions & 5 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,15 @@
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
beStrictAboutTestsThatDoNotTestAnything="false">
<testsuites>
<testsuite name="Omnipay Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<coverage>
<include>
<directory>./src</directory>
</whitelist>
</filter>
</include>
</coverage>
</phpunit>
4 changes: 2 additions & 2 deletions src/Message/AbstractRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ abstract class AbstractRequest extends OmnipayAbstractRequest implements Constan
/**
* @var string Endpoint base URLs.
*/
protected $liveEndpoint = 'https://live.sagepay.com/gateway/service';
protected $testEndpoint = 'https://test.sagepay.com/gateway/service';
protected $liveEndpoint = 'https://live.opayo.eu.elavon.com/gateway/service';
protected $testEndpoint = 'https://sandbox.opayo.eu.elavon.com/gateway/service';

/**
* Convenience method to switch iframe mode on or off.
Expand Down
2 changes: 1 addition & 1 deletion src/Message/Form/AuthorizeRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public function generateCrypt(array $data)

$query = [];
foreach ($data as $name => $value) {
$query[] = $name . '=' . ($disableUtf8Decode ? $value : utf8_decode($value));
$query[] = $name . '=' . ($disableUtf8Decode ? $value : mb_convert_encoding($value, 'ISO-8859-1', 'UTF-8'));
}
$query = implode('&', $query);

Expand Down
4 changes: 2 additions & 2 deletions src/Message/Form/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class Response extends AbstractResponse implements RedirectResponseInterface, Co
/**
* @var string Endpoint base URLs.
*/
protected $liveEndpoint = 'https://live.sagepay.com/gateway/service/vspform-register.vsp';
protected $testEndpoint = 'https://test.sagepay.com/gateway/service/vspform-register.vsp';
protected $liveEndpoint = 'https://live.opayo.eu.elavon.com/gateway/service/vspform-register.vsp';
protected $testEndpoint = 'https://sandbox.opayo.eu.elavon.com/gateway/service/vspform-register.vsp';

/**
* Always a redirect, so not yet successful.
Expand Down
2 changes: 1 addition & 1 deletion src/Message/ServerAuthorizeRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function getData()

// Set the profile only if it is LOW (for iframe use) or NORMAL (for full-page redirects)

$profile = strtoupper($this->getProfile());
$profile = strtoupper($this->getProfile() ?? '');

if ($profile === static::PROFILE_NORMAL || $profile === static::PROFILE_LOW) {
$data['Profile'] = $this->getProfile();
Expand Down
2 changes: 1 addition & 1 deletion src/Message/ServerCompleteAuthorizeRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function getData()
{
// The two signatures to compare.
$signature = $this->getSignature();
$VPSSignature = strtolower($this->httpRequest->request->get('VPSSignature'));
$VPSSignature = strtolower($this->httpRequest->request->get('VPSSignature') ?? '');

if ($VPSSignature !== $signature) {
throw new InvalidResponseException;
Expand Down
4 changes: 2 additions & 2 deletions src/Traits/ServerNotifyTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ trait ServerNotifyTrait
*/
public function getSignature()
{
return strtolower($this->getDataItem('VPSSignature'));
return strtolower($this->getDataItem('VPSSignature') ?? '');
}

/**
Expand Down Expand Up @@ -56,7 +56,7 @@ public function buildSignature()
$this->getTransactionId(),
$this->getStatus(),
$this->getTxAuthNo(),
strtolower($this->getVendor()),
strtolower($this->getVendor() ?? ''),
$this->getAVSCV2(),
($this->getTxType() === Response::TXTYPE_TOKEN ? $this->getToken() : ''),
// As saved in the merchant application.
Expand Down
11 changes: 9 additions & 2 deletions tests/DirectGatewayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@

class DirectGatewayTest extends GatewayTestCase
{
protected $purchaseOptions;
protected $captureOptions;
protected $repeatOptions;
protected $refundOptions;
protected $voidOptions;
protected $abortOptions;

public function setUp(): void
{
parent::setUp();
Expand Down Expand Up @@ -90,7 +97,7 @@ public function testAuthorize3dSecure()
$this->assertTrue($response->isRedirect());
$this->assertNull($response->getTransactionReference());
$this->assertNull($response->getMessage());
$this->assertSame('https://test.sagepay.com/Simulator/3DAuthPage.asp', $response->getRedirectUrl());
$this->assertSame('https://sandbox.opayo.eu.elavon.com/Simulator/3DAuthPage.asp', $response->getRedirectUrl());

$redirectData = $response->getRedirectData();
$this->assertSame('065379457749061954', $redirectData['MD']);
Expand Down Expand Up @@ -132,7 +139,7 @@ public function testPurchase3dSecure()
$this->assertTrue($response->isRedirect());
$this->assertNull($response->getTransactionReference());
$this->assertNull($response->getMessage());
$this->assertSame('https://test.sagepay.com/Simulator/3DAuthPage.asp', $response->getRedirectUrl());
$this->assertSame('https://sandbox.opayo.eu.elavon.com/Simulator/3DAuthPage.asp', $response->getRedirectUrl());

$redirectData = $response->getRedirectData();
$this->assertSame('065379457749061954', $redirectData['MD']);
Expand Down
6 changes: 5 additions & 1 deletion tests/FormGatewayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

class FormGatewayTest extends GatewayTestCase
{
protected $purchaseOptions;
protected $captureOptions;
protected $completePurchaseOptions;

public function setUp(): void
{
parent::setUp();
Expand Down Expand Up @@ -73,7 +77,7 @@ public function testAuthorizeSuccess()

// Live (non-test) endpoint.
$this->assertSame(
'https://live.sagepay.com/gateway/service/vspform-register.vsp',
'https://live.opayo.eu.elavon.com/gateway/service/vspform-register.vsp',
$response->getRedirectUrl()
);

Expand Down
2 changes: 2 additions & 0 deletions tests/Message/DirectCompleteAuthorizeRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

class DirectCompleteAuthorizeRequestTest extends TestCase
{
protected $request;

public function testDirectCompleteAuthorizeRequestSuccess()
{
parent::setUp();
Expand Down
2 changes: 1 addition & 1 deletion tests/Message/ResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function testDirectPurchase3dSecure()
$this->assertTrue($response->isRedirect());
$this->assertNull($response->getTransactionReference());
$this->assertNull($response->getMessage());
$this->assertSame('https://test.sagepay.com/Simulator/3DAuthPage.asp', $response->getRedirectUrl());
$this->assertSame('https://sandbox.opayo.eu.elavon.com/Simulator/3DAuthPage.asp', $response->getRedirectUrl());

$redirectData = $response->getRedirectData();
$this->assertSame('065379457749061954', $redirectData['MD']);
Expand Down
2 changes: 2 additions & 0 deletions tests/Message/ServerAuthorizeRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

class ServerAuthorizeRequestTest extends TestCase
{
protected $request;

const SURCHARGE_XML = '<surcharges><surcharge><paymentType>VISA</paymentType><percentage>2.50</percentage></surcharge></surcharges>';

public function setUp(): void
Expand Down
2 changes: 1 addition & 1 deletion tests/Message/ServerAuthorizeResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function testServerPurchaseSuccess()
$this->assertTrue($response->isRedirect());
$this->assertSame('{"SecurityKey":"IK776BWNHN","VPSTxId":"{1E7D9C70-DBE2-4726-88EA-D369810D801D}","VendorTxCode":"123456"}', $response->getTransactionReference());
$this->assertSame('Server transaction registered successfully.', $response->getMessage());
$this->assertSame('https://test.sagepay.com/Simulator/VSPServerPaymentPage.asp?TransactionID={1E7D9C70-DBE2-4726-88EA-D369810D801D}', $response->getRedirectUrl());
$this->assertSame('https://sandbox.opayo.eu.elavon.com/Simulator/VSPServerPaymentPage.asp?TransactionID={1E7D9C70-DBE2-4726-88EA-D369810D801D}', $response->getRedirectUrl());
$this->assertSame('GET', $response->getRedirectMethod());
$this->assertSame([], $response->getRedirectData());
}
Expand Down
2 changes: 2 additions & 0 deletions tests/Message/ServerNotifyRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

class ServerNotifyRequestTest extends TestCase
{
protected $request;

public function testServerNotifyResponseSuccess()
{
parent::setUp();
Expand Down
3 changes: 2 additions & 1 deletion tests/Message/ServerPurchaseRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@

class ServerPurchaseRequestTest extends TestCase
{

const SURCHARGE_XML = '<surcharges><surcharge><paymentType>VISA</paymentType><percentage>2.50</percentage></surcharge></surcharges>';

protected $request;

public function testInitialize()
{
$this->request = new ServerPurchaseRequest($this->getHttpClient(), $this->getHttpRequest());
Expand Down
2 changes: 1 addition & 1 deletion tests/Message/ServerTokenRegistrationResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function testTokenRegistrationSuccess()
$this->assertTrue($response->isRedirect());
$this->assertSame('{"SecurityKey":"IK776BWNHN","VPSTxId":"{1E7D9C70-DBE2-4726-88EA-D369810D801D}","VendorTxCode":"123456"}', $response->getTransactionReference());
$this->assertSame('Server transaction registered successfully.', $response->getMessage());
$this->assertSame('https://test.sagepay.com/Simulator/VSPServerPaymentPage.asp?TransactionID={1E7D9C70-DBE2-4726-88EA-D369810D801D}', $response->getRedirectUrl());
$this->assertSame('https://sandbox.opayo.eu.elavon.com/Simulator/VSPServerPaymentPage.asp?TransactionID={1E7D9C70-DBE2-4726-88EA-D369810D801D}', $response->getRedirectUrl());
$this->assertSame('GET', $response->getRedirectMethod());
$this->assertSame([], $response->getRedirectData());
}
Expand Down
4 changes: 3 additions & 1 deletion tests/Message/SharedAbortRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

class SharedAbortRequestTest extends TestCase
{
protected $request;

public function setUp(): void
{
parent::setUp();
Expand Down Expand Up @@ -36,6 +38,6 @@ public function testGetEndpoint()
{
$url = $this->request->getEndpoint();

$this->assertSame('https://test.sagepay.com/gateway/service/abort.vsp', $url);
$this->assertSame('https://sandbox.opayo.eu.elavon.com/gateway/service/abort.vsp', $url);
}
}
2 changes: 2 additions & 0 deletions tests/Message/SharedCaptureRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

class SharedCaptureRequestTest extends TestCase
{
protected $request;

public function setUp(): void
{
parent::setUp();
Expand Down
4 changes: 3 additions & 1 deletion tests/Message/SharedRefundRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

class SharedRefundRequestTest extends TestCase
{
protected $request;

public function setUp(): void
{
parent::setUp();
Expand Down Expand Up @@ -36,6 +38,6 @@ public function testGetEndpoint()
{
$url = $this->request->getEndpoint();

$this->assertSame('https://test.sagepay.com/gateway/service/refund.vsp', $url);
$this->assertSame('https://sandbox.opayo.eu.elavon.com/gateway/service/refund.vsp', $url);
}
}
4 changes: 3 additions & 1 deletion tests/Message/SharedVoidRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

class SharedVoidRequestTest extends TestCase
{
protected $request;

public function setUp(): void
{
parent::setUp();
Expand Down Expand Up @@ -39,6 +41,6 @@ public function testGetEndpoint()
{
$url = $this->request->getEndpoint();

$this->assertSame('https://test.sagepay.com/gateway/service/void.vsp', $url);
$this->assertSame('https://sandbox.opayo.eu.elavon.com/gateway/service/void.vsp', $url);
}
}
2 changes: 1 addition & 1 deletion tests/Mock/DirectPurchase3dSecure.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ VPSProtocol=3.00
Status=3DAUTH
3DSecureStatus=OK
MD=065379457749061954
ACSURL=https://test.sagepay.com/Simulator/3DAuthPage.asp
ACSURL=https://sandbox.opayo.eu.elavon.com/Simulator/3DAuthPage.asp
PAReq=BSkaFwYFFTYAGyFbAB0LFRYWBwsBZw0EGwECEX9YRGFWc08pJCVVKgAANS0KADoZCCAMBnIeOxcWRg0LERdOOTQRDFRdVHNYUgwTMBsBCxABJw4DJHE+ERgPCi8MVC0HIAROCAAfBUk4ER89DD0IWDkvMQ1VdFwoUFgwXVYvbHgvMkdBXXNbQGIjdl1ZUEc1XSwqAAgUUicYBDYcB3I2AjYjIzsn
2 changes: 1 addition & 1 deletion tests/Mock/ServerPurchaseSuccess.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ Status=OK
StatusDetail=Server transaction registered successfully.
VPSTxId={1E7D9C70-DBE2-4726-88EA-D369810D801D}
SecurityKey=IK776BWNHN
NextURL=https://test.sagepay.com/Simulator/VSPServerPaymentPage.asp?TransactionID={1E7D9C70-DBE2-4726-88EA-D369810D801D}
NextURL=https://sandbox.opayo.eu.elavon.com/Simulator/VSPServerPaymentPage.asp?TransactionID={1E7D9C70-DBE2-4726-88EA-D369810D801D}
2 changes: 1 addition & 1 deletion tests/Mock/ServerPurchaseWithToken.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ Status=OK
StatusDetail=Server transaction registered successfully.
VPSTxId={1E7D9C70-DBE2-4726-88EA-D369810D801D}
SecurityKey=IK776BWNHN
NextURL=https://test.sagepay.com/Simulator/VSPServerPaymentPage.asp?TransactionID={1E7D9C70-DBE2-4726-88EA-D369810D801D}
NextURL=https://sandbox.opayo.eu.elavon.com/Simulator/VSPServerPaymentPage.asp?TransactionID={1E7D9C70-DBE2-4726-88EA-D369810D801D}
Token={ABCDEFGH-ABCD-ABCD-ABCD-ABCDEFGHIJKL}
2 changes: 1 addition & 1 deletion tests/Mock/ServerTokenRegistrationSuccess.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ Status=OK
StatusDetail=Server transaction registered successfully.
VPSTxId={1E7D9C70-DBE2-4726-88EA-D369810D801D}
SecurityKey=IK776BWNHN
NextURL=https://test.sagepay.com/Simulator/VSPServerPaymentPage.asp?TransactionID={1E7D9C70-DBE2-4726-88EA-D369810D801D}
NextURL=https://sandbox.opayo.eu.elavon.com/Simulator/VSPServerPaymentPage.asp?TransactionID={1E7D9C70-DBE2-4726-88EA-D369810D801D}
12 changes: 10 additions & 2 deletions tests/ServerGatewayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ class ServerGatewayTest extends GatewayTestCase
{
protected $error_3082_text = '3082 : The Description value is too long.';

protected $purchaseOptions;
protected $captureOptions;
protected $completePurchaseOptions;
protected $voidOptions;
protected $abortOptions;
protected $refundOptions;
protected $repeatOptions;

public function setUp(): void
{
parent::setUp();
Expand Down Expand Up @@ -76,7 +84,7 @@ public function testAuthorizeSuccess()
$this->assertTrue($response->isRedirect());
$this->assertSame('{"SecurityKey":"IK776BWNHN","VPSTxId":"{1E7D9C70-DBE2-4726-88EA-D369810D801D}","VendorTxCode":"123"}', $response->getTransactionReference());
$this->assertSame('Server transaction registered successfully.', $response->getMessage());
$this->assertSame('https://test.sagepay.com/Simulator/VSPServerPaymentPage.asp?TransactionID={1E7D9C70-DBE2-4726-88EA-D369810D801D}', $response->getRedirectUrl());
$this->assertSame('https://sandbox.opayo.eu.elavon.com/Simulator/VSPServerPaymentPage.asp?TransactionID={1E7D9C70-DBE2-4726-88EA-D369810D801D}', $response->getRedirectUrl());
}

public function testAuthorizeFailure()
Expand Down Expand Up @@ -145,7 +153,7 @@ public function testPurchaseSuccess()
$this->assertTrue($response->isRedirect());
$this->assertSame('{"SecurityKey":"IK776BWNHN","VPSTxId":"{1E7D9C70-DBE2-4726-88EA-D369810D801D}","VendorTxCode":"123"}', $response->getTransactionReference());
$this->assertSame('Server transaction registered successfully.', $response->getMessage());
$this->assertSame('https://test.sagepay.com/Simulator/VSPServerPaymentPage.asp?TransactionID={1E7D9C70-DBE2-4726-88EA-D369810D801D}', $response->getRedirectUrl());
$this->assertSame('https://sandbox.opayo.eu.elavon.com/Simulator/VSPServerPaymentPage.asp?TransactionID={1E7D9C70-DBE2-4726-88EA-D369810D801D}', $response->getRedirectUrl());
}

public function testPurchaseFailure()
Expand Down

0 comments on commit 29b67bd

Please sign in to comment.