-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
408 additions
and
440 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright (C) 1997-2020 Reyesoft <[email protected]>. | ||
* | ||
* This file is part of CryptoQr. CryptoQr can not be copied and/or | ||
* distributed without the express permission of Reyesoft | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MercadoPagoQr\Clients; | ||
|
||
use MercadoPago\Client\Common\RequestOptions; | ||
use MercadoPago\Client\MercadoPagoClient; | ||
use MercadoPago\MercadoPagoConfig; | ||
use MercadoPago\Net\HttpMethod; | ||
use MercadoPago\Net\MPHttpClient; | ||
use MercadoPagoQr\Resources\Pos; | ||
|
||
final class InstoreOrderV2 extends MercadoPagoClient | ||
{ | ||
private const URL_CREATE = '/instore/qr/seller/collectors/%s/stores/%s/pos/%s/orders'; | ||
|
||
public function __construct(?MPHttpClient $MPHttpClient = null) | ||
{ | ||
parent::__construct($MPHttpClient ?: MercadoPagoConfig::getHttpClient()); | ||
} | ||
|
||
/** | ||
* @see https://www.mercadopago.com.ar/developers/en/reference/instore_orders_v2/_instore_qr_seller_collectors_user_id_stores_external_store_id_pos_external_pos_id_orders/put | ||
* | ||
* @throws \TypeError this entrypoint return empty response, and is not supported by MercadoPago DX PHP | ||
*/ | ||
public function create(int $user_id, string $external_store_id, string $external_pos_id, array $payload, ?RequestOptions $request_options = null): bool | ||
{ | ||
// no response | ||
$response = parent::send(sprintf(self::URL_CREATE, $user_id, $external_store_id, $external_pos_id), HttpMethod::PUT, json_encode($payload), null, $request_options); | ||
|
||
return $response->getStatusCode() > 200 && $response->getStatusCode() < 300; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright (C) 1997-2020 Reyesoft <[email protected]>. | ||
* | ||
* This file is part of CryptoQr. CryptoQr can not be copied and/or | ||
* distributed without the express permission of Reyesoft | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MercadoPagoQr\Clients; | ||
|
||
use MercadoPago\Client\Common\RequestOptions; | ||
use MercadoPago\Client\MercadoPagoClient; | ||
use MercadoPago\MercadoPagoConfig; | ||
use MercadoPago\Net\HttpMethod; | ||
use MercadoPago\Net\MPHttpClient; | ||
use MercadoPago\Serialization\Serializer; | ||
use MercadoPagoQr\Resources\Pos; | ||
use MercadoPagoQr\Resources\QrTramma; | ||
|
||
final class InstoreQrTramma extends MercadoPagoClient | ||
{ | ||
private const URL_CREATE = '/instore/orders/qr/seller/collectors/%s/pos/%s/qrs'; | ||
|
||
public function __construct(?MPHttpClient $MPHttpClient = null) | ||
{ | ||
parent::__construct($MPHttpClient ?: MercadoPagoConfig::getHttpClient()); | ||
} | ||
|
||
/** | ||
* @see https://www.mercadopago.com.ar/developers/en/reference/qr-dynamic/_instore_orders_qr_seller_collectors_user_id_pos_external_pos_id_qrs/post | ||
*/ | ||
public function create(int $user_id, string $external_pos_id, array $payload, ?RequestOptions $request_options = null): QrTramma | ||
{ | ||
$response = parent::send(sprintf(self::URL_CREATE, $user_id, $external_pos_id), HttpMethod::POST, json_encode($payload), null, $request_options); | ||
$result = Serializer::deserializeFromJson(QrTramma::class, $response->getContent()); | ||
$result->setResponse($response); | ||
|
||
return $result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright (C) 1997-2020 Reyesoft <[email protected]>. | ||
* | ||
* This file is part of CryptoQr. CryptoQr can not be copied and/or | ||
* distributed without the express permission of Reyesoft | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MercadoPagoQr\Clients; | ||
|
||
use MercadoPago\Client\Common\RequestOptions; | ||
use MercadoPago\Client\MercadoPagoClient; | ||
use MercadoPago\Exceptions\MPApiException; | ||
use MercadoPago\MercadoPagoConfig; | ||
use MercadoPago\Net\HttpMethod; | ||
use MercadoPago\Net\MPHttpClient; | ||
use MercadoPago\Serialization\Serializer; | ||
use MercadoPagoQr\Resources\Pos; | ||
|
||
final class PosClient extends MercadoPagoClient | ||
{ | ||
private const URL = '/pos'; | ||
|
||
public function __construct(?MPHttpClient $MPHttpClient = null) | ||
{ | ||
parent::__construct($MPHttpClient ?: MercadoPagoConfig::getHttpClient()); | ||
} | ||
|
||
/** | ||
* Method responsible for creating card token. | ||
* | ||
* @param array $request card token data | ||
* | ||
* @throws MPApiException if the request fails | ||
* @throws \Exception if the request fails | ||
* | ||
* @return Pos card token created | ||
*/ | ||
public function create(array $request, ?RequestOptions $request_options = null): Pos | ||
{ | ||
$response = parent::send(self::URL, HttpMethod::POST, json_encode($request), null, $request_options); | ||
$result = Serializer::deserializeFromJson(Pos::class, $response->getContent()); | ||
$result->setResponse($response); | ||
|
||
// @phpstan-ignore-next-line | ||
return $result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright (C) 1997-2020 Reyesoft <[email protected]>. | ||
* | ||
* This file is part of CryptoQr. CryptoQr can not be copied and/or | ||
* distributed without the express permission of Reyesoft | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MercadoPagoQr\Clients; | ||
|
||
use MercadoPago\Client\Common\RequestOptions; | ||
use MercadoPago\Client\MercadoPagoClient; | ||
use MercadoPago\MercadoPagoConfig; | ||
use MercadoPago\Net\HttpMethod; | ||
use MercadoPago\Net\MPHttpClient; | ||
use MercadoPago\Serialization\Serializer; | ||
use MercadoPagoQr\Resources\Store; | ||
|
||
final class StoreClient extends MercadoPagoClient | ||
{ | ||
private const URL_CREATE = '/users/%s/stores'; | ||
|
||
public function __construct(?MPHttpClient $MPHttpClient = null) | ||
{ | ||
parent::__construct($MPHttpClient ?: MercadoPagoConfig::getHttpClient()); | ||
} | ||
|
||
/** | ||
* @see https://www.mercadopago.com.ar/developers/en/reference/stores/_users_user_id_stores/post | ||
*/ | ||
public function create(int $user_id, array $payload, ?RequestOptions $request_options = null): Store | ||
{ | ||
$response = parent::send(sprintf(self::URL_CREATE, $user_id), HttpMethod::POST, json_encode($payload), null, $request_options); | ||
$result = Serializer::deserializeFromJson(Store::class, $response->getContent()); | ||
$result->setResponse($response); | ||
|
||
return $result; | ||
} | ||
} |
Oops, something went wrong.