Skip to content

Commit

Permalink
Merge pull request #5 from thepeerstack/support-for-direct-debit
Browse files Browse the repository at this point in the history
update methods to match documentation
  • Loading branch information
ichtrojan authored Dec 9, 2021
2 parents 495a531 + 9ed503b commit d5b5597
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ $thepeer->chargeLink("lost-in-the-world", 5000, "Benz");
* processSendReceipt
- `accepts`:
- receipt_id (string)
- insufficient_funds (bool)
- event (string)
- `returns`: object

* indexUser
Expand Down Expand Up @@ -72,7 +72,7 @@ $thepeer->chargeLink("lost-in-the-world", 5000, "Benz");
* authorizaDirectCharge
- `accepts`:
- reference (string)
- insufficient_funds (bool)
- event (string)
- `returns`: object

## Extra
Expand Down
14 changes: 5 additions & 9 deletions src/Thepeer.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,7 @@ public function validateSignature(Request $payload)

$calculatedSignature = hash_hmac('sha1', json_encode($payload->all()), $this->secretKey);

if ($headerSignature === $calculatedSignature) {
return true;
}

return false;
return $headerSignature === $calculatedSignature;
}

public function getSendReceipt(string $receipt)
Expand All @@ -69,12 +65,12 @@ public function getSendReceipt(string $receipt)
}
}

public function processSendReceipt(string $receipt, bool $insufficient_funds)
public function processSendReceipt(string $receipt, string $event)
{
try {
$request = $this->client->post("/send/{$receipt}", [
"body" => json_encode([
'insufficient_funds' => $insufficient_funds,
'event' => $event,
])
]);

Expand Down Expand Up @@ -166,12 +162,12 @@ public function chargeLink(string $link, int $amount, string $remark)
}
}

public function authorizeDirectCharge(string $reference, bool $insufficient_funds)
public function authorizeDirectCharge(string $reference, string $event)
{
try {
$request = $this->client->post("/debit/{$reference}", [
"body" => json_encode([
'insufficient_funds' => $insufficient_funds,
'event' => $event,
])
]);

Expand Down

0 comments on commit d5b5597

Please sign in to comment.