Skip to content

Commit

Permalink
Issue #123 / PR #128 Some general refactoring and SHA hash tests added.
Browse files Browse the repository at this point in the history
  • Loading branch information
judgej committed Mar 16, 2019
1 parent 6b97fbd commit 07a1a26
Show file tree
Hide file tree
Showing 18 changed files with 376 additions and 262 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,16 @@ $data = $response->getData();

$data['paymentProfile']['customerProfileId'];
$data['paymentProfile']['customerPaymentProfileId'];
//Now you can use these 2 fields to reference this customer and this payment profile for later use with
//the rest of the CIM driver features as usual.

// Now you can use these 2 fields to reference this customer and this payment profile for later use with
// the rest of the CIM driver features as usual.
```

## DPM and SIM Signatures

DPM and SIM used to sign their requests with the `transactionKey` using the mdh HMAC algorithm.
From early 2019, this algorithm is being removed completely.
Instead, the SHA-512 HMAC algorithm is used to sign the DPM and SIM requsts,
Instead, the SHA-512 HMAC algorithm is used to sign the DPM and SIM requests,
and to validate the received notifications.

To start using the SHA-512 signing, set your `signatureKey` in the gateway:
Expand Down
1 change: 1 addition & 0 deletions src/Message/DPMAuthorizeRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Authorize.Net DPM Authorize Request.
* Takes the data that will be used to create the direct-post form.
*/

class DPMAuthorizeRequest extends SIMAuthorizeRequest
{
protected $action = 'AUTH_ONLY';
Expand Down
2 changes: 1 addition & 1 deletion src/Message/DPMCompleteRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* Authorize.Net DPM Complete Authorize Request
*/
class DPMCompleteRequest extends SIMCompleteAuthorizeRequest
class DPMCompleteRequest extends SIMCompleteRequest
{
public function sendData($data)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Message/DPMCompleteResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
/**
* SIM and DPM both have identical needs when handling the notify request.
*/
class DPMCompleteResponse extends SIMCompleteAuthorizeResponse
class DPMCompleteResponse extends SIMCompleteResponse
{
}
5 changes: 3 additions & 2 deletions src/Message/SIMAbstractRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

namespace Omnipay\AuthorizeNet\Message;

use Omnipay\Common\Message\AbstractRequest;

/**
* Authorize.Net SIM Abstract Request
*/

use Omnipay\Common\Message\AbstractRequest;

abstract class SIMAbstractRequest extends AbstractRequest
{
/**
Expand Down
6 changes: 4 additions & 2 deletions src/Message/SIMAuthorizeRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ public function getData()
}

$data = array_merge($data, $this->getBillingData());
$data['x_fp_hash'] = $this->getHash($data);

$data['x_fp_hash'] = $this->createHash($data);

return $data;
}
Expand All @@ -64,10 +65,11 @@ public function getData()
* modified en-route.
* It uses the TransactionKey, which is a shared secret between the merchant
* and Authorize.Net The sequence and timestamp provide additional salt.
*
* @param $data
* @return string
*/
public function getHash($data)
public function createHash($data)
{
$fingerprint = implode(
'^',
Expand Down
4 changes: 3 additions & 1 deletion src/Message/SIMAuthorizeResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public function getRedirectData()

public function getTransactionId()
{
return isset($this->data[SIMAbstractRequest::TRANSACTION_ID_PARAM]) ? $this->data[SIMAbstractRequest::TRANSACTION_ID_PARAM] : null;
return isset($this->data[SIMAbstractRequest::TRANSACTION_ID_PARAM])
? $this->data[SIMAbstractRequest::TRANSACTION_ID_PARAM]
: null;
}
}
171 changes: 0 additions & 171 deletions src/Message/SIMCompleteAuthorizeRequest.php

This file was deleted.

Loading

0 comments on commit 07a1a26

Please sign in to comment.