Skip to content

Updating dependencies and tests #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ jobs:
php_version: ${{ matrix.php-version }}
php_extensions: bcmath gmp xdebug
testsuite: Unit
version: 9
version: 10.5
args: --no-coverage

integration-tests:
runs-on: ubuntu-latest
Expand All @@ -52,7 +53,8 @@ jobs:
php_version: ${{ matrix.php-version }}
php_extensions: bcmath gmp xdebug
testsuite: Integration
version: 9
version: 10.5
args: --no-coverage

phpcs:
runs-on: ubuntu-latest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

final class BaseUpdateInvoiceValidator implements UpdateInvoiceValidator
{
public function execute(?array $data, ?BitPayInvoice $bitPayInvoice, array $headers): void
public function execute(?array $payload, ?BitPayInvoice $bitPayInvoice, array $headers): void
{
if (!$data) {
if (!$payload) {
throw new ValidationFailed('Missing data');
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ public function execute(?array $data, ?BitPayInvoice $bitPayInvoice, ?array $hea
throw new ValidationFailed(self::MISSING_BITPAY_MESSAGE);
}

$data = $data['data'];
$bitPayId = $data['id'] ?? null;

if (!$bitPayId || (string)$bitPayId !== (string)$bitPayInvoice->getId()) {
throw new ValidationFailed(self::WRONG_BITPAY_INVOICE_ID_MESSAGE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function __construct(
$this->bitPayConfiguration = $bitPayConfiguration;
}

public function execute(string $uuid, array $data, array $headers): void
public function execute(string $uuid, array $payload, array $headers): void
{
$invoice = $this->invoiceRepository->findOneByUuid($uuid);
if (!$invoice) {
Expand All @@ -62,8 +62,15 @@ public function execute(string $uuid, array $data, array $headers): void
$this->bitPayConfiguration->isSignRequest()
);

$this->updateInvoiceValidator->execute($payload, $bitPayInvoice, $headers);

$event = $payload['event'];
$data = $payload['data'];

$data['uuid'] = $uuid;
$data['event'] = $event['name'];

$updateInvoiceData = $this->bitPayUpdateMapper->execute($data)->toArray();
$this->updateInvoiceValidator->execute($data, $bitPayInvoice, $headers);

$this->updateInvoice($invoice, $updateInvoiceData);

Expand Down
7 changes: 1 addition & 6 deletions app/Http/Controllers/Invoice/UpdateInvoiceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,9 @@ public function execute(Request $request, string $uuid): Response
$this->logger->info('IPN_RECEIVED', 'Received IPN', $request->request->all());

$payload = json_decode($request->getContent(), true);
$data = $payload['data'];
$event = $payload['event'];

$data['uuid'] = $uuid;
$data['event'] = $event['name'] ?? null;

try {
$this->updateInvoice->execute($uuid, $data, $request->headers->all());
$this->updateInvoice->execute($uuid, $payload, $request->headers->all());
} catch (MissingInvoice $e) {
return response(null, Response::HTTP_NOT_FOUND);
} catch (SignatureVerificationFailed $e) {
Expand Down
2 changes: 1 addition & 1 deletion application-example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ bitpay:
bgColor: "#100000"
title: "BitPay Demo ts"
body: "Mattis amet hendrerit dolor, quisque lorem pharetra. Pellentesque lacus nisi urna, arcu sociis eu. Orci vel lectus nisl eget eget ut consectetur. Sit justo viverra non adipisicing elit distinctio."
logo: "https://via.placeholder.com/300x75?text=LOGO"
logo: "/logo.svg"
posData:
fields:
- type: "select"
Expand Down
2 changes: 0 additions & 2 deletions docker-compose.yml → compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3.8'

services:
php-fpm:
build:
Expand Down
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@
"license": "MIT",
"require": {
"php": "^8.1",
"bitpay/sdk": "^9.2.0",
"bitpay/sdk": "^9.2",
"guzzlehttp/guzzle": "^7.9",
"laravel/framework": "^10.48",
"laravel/sanctum": "^3.2",
"laravel/sanctum": "^3.3",
"laravel/tinker": "^2.10",
"symfony/mercure": "^0.6.3",
"symfony/mercure": "^0.6.5",
"symfony/serializer": "^6.4",
"symfony/serializer-pack": "*",
"symfony/serializer-pack": "^1.3",
"symfony/yaml": "^6.4"
},
"require-dev": {
"fakerphp/faker": "^1.24",
"laravel/pint": "^1.20",
"laravel/sail": "^1.41",
"mockery/mockery": "^1.4.4",
"laravel/sail": "^1.43",
"mockery/mockery": "^1.6",
"nunomaduro/collision": "^7.12",
"phpunit/phpunit": "^10.5",
"spatie/laravel-ignition": "^2.9",
"squizlabs/php_codesniffer": "^3.12"
"squizlabs/php_codesniffer": "^3.13"
},
"autoload": {
"psr-4": {
Expand Down
Loading