Skip to content
Open
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
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
],
"require": {
"php": ">=7.2",
"endroid/qr-code": "^3.2",
"endroid/qr-code": "^5.0",
"ext-gd": "*",
"pablorsk/dx-php": "2.2.8"
},
"require-dev": {
"reyesoft/ci": "1.2.0",
"phpunit/phpunit": "^7",
"codedungeon/phpunit-result-printer": "0.19.10"
"reyesoft/ci": "1.4.6",
"phpunit/phpunit": "^9",
"codedungeon/phpunit-result-printer": "0.30.0"
},
"autoload": {
"classmap": [
Expand Down
6 changes: 2 additions & 4 deletions src/MercadoPagoPos.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class MercadoPagoPos

public function __construct(string $pos_external_id = '')
{
$this->qr_code = new QrCode();
$this->qr_code = new QrCode($pos_external_id);
$this->data = new MercadoPagoPosData($pos_external_id);
$this->pos = new Pos();
}
Expand Down Expand Up @@ -87,9 +87,7 @@ public function getQrCode(string $collector_id = null): QrCode
$collector_id = $this->getCollectorIdFromMp();
}

$this->qr_code->setText(
'https://mercadopago.com/s/qr/' . $collector_id . '/' . $this->data->getExternalId()
);
$this->qr_code = new QrCode('https://mercadopago.com/s/qr/' . $collector_id . '/' . $this->data->getExternalId());

return $this->qr_code;
}
Expand Down
10 changes: 8 additions & 2 deletions tests/MercadoPagoQrTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

namespace Tests;

use Endroid\QrCode\Writer\PngWriter;
use MercadoPago\SDK;
use MercadoPagoQr\MercadoPagoPos;
use PHPUnit\Framework\TestCase;
Expand Down Expand Up @@ -93,14 +94,19 @@ public function testCreateQr(): void

$pos = new MercadoPagoPos('MyTestPos');
$filename = __DIR__ . '/image/mercadopago-qr-code.png';
$pos->getQrCode()->writeFile($filename);

$qrCode = $pos->getQrCode();
$writer = new PngWriter();

$result = $writer->write($qrCode);
$result->saveToFile($filename);

$file_content = file_get_contents($filename);
static::assertNotFalse($file_content);

$image = imagecreatefromstring($file_content);

static::assertInternalType('resource', $image);
static::assertIsResource($image);
}

/**
Expand Down