Skip to content

Commit 4c978f3

Browse files
authored
Feat/dynamic qr tramma (#24)
1 parent 34a3a1b commit 4c978f3

File tree

3 files changed

+51
-1
lines changed

3 files changed

+51
-1
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
## [3.0.1] - 2024-11-25
10+
11+
### Added
12+
- Instore QR Tramma support.
13+
914
## [3.0.0] - 2024-11-25
1015

1116
### Changed

src/Clients/QrTrammaClient.php

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
/**
4+
* Copyright (C) 1997-2020 Reyesoft <[email protected]>.
5+
*
6+
* This file is part of CryptoQr. CryptoQr can not be copied and/or
7+
* distributed without the express permission of Reyesoft
8+
*/
9+
10+
declare(strict_types=1);
11+
12+
namespace MercadoPagoQr\Clients;
13+
14+
use MercadoPago\Client\Common\RequestOptions;
15+
use MercadoPago\Client\MercadoPagoClient;
16+
use MercadoPago\MercadoPagoConfig;
17+
use MercadoPago\Net\HttpMethod;
18+
use MercadoPago\Net\MPHttpClient;
19+
use MercadoPago\Serialization\Serializer;
20+
use MercadoPagoQr\Resources\Pos;
21+
use MercadoPagoQr\Resources\QrTramma;
22+
23+
final class QrTrammaClient extends MercadoPagoClient
24+
{
25+
private const URL_CREATE = '/instore/orders/qr/seller/collectors/%s/pos/%s/qrs';
26+
27+
public function __construct(?MPHttpClient $MPHttpClient = null)
28+
{
29+
parent::__construct($MPHttpClient ?: MercadoPagoConfig::getHttpClient());
30+
}
31+
32+
/**
33+
* @see https://www.mercadopago.com.ar/developers/en/reference/qr-dynamic/_instore_orders_qr_seller_collectors_user_id_pos_external_pos_id_qrs/post
34+
*/
35+
public function create(int $user_id, string $external_pos_id, array $payload, ?RequestOptions $request_options = null): QrTramma
36+
{
37+
$response = parent::send(sprintf(self::URL_CREATE, $user_id, $external_pos_id), HttpMethod::POST, json_encode($payload), null, $request_options);
38+
$result = Serializer::deserializeFromJson(QrTramma::class, $response->getContent());
39+
$result->setResponse($response);
40+
41+
return $result;
42+
}
43+
}

src/Resources/QrTramma.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111

1212
namespace MercadoPagoQr\Resources;
1313

14-
class QrTramma
14+
use MercadoPago\Net\MPResource;
15+
16+
class QrTramma extends MPResource
1517
{
1618
public ?string $qr_data;
1719
public ?string $in_store_order_id;

0 commit comments

Comments
 (0)