Skip to content

Commit 648726b

Browse files
committed
Backported DPM getHash() to SIM getHash() to support a specified currency.
1 parent 4a391cd commit 648726b

File tree

3 files changed

+25
-24
lines changed

3 files changed

+25
-24
lines changed

src/DPMGateway.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,33 @@ public function getName()
1212
return 'Authorize.Net DPM';
1313
}
1414

15+
/**
16+
* Helper to generate the authorize direct-post form.
17+
*/
1518
public function authorize(array $parameters = array())
1619
{
1720
return $this->createRequest('\Omnipay\AuthorizeNet\Message\DPMAuthorizeRequest', $parameters);
1821
}
1922

23+
/**
24+
* Get, validate, interpret and respond to the Authorize.Net callback.
25+
*/
2026
public function completeAuthorize(array $parameters = array())
2127
{
2228
return $this->createRequest('\Omnipay\AuthorizeNet\Message\DPMCompleteRequest', $parameters);
2329
}
2430

31+
/**
32+
* Helper to generate the purchase direct-post form.
33+
*/
2534
public function purchase(array $parameters = array())
2635
{
2736
return $this->createRequest('\Omnipay\AuthorizeNet\Message\DPMPurchaseRequest', $parameters);
2837
}
2938

39+
/**
40+
* Get, validate, interpret and respond to the Authorize.Net callback.
41+
*/
3042
public function completePurchase(array $parameters = array())
3143
{
3244
return $this->createRequest('\Omnipay\AuthorizeNet\Message\DPMCompleteRequest', $parameters);

src/Message/DPMAuthorizeRequest.php

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,13 @@
55
use Omnipay\AuthorizeNet\Message\SIMAbstractRequest;
66

77
/**
8-
* Authorize.Net DPM Authorize Request
8+
* Authorize.Net DPM Authorize Request.
9+
* Takes the data that will be used to create the direct-post form.
910
*/
1011
class DPMAuthorizeRequest extends SIMAuthorizeRequest
1112
{
1213
protected $action = 'AUTH_ONLY';
1314

14-
public function getHash($data)
15-
{
16-
$fingerprint = implode(
17-
'^',
18-
array(
19-
$this->getApiLoginId(),
20-
$data['x_fp_sequence'],
21-
$data['x_fp_timestamp'],
22-
$data['x_amount']
23-
)
24-
).'^';
25-
26-
// If x_currency_code is specified, then it must follow the final trailing carat.
27-
// CHECKME: this may need to be back-ported to SIMAuthorizeRequest and AIMAuthorizeRequest
28-
// in order to supprot multiple currencies.
29-
30-
if ($this->getCurrency()) {
31-
$fingerprint .= $this->getCurrency();
32-
}
33-
34-
return hash_hmac('md5', $fingerprint, $this->getTransactionKey());
35-
}
36-
3715
public function getData()
3816
{
3917
$data = parent::getData();

src/Message/SIMAuthorizeRequest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ public function getData()
3636
return $data;
3737
}
3838

39+
/**
40+
* This hash is put into the form to confirm the amount has not been
41+
* modified en-route.
42+
* It uses the TransactionKey, which is a shared secret between the merchant
43+
* and Authorize.Net The sequence and timestamp provide additional salt.
44+
*/
3945
public function getHash($data)
4046
{
4147
$fingerprint = implode(
@@ -48,6 +54,11 @@ public function getHash($data)
4854
)
4955
).'^';
5056

57+
// If x_currency_code is specified, then it must follow the final trailing carat.
58+
if ($this->getCurrency()) {
59+
$fingerprint .= $this->getCurrency();
60+
}
61+
5162
return hash_hmac('md5', $fingerprint, $this->getTransactionKey());
5263
}
5364

0 commit comments

Comments
 (0)