Skip to content

Commit deeeaf3

Browse files
authored
Merge pull request #23 from RobvH/improve-reference-payment
Use CardReference for reference purchases
2 parents 65f0d0c + 325ff78 commit deeeaf3

File tree

3 files changed

+7
-26
lines changed

3 files changed

+7
-26
lines changed

src/Message/AuthorizeRequest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,10 @@ public function getData()
261261
$data['ORDERID'] = $this->getOrderId();
262262
$data['PONUM'] = $this->getPoNum();
263263

264-
$data['BILLTOEMAIL'] = $this->getCard()->getEmail();
265-
$data['BILLTOPHONENUM'] = $this->getCard()->getBillingPhone();
264+
if ($this->getCard()) {
265+
$data['BILLTOEMAIL'] = $this->getCard()->getEmail();
266+
$data['BILLTOPHONENUM'] = $this->getCard()->getBillingPhone();
267+
}
266268

267269
$items = $this->getItems();
268270
if (!empty($items)) {

src/Message/PurchaseRequest.php

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636
* // $reference_id can be the transaction reference from a previous authorization, credit, capture, sale, voice auth,
3737
* // or void.
3838
* $transaction = $gateway->purchase(array(
39-
* 'amount' => '10.00',
40-
* 'transactionReference' => $reference_id,
39+
* 'amount' => '10.00',
40+
* 'cardReference' => $reference_id,
4141
* ));
4242
*
4343
* // 2. Sale (with card data) example:
@@ -69,25 +69,4 @@
6969
class PurchaseRequest extends AuthorizeRequest
7070
{
7171
protected $action = 'S';
72-
73-
public function getData()
74-
{
75-
if ($this->parameters->get('transactionReference')) {
76-
return $this->getReferenceSaleData();
77-
}
78-
79-
return parent::getData();
80-
}
81-
82-
public function getReferenceSaleData()
83-
{
84-
$this->validate('transactionReference', 'amount');
85-
86-
$data = $this->getBaseData();
87-
$data['AMT'] = $this->getAmount();
88-
$data['ORIGID'] = $this->getTransactionReference();
89-
$data['TENDER'] = 'C';
90-
91-
return $data;
92-
}
9372
}

tests/ProGatewayTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function testReferencePurchaseSuccess()
7575
{
7676
$options = array(
7777
'amount' => '10.00',
78-
'transactionReference' => 'abc123',
78+
'cardReference' => 'abc123',
7979
);
8080

8181
$this->setMockHttpResponse('PurchaseSuccess.txt');

0 commit comments

Comments
 (0)