Skip to content

Commit c3d4a19

Browse files
authored
Merge pull request #87 from kschroeder/master
Added Sage Pay support
2 parents 6dd769b + bee1654 commit c3d4a19

File tree

2 files changed

+94
-0
lines changed

2 files changed

+94
-0
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<?php
2+
3+
namespace Magium\Magento\Actions\Checkout\PaymentMethods;
4+
5+
use Facebook\WebDriver\WebDriverSelect;
6+
use Magium\Magento\AbstractMagentoTestCase;
7+
use Magium\Magento\Actions\Checkout\PaymentInformation;
8+
use Magium\Magento\Identities\Customer;
9+
use Magium\WebDriver\WebDriver;
10+
11+
class SagePay implements PaymentMethodInterface
12+
{
13+
14+
const ACTION = 'Checkout\PaymentMethods\SagePay';
15+
16+
protected $webDriver;
17+
protected $testCase;
18+
protected $paymentInformation;
19+
protected $customer;
20+
protected $assertion;
21+
22+
public function __construct(
23+
WebDriver $webDriver,
24+
AbstractMagentoTestCase $testCase,
25+
PaymentInformation $paymentInformation,
26+
Customer $customer,
27+
\Magium\Magento\Assertions\Checkout\PaymentMethods\SagePay $assertion
28+
) {
29+
$this->webDriver = $webDriver;
30+
$this->testCase = $testCase;
31+
$this->paymentInformation = $paymentInformation;
32+
$this->customer = $customer;
33+
$this->assertion = $assertion;
34+
}
35+
36+
public function getId()
37+
{
38+
return 'p_method_sagepaydirectpro';
39+
}
40+
41+
public function pay($requirePayment)
42+
{
43+
if ($requirePayment) {
44+
$this->testCase->assertElementExists($this->getId());
45+
}
46+
47+
if (!$this->webDriver->elementDisplayed('sagepaydirectpro_cc_owner')) {
48+
$this->webDriver->getMouse()->click($this->webDriver->byId($this->getId())->getCoordinates());
49+
}
50+
$this->assertion->assert();
51+
52+
$select = new WebDriverSelect($this->webDriver->byId('sagepaydirectpro_cc_type'));
53+
$select->selectByValue($this->paymentInformation->getType());
54+
55+
$this->webDriver->byId('sagepaydirectpro_cc_number')->clear();
56+
$this->webDriver->byId('sagepaydirectpro_cc_number')->sendKeys($this->paymentInformation->getCreditCardNumber());
57+
58+
$select = new WebDriverSelect($this->webDriver->byId('sagepaydirectpro_expiration'));
59+
$select->selectByValue($this->paymentInformation->getExpiryMonth());
60+
61+
$select = new WebDriverSelect($this->webDriver->byId('sagepaydirectpro_expiration_yr'));
62+
$select->selectByValue($this->paymentInformation->getExpiryYear());
63+
64+
$this->webDriver->byId('sagepaydirectpro_cc_cid')->clear();
65+
$this->webDriver->byId('sagepaydirectpro_cc_cid')->sendKeys($this->paymentInformation->getCvv());
66+
67+
$this->webDriver->byId('sagepaydirectpro_cc_owner')->clear();
68+
$this->webDriver->byId('sagepaydirectpro_cc_owner')->sendKeys(
69+
$this->customer->getBillingFirstName() . ' ' . $this->customer->getBillingLastName()
70+
);
71+
72+
}
73+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace Magium\Magento\Assertions\Checkout\PaymentMethods;
4+
5+
use Magium\Assertions\AbstractAssertion;
6+
7+
class SagePay extends AbstractAssertion
8+
{
9+
10+
public function assert()
11+
{
12+
$this->getTestCase()->assertElementExists('sagepaydirectpro_cc_owner');
13+
$this->getTestCase()->assertElementExists('sagepaydirectpro_cc_type');
14+
$this->getTestCase()->assertEquals('select', strtolower($this->webDriver->byId('sagepaydirectpro_cc_type')->getTagName()));
15+
$this->getTestCase()->assertElementExists('sagepaydirectpro_cc_number');
16+
$this->getTestCase()->assertElementExists('sagepaydirectpro_expiration');
17+
$this->getTestCase()->assertElementExists('sagepaydirectpro_expiration_yr');
18+
$this->getTestCase()->assertElementExists('sagepaydirectpro_cc_cid');
19+
}
20+
21+
}

0 commit comments

Comments
 (0)