Skip to content

Commit

Permalink
Use helpers 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bajb committed Jun 15, 2015
1 parent 5aa839c commit f506f8a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Fortifi Webhooks",
"homepage": "http://fortifi.co/",
"require": {
"packaged/helpers": "~0.11"
"packaged/helpers": "~1.0"
},
"require-dev": {
"phpunit/phpunit": "~4.5"
Expand Down
16 changes: 9 additions & 7 deletions src/Payloads/FortifiWebhookPayload.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php
namespace Fortifi\Webhooks\Payloads;

use Packaged\Helpers\Objects;

abstract class FortifiWebhookPayload implements \JsonSerializable
{
private $_event;
Expand Down Expand Up @@ -31,13 +33,13 @@ public function jsonSerialize()
'sig' => $this->_signature,
'uuid' => $this->_payloadId,
'rqid' => $this->_requestId,
'data' => get_public_properties($this)
'data' => Objects::propertyValues($this)
];
}

public function prepareForTransport($secret, $payloadId, $requestId)
{
$data = json_encode(get_public_properties($this));
$data = json_encode(Objects::propertyValues($this));
$this->_dataHash = md5($data);
$this->_signature = md5($secret . $this->_dataHash);
$this->_payloadId = $payloadId;
Expand All @@ -54,13 +56,13 @@ public function prepareForTransport($secret, $payloadId, $requestId)
public static function hydrateFromJson($json)
{
$rawPayload = json_decode($json);
$payload = new static(idp($rawPayload, 'event'));
$payload = new static(Objects::property($rawPayload, 'event'));

$payload->_signature = idp($rawPayload, 'sig');
$payload->_payloadId = idp($rawPayload, 'uuid');
$payload->_requestId = idp($rawPayload, 'rqid');
$payload->_signature = Objects::property($rawPayload, 'sig');
$payload->_payloadId = Objects::property($rawPayload, 'uuid');
$payload->_requestId = Objects::property($rawPayload, 'rqid');

$data = idp($rawPayload, 'data', new \stdClass());
$data = Objects::property($rawPayload, 'data', new \stdClass());
$payload->_dataHash = md5(json_encode($rawPayload->data));
foreach($payload as $key => $value)
{
Expand Down

0 comments on commit f506f8a

Please sign in to comment.