Skip to content

Commit 6d8cb89

Browse files
committed
Merge branch 'master' of github.com:thephpleague/omnipay-sagepay into protocol3
Conflicts: src/DirectGateway.php
2 parents 767ba21 + eb7f0d4 commit 6d8cb89

File tree

4 files changed

+39
-0
lines changed

4 files changed

+39
-0
lines changed

src/DirectGateway.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public function getDefaultParameters()
2121
return array(
2222
'vendor' => '',
2323
'testMode' => false,
24+
'referrerId' => '',
2425
);
2526
}
2627

@@ -46,6 +47,15 @@ public function getHttpClient()
4647
}
4748

4849
// Available services.
50+
public function getReferrerId()
51+
{
52+
return $this->getParameter('referrerId');
53+
}
54+
55+
public function setReferrerId($value)
56+
{
57+
return $this->setParameter('referrerId', $value);
58+
}
4959

5060
public function authorize(array $parameters = array())
5161
{

src/Message/AbstractRequest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,19 @@ public function setAccountType($value)
4646
return $this->setParameter('accountType', $value);
4747
}
4848

49+
public function getReferrerId()
50+
{
51+
return $this->getParameter('referrerId');
52+
}
53+
54+
/**
55+
* Set the referrer ID for PAYMENT, DEFERRED and AUTHENTICATE transactions.
56+
*/
57+
public function setReferrerId($value)
58+
{
59+
return $this->setParameter('referrerId', $value);
60+
}
61+
4962
public function getApplyAVSCV2()
5063
{
5164
return $this->getParameter('applyAVSCV2');

src/Message/DirectAuthorizeRequest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ protected function getBaseAuthorizeData()
2727
$data['ApplyAVSCV2'] = $this->getApplyAVSCV2() ?: 0;
2828
$data['Apply3DSecure'] = $this->getApply3DSecure() ?: 0;
2929

30+
if ($this->getReferrerId()) {
31+
$data['ReferrerID'] = $this->getReferrerId();
32+
}
33+
3034
// billing details
3135
$data['BillingFirstnames'] = $card->getBillingFirstName();
3236
$data['BillingSurname'] = $card->getBillingLastName();

tests/Message/DirectAuthorizeRequestTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public function testGetData()
3737
$this->request->setApply3DSecure(3);
3838
$this->request->setDescription('food');
3939
$this->request->setClientIp('127.0.0.1');
40+
$this->request->setReferrerId('3F7A4119-8671-464F-A091-9E59EB47B80C');
4041

4142
$data = $this->request->getData();
4243

@@ -48,6 +49,17 @@ public function testGetData()
4849
$this->assertSame('127.0.0.1', $data['ClientIPAddress']);
4950
$this->assertSame(2, $data['ApplyAVSCV2']);
5051
$this->assertSame(3, $data['Apply3DSecure']);
52+
$this->assertSame('3F7A4119-8671-464F-A091-9E59EB47B80C', $data['ReferrerID']);
53+
}
54+
55+
public function testGetDataNoReferrerId()
56+
{
57+
// Default value is equivalent to this:
58+
$this->request->setReferrerId('');
59+
60+
$data = $this->request->getData();
61+
62+
$this->assertArrayNotHasKey('ReferrerID', $data);
5163
}
5264

5365
public function testGetDataCustomerDetails()

0 commit comments

Comments
 (0)