Skip to content

Commit c61d21b

Browse files
authored
Merge pull request #10 from SUMO-Kwiatkowski/SP-X
Updating dependencies and tests
2 parents 8fb2042 + 773d5bf commit c61d21b

29 files changed

+1951
-453
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ jobs:
3030
php_version: ${{ matrix.php-version }}
3131
php_extensions: bcmath gmp xdebug
3232
testsuite: Unit
33-
version: 9
33+
version: 10.5
34+
args: --no-coverage
3435

3536
integration-tests:
3637
runs-on: ubuntu-latest
@@ -52,7 +53,8 @@ jobs:
5253
php_version: ${{ matrix.php-version }}
5354
php_extensions: bcmath gmp xdebug
5455
testsuite: Integration
55-
version: 9
56+
version: 10.5
57+
args: --no-coverage
5658

5759
phpcs:
5860
runs-on: ubuntu-latest

app/Features/Invoice/UpdateInvoice/BaseUpdateInvoiceValidator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313

1414
final class BaseUpdateInvoiceValidator implements UpdateInvoiceValidator
1515
{
16-
public function execute(?array $data, ?BitPayInvoice $bitPayInvoice, array $headers): void
16+
public function execute(?array $payload, ?BitPayInvoice $bitPayInvoice, array $headers): void
1717
{
18-
if (!$data) {
18+
if (!$payload) {
1919
throw new ValidationFailed('Missing data');
2020
}
2121
}

app/Features/Invoice/UpdateInvoice/UpdateInvoiceIpnValidator.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ public function execute(?array $data, ?BitPayInvoice $bitPayInvoice, ?array $hea
4242
throw new ValidationFailed(self::MISSING_BITPAY_MESSAGE);
4343
}
4444

45+
$data = $data['data'];
4546
$bitPayId = $data['id'] ?? null;
47+
4648
if (!$bitPayId || (string)$bitPayId !== (string)$bitPayInvoice->getId()) {
4749
throw new ValidationFailed(self::WRONG_BITPAY_INVOICE_ID_MESSAGE);
4850
}

app/Features/Invoice/UpdateInvoice/UpdateInvoiceUsingBitPayIpn.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function __construct(
4646
$this->bitPayConfiguration = $bitPayConfiguration;
4747
}
4848

49-
public function execute(string $uuid, array $data, array $headers): void
49+
public function execute(string $uuid, array $payload, array $headers): void
5050
{
5151
$invoice = $this->invoiceRepository->findOneByUuid($uuid);
5252
if (!$invoice) {
@@ -62,8 +62,15 @@ public function execute(string $uuid, array $data, array $headers): void
6262
$this->bitPayConfiguration->isSignRequest()
6363
);
6464

65+
$this->updateInvoiceValidator->execute($payload, $bitPayInvoice, $headers);
66+
67+
$event = $payload['event'];
68+
$data = $payload['data'];
69+
70+
$data['uuid'] = $uuid;
71+
$data['event'] = $event['name'];
72+
6573
$updateInvoiceData = $this->bitPayUpdateMapper->execute($data)->toArray();
66-
$this->updateInvoiceValidator->execute($data, $bitPayInvoice, $headers);
6774

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

app/Http/Controllers/Invoice/UpdateInvoiceController.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,9 @@ public function execute(Request $request, string $uuid): Response
3232
$this->logger->info('IPN_RECEIVED', 'Received IPN', $request->request->all());
3333

3434
$payload = json_decode($request->getContent(), true);
35-
$data = $payload['data'];
36-
$event = $payload['event'];
37-
38-
$data['uuid'] = $uuid;
39-
$data['event'] = $event['name'] ?? null;
4035

4136
try {
42-
$this->updateInvoice->execute($uuid, $data, $request->headers->all());
37+
$this->updateInvoice->execute($uuid, $payload, $request->headers->all());
4338
} catch (MissingInvoice $e) {
4439
return response(null, Response::HTTP_NOT_FOUND);
4540
} catch (SignatureVerificationFailed $e) {

application-example.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ bitpay:
99
bgColor: "#100000"
1010
title: "BitPay Demo ts"
1111
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."
12-
logo: "https://via.placeholder.com/300x75?text=LOGO"
12+
logo: "/logo.svg"
1313
posData:
1414
fields:
1515
- type: "select"

docker-compose.yml renamed to compose.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
version: '3.8'
2-
31
services:
42
php-fpm:
53
build:

composer.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,25 @@
99
"license": "MIT",
1010
"require": {
1111
"php": "^8.1",
12-
"bitpay/sdk": "^9.2.0",
12+
"bitpay/sdk": "^9.2",
1313
"guzzlehttp/guzzle": "^7.9",
1414
"laravel/framework": "^10.48",
15-
"laravel/sanctum": "^3.2",
15+
"laravel/sanctum": "^3.3",
1616
"laravel/tinker": "^2.10",
17-
"symfony/mercure": "^0.6.3",
17+
"symfony/mercure": "^0.6.5",
1818
"symfony/serializer": "^6.4",
19-
"symfony/serializer-pack": "*",
19+
"symfony/serializer-pack": "^1.3",
2020
"symfony/yaml": "^6.4"
2121
},
2222
"require-dev": {
2323
"fakerphp/faker": "^1.24",
2424
"laravel/pint": "^1.20",
25-
"laravel/sail": "^1.41",
26-
"mockery/mockery": "^1.4.4",
25+
"laravel/sail": "^1.43",
26+
"mockery/mockery": "^1.6",
2727
"nunomaduro/collision": "^7.12",
2828
"phpunit/phpunit": "^10.5",
2929
"spatie/laravel-ignition": "^2.9",
30-
"squizlabs/php_codesniffer": "^3.12"
30+
"squizlabs/php_codesniffer": "^3.13"
3131
},
3232
"autoload": {
3333
"psr-4": {

0 commit comments

Comments
 (0)