Skip to content
Draft
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
21 changes: 21 additions & 0 deletions src/MercadoPago/Client/Order/OrderClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,19 @@
use MercadoPago\Client\Common\RequestOptions;
use MercadoPago\Client\MercadoPagoClient;
use MercadoPago\Resources\Order;
use MercadoPago\Resources\OrderSearch;
use MercadoPago\MercadoPagoConfig;
use MercadoPago\Net\HttpMethod;
use MercadoPago\Net\MPHttpClient;
use MercadoPago\Net\MPSearchRequest;
use MercadoPago\Serialization\Serializer;

/** Client responsible for performing Order actions. */
final class OrderClient extends MercadoPagoClient
{
private const URL = "/v1/orders";
private const URL_WITH_ID = "/v1/orders/%s";
private const URL_SEARCH = "/v1/orders";
private const URL_CAPTURE = self::URL_WITH_ID . '/capture';
private const URL_CANCEL = self::URL_WITH_ID . '/cancel';
private const URL_PROCESS = self::URL_WITH_ID . '/process';
Expand Down Expand Up @@ -129,4 +132,22 @@ public function refund(string $order_id, ?array $request = null, ?RequestOptions
$result->setResponse($response);
return $result;
}

/**
* Method responsible for searching Orders.
*
* @param \MercadoPago\Net\MPSearchRequest $request search request.
* @param \MercadoPago\Client\Common\RequestOptions request options to be sent.
* @return \MercadoPago\Resources\OrderSearch search results.
* @throws \MercadoPago\Exceptions\MPApiException if the request fails.
* @throws \Exception if the request fails.
*/
public function search(MPSearchRequest $request, ?RequestOptions $request_options = null): OrderSearch
{
$query_params = isset($request) ? $request->getParameters() : null;
$response = parent::send(self::URL_SEARCH, HttpMethod::GET, null, $query_params, $request_options);
$result = Serializer::deserializeFromJson(OrderSearch::class, $response->getContent());
$result->setResponse($response);
return $result;
}
}
3 changes: 3 additions & 0 deletions src/MercadoPago/Resources/Common/Paging.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ class Paging
/** Total. */
public ?int $total;

/** Total pages. */
public ?int $total_pages;

/** Limit. */
public ?int $limit;

Expand Down
4 changes: 4 additions & 0 deletions src/MercadoPago/Resources/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ class Order extends MPResource
/** Taxes. */
public ?array $taxes;

/** Type response. */
public array|object|null $type_response;

private $map = [
"transactions" => "MercadoPago\Resources\Order\Transactions",
"items" => "MercadoPago\Resources\Order\Items",
Expand All @@ -108,6 +111,7 @@ class Order extends MPResource
"shipment" => "MercadoPago\Resources\Order\Shipment",
"discounts" => "MercadoPago\Resources\Order\Discounts",
"taxes" => "MercadoPago\Resources\Order\Taxes",
"type_response" => "MercadoPago\Resources\Order\TypeResponse",
];

/**
Expand Down
22 changes: 22 additions & 0 deletions src/MercadoPago/Resources/Order/Chargeback.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace MercadoPago\Resources\Order;

/** Chargeback class. */
class Chargeback
{
/** Chargeback unique identifier. */
public ?string $id = null;

/** Transaction ID originating the chargeback. */
public ?string $transaction_id = null;

/** Case ID opened with the card operator. */
public ?string $case_id = null;

/** Current chargeback status. */
public ?string $status = null;

/** List of references related to the chargeback. */
public ?array $references = null;
}
31 changes: 31 additions & 0 deletions src/MercadoPago/Resources/Order/Installments.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace MercadoPago\Resources\Order;

use MercadoPago\Serialization\Mapper;

/** Installments class. */
class Installments
{
/** Class mapper. */
use Mapper;

/** Interest-free installment configuration. */
public array|object|null $interest_free = null;

/** Available installment configuration. */
public array|object|null $available = null;

private $map = [
"interest_free" => "MercadoPago\Resources\Order\InstallmentsInterestFree",
"available" => "MercadoPago\Resources\Order\InstallmentsAvailable",
];

/**
* Method responsible for getting map of entities.
*/
public function getMap(): array
{
return $this->map;
}
}
10 changes: 10 additions & 0 deletions src/MercadoPago/Resources/Order/InstallmentsAvailable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace MercadoPago\Resources\Order;

/** InstallmentsAvailable class. */
class InstallmentsAvailable
{
/** Available installment type. */
public ?string $type = null;
}
13 changes: 13 additions & 0 deletions src/MercadoPago/Resources/Order/InstallmentsInterestFree.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace MercadoPago\Resources\Order;

/** InstallmentsInterestFree class. */
class InstallmentsInterestFree
{
/** Interest-free installment type. */
public ?string $type = null;

/** List of available interest-free installment numbers. */
public ?array $values = null;
}
10 changes: 10 additions & 0 deletions src/MercadoPago/Resources/Order/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,22 @@ class Payment
/** Subscription data. */
public array|object|null $subscription_data;

/** Refunded amount. */
public ?string $refunded_amount;

/** Provider. */
public ?string $provider;

/** Discounts. */
public ?array $discounts;

private $map = [
"payment_method" => "MercadoPago\Resources\Order\PaymentMethod",
"attempts" => "MercadoPago\Resources\Order\Attempt",
"automatic_payments" => "MercadoPago\Resources\Order\AutomaticPayments",
"stored_credential" => "MercadoPago\Resources\Order\StoredCredential",
"subscription_data" => "MercadoPago\Resources\Order\SubscriptionData",
"discounts" => "MercadoPago\Resources\Order\PaymentDiscount",
];

/**
Expand Down
10 changes: 10 additions & 0 deletions src/MercadoPago/Resources/Order/PaymentDiscount.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace MercadoPago\Resources\Order;

/** PaymentDiscount class. */
class PaymentDiscount
{
/** Discount type applied to the payment. */
public ?string $type = null;
}
6 changes: 6 additions & 0 deletions src/MercadoPago/Resources/Order/PaymentMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ class PaymentMethod
/** Digitable Line */
public ?string $digitable_line;

/** E2E ID. */
public ?string $e2e_id;

/** Redirect URL. */
public ?string $redirect_url;

/** Transaction security. */
public array|object|null $transaction_security;

Expand Down
29 changes: 29 additions & 0 deletions src/MercadoPago/Resources/Order/PaymentMethodConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@

namespace MercadoPago\Resources\Order;

use MercadoPago\Serialization\Mapper;

/** PaymentMethodConfig class. */
class PaymentMethodConfig
{
/** Class mapper. */
use Mapper;

/** Not allowed ids. */
public ?array $not_allowed_ids;

Expand All @@ -16,9 +21,33 @@ class PaymentMethodConfig
/** Default ID. */
public ?string $default_id;

/** Default type. */
public ?string $default_type;

/** Max installments. */
public ?int $max_installments;

/** Default installments. */
public ?int $default_installments;

/** Min installments. */
public ?int $min_installments;

/** Installments cost. */
public ?string $installments_cost;

/** Installments configuration. */
public array|object|null $installments;

private $map = [
"installments" => "MercadoPago\Resources\Order\Installments",
];

/**
* Method responsible for getting map of entities.
*/
public function getMap(): array
{
return $this->map;
}
}
3 changes: 3 additions & 0 deletions src/MercadoPago/Resources/Order/Refund.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ class Refund
/** Status. */
public ?string $status;

/** E2E ID. */
public ?string $e2e_id;

/** Items. */
public ?array $items;

Expand Down
4 changes: 3 additions & 1 deletion src/MercadoPago/Resources/Order/TransactionSecurity.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ class TransactionSecurity
/** Class mapper. */
use Mapper;

/** Transaction security ID. */
public ?string $id;

/** Validation. */
public ?string $validation;

Expand All @@ -29,4 +32,3 @@ public function getMap(): array
return [];
}
}

4 changes: 4 additions & 0 deletions src/MercadoPago/Resources/Order/Transactions.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@ class Transactions extends MPResource
/** Refunds. */
public ?array $refunds;

/** Chargebacks. */
public ?array $chargebacks;

private $map = [
"payments" => "MercadoPago\Resources\Order\Payment",
"refunds" => "MercadoPago\Resources\Order\Refund",
"chargebacks" => "MercadoPago\Resources\Order\Chargeback",
];

/**
Expand Down
10 changes: 10 additions & 0 deletions src/MercadoPago/Resources/Order/TypeResponse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace MercadoPago\Resources\Order;

/** TypeResponse class. */
class TypeResponse
{
/** QR code data for the order. */
public ?string $qr_data = null;
}
32 changes: 32 additions & 0 deletions src/MercadoPago/Resources/OrderSearch.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace MercadoPago\Resources;

use MercadoPago\Net\MPResource;
use MercadoPago\Serialization\Mapper;

/** OrderSearch class. */
class OrderSearch extends MPResource
{
/** Class mapper. */
use Mapper;

/** Search paging. */
public array|object|null $paging;

/** Search data. */
public array|object|null $data;

private $map = [
"paging" => "MercadoPago\Resources\Common\Paging",
"data" => "MercadoPago\Resources\Order",
];

/**
* Method responsible for getting map of entities.
*/
public function getMap(): array
{
return $this->map;
}
}
2 changes: 1 addition & 1 deletion src/MercadoPago/Resources/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ class Payment extends MPResource
"payment_method" => "MercadoPago\Resources\Payment\PaymentMethod",
"metadata" => "MercadoPago\Resources\Payment\Metadata",
"three_ds_info" => "MercadoPago\Resources\Payment\ThreeDSInfo",
"order"=> "MercadoPago\Resources\Payment\Order",
"order" => "MercadoPago\Resources\Payment\Order",
"expanded" => "MercadoPago\Resources\Payment\Expanded"
];

Expand Down
2 changes: 1 addition & 1 deletion src/MercadoPago/Resources/Payment/Expanded.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ class ExpandedGatewayReference
{
/** Network transaction ID. */
public ?string $network_transaction_id;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ class NetworkTransactionData
{
/** Network transaction ID. */
public ?string $network_transaction_id;
}
}
1 change: 0 additions & 1 deletion src/MercadoPago/Resources/Payment/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
/** Order class. */
class Order
{

/** Order ID. */
public ?int $id;

Expand Down
Loading