Skip to content

Commit 9a227cc

Browse files
committed
Change populateBillTo to defaultBillTo. Set flags at a gateway level
1 parent 6ca8e75 commit 9a227cc

File tree

5 files changed

+67
-8
lines changed

5 files changed

+67
-8
lines changed

src/CIMGateway.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,43 @@
99
*/
1010
class CIMGateway extends AIMGateway
1111
{
12+
public function getDefaultParameters()
13+
{
14+
return array(
15+
'apiLoginId' => '',
16+
'transactionKey' => '',
17+
'testMode' => false,
18+
'developerMode' => false,
19+
'forceCardUpdate' => false,
20+
'defaultBillTo' => [[]]
21+
);
22+
}
23+
1224
public function getName()
1325
{
1426
return 'Authorize.Net CIM';
1527
}
1628

29+
public function setForceCardUpdate($forceCardUpdate)
30+
{
31+
return $this->setParameter('forceCardUpdate', $forceCardUpdate);
32+
}
33+
34+
public function getForceCardUpdate()
35+
{
36+
return $this->getParameter('forceCardUpdate');
37+
}
38+
39+
public function setDefaultBillTo($defaultBillTo)
40+
{
41+
return $this->setParameter('defaultBillTo', $defaultBillTo);
42+
}
43+
44+
public function getDefaultBillTo()
45+
{
46+
return $this->getParameter('defaultBillTo');
47+
}
48+
1749
/**
1850
* Create a new debit or credit card
1951
*
@@ -45,4 +77,9 @@ public function refund(array $parameters = array())
4577
{
4678
return $this->createRequest('\Omnipay\AuthorizeNet\Message\CIMRefundRequest', $parameters);
4779
}
80+
81+
public function void(array $parameters = array())
82+
{
83+
return $this->createRequest('\Omnipay\AuthorizeNet\Message\CIMVoidRequest', $parameters);
84+
}
4885
}

src/Message/CIMAbstractRequest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,14 @@ public function getForceCardUpdate()
6767
return $this->getParameter('forceCardUpdate');
6868
}
6969

70-
public function setPopulateBillTo($populateBillTo)
70+
public function setDefaultBillTo($defaultBillTo)
7171
{
72-
return $this->setParameter('populateBillTo', $populateBillTo);
72+
return $this->setParameter('defaultBillTo', $defaultBillTo);
7373
}
7474

75-
public function getPopulateBillTo()
75+
public function getDefaultBillTo()
7676
{
77-
return $this->getParameter('populateBillTo');
77+
return $this->getParameter('defaultBillTo');
7878
}
7979

8080
/**

src/Message/CIMCreateCardRequest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@ protected function addBillingData(\SimpleXMLElement $data)
8888
$req->zip = $card->getBillingPostcode();
8989
$req->country = $card->getBillingCountry();
9090

91-
$populateBillTo = $this->getParameter('populateBillTo');
92-
if (is_array($populateBillTo)) {
91+
$defaultBillTo = $this->getParameter('defaultBillTo');
92+
if (is_array($defaultBillTo)) {
9393
// A configuration parameter to populate billTo has been specified
94-
foreach ($populateBillTo as $field => $value) {
94+
foreach ($defaultBillTo as $field => $value) {
9595
if (empty($req->{$field}) && !empty($value)) {
9696
// This particular field is empty and default value in populateBillTo has been specified
9797
// so use it

src/Message/CIMVoidRequest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
namespace Omnipay\AuthorizeNet\Message;
4+
5+
/**
6+
* Authorize.Net CIM Void Request
7+
*/
8+
class CIMVoidRequest extends CIMAbstractRequest
9+
{
10+
protected $action = 'voidTransaction';
11+
12+
public function getData()
13+
{
14+
$this->validate('transactionReference');
15+
16+
$data = $this->getBaseData();
17+
$data->transactionRequest->refTransId = $this->getTransactionReference();
18+
$this->addTestModeSetting($data);
19+
20+
return $data;
21+
}
22+
}

tests/Message/CIMCreateCardRequestTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function testGetDataShouldHaveCustomBillTo()
4242
'card' => $card,
4343
'developerMode' => true,
4444
'forceCardUpdate' => true,
45-
'populateBillTo' => [
45+
'defaultBillTo' => [
4646
'address' => '1234 Test Street',
4747
'city' => 'Blacksburg'
4848
]

0 commit comments

Comments
 (0)