Skip to content

Commit 8b10a49

Browse files
committed
Merge pull request #4 from formapro-forks/fixes
Require credit card details, use query to get data for fingerprint.
2 parents 3337a7a + ea5dcb4 commit 8b10a49

File tree

5 files changed

+32
-5
lines changed

5 files changed

+32
-5
lines changed

src/Message/DirectPostAuthorizeRequest.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class DirectPostAuthorizeRequest extends DirectPostAbstractRequest
1111

1212
public function getData()
1313
{
14-
$this->validate('amount', 'returnUrl');
14+
$this->validate('amount', 'returnUrl', 'card');
1515

1616
$data = array();
1717
$data['EPS_MERCHANT'] = $this->getMerchantId();
@@ -26,6 +26,8 @@ public function getData()
2626
$data['EPS_REDIRECT'] = 'TRUE';
2727
$data['EPS_CURRENCY'] = $this->getCurrency();
2828

29+
$data = array_replace($data, $this->getCardData());
30+
2931
return $data;
3032
}
3133

@@ -50,4 +52,17 @@ public function sendData($data)
5052
{
5153
return $this->response = new DirectPostAuthorizeResponse($this, $data, $this->getEndpoint());
5254
}
55+
56+
protected function getCardData()
57+
{
58+
$this->getCard()->validate();
59+
60+
$data = array();
61+
$data['EPS_CARDNUMBER'] = $this->getCard()->getNumber();
62+
$data['EPS_EXPIRYMONTH'] = $this->getCard()->getExpiryMonth();
63+
$data['EPS_EXPIRYYEAR'] = $this->getCard()->getExpiryYear();
64+
$data['EPS_CCV'] = $this->getCard()->getCvv();
65+
66+
return $data;
67+
}
5368
}

src/Message/DirectPostCompletePurchaseRequest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ class DirectPostCompletePurchaseRequest extends DirectPostAbstractRequest
1111
{
1212
public function getData()
1313
{
14-
$data = $this->httpRequest->request->all();
14+
$data = $this->httpRequest->query->all();
1515

16-
if ($this->generateResponseFingerprint($data) !== $this->httpRequest->request->get('fingerprint')) {
16+
if ($this->generateResponseFingerprint($data) !== $this->httpRequest->query->get('fingerprint')) {
1717
throw new InvalidRequestException('Invalid fingerprint');
1818
}
1919

tests/Message/DirectPostAuthorizeRequestTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ public function setUp()
1616
'transactionPassword' => 'bar',
1717
'amount' => '12.00',
1818
'returnUrl' => 'https://www.example.com/return',
19+
'card' => array(
20+
'number' => '4444333322221111',
21+
'expiryMonth' => '6',
22+
'expiryYear' => '2020',
23+
'cvv' => '123',
24+
),
1925
)
2026
);
2127
}

tests/Message/DirectPostCompletePurchaseRequestTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function testSuccess()
3535
'transactionPassword' => 'abc123',
3636
));
3737

38-
$this->getHttpRequest()->request->replace(array(
38+
$this->getHttpRequest()->query->replace(array(
3939
'timestamp' => '20130602112954',
4040
'callback_status_code' => '',
4141
'fingerprint' => 'd9b40fc6f841f41ef3475220fe6316406a5256ce',
@@ -68,7 +68,7 @@ public function testFailure()
6868
'transactionPassword' => 'abc123',
6969
));
7070

71-
$this->getHttpRequest()->request->replace(array(
71+
$this->getHttpRequest()->query->replace(array(
7272
'timestamp' => '20130602102927',
7373
'callback_status_code' => '',
7474
'fingerprint' => '0516a31bf96ad89c354266afb9bd4be43aaf853f',

tests/Message/DirectPostPurchaseRequestTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ public function setUp()
1616
'transactionPassword' => 'bar',
1717
'amount' => '12.00',
1818
'returnUrl' => 'https://www.example.com/return',
19+
'card' => array(
20+
'number' => '4444333322221111',
21+
'expiryMonth' => '6',
22+
'expiryYear' => '2020',
23+
'cvv' => '123',
24+
),
1925
)
2026
);
2127
}

0 commit comments

Comments
 (0)