diff --git a/README.md b/README.md index 614d2317..dacb297d 100644 --- a/README.md +++ b/README.md @@ -192,125 +192,57 @@ try{ } ``` -## 🌟 Getting started with payment via Checkout Pro +## 🌟 Getting started with Checkout Pro via Orders -### Step 1: Require the libraries +The SDK exposes the bounded Orders API through `MercadoPago\Client\Order\OrderClient` and `MercadoPago\Client\Order\OrderTransactionClient`. Create the order with its transaction data; no separate transaction-creation step is required before processing. -```php -use MercadoPago\MercadoPagoConfig; -use MercadoPago\Client\Preference\PreferenceClient; -use MercadoPago\Exceptions\MPApiException; -``` +### Create an order -### Step 2: Create an authentication function +The snippet uses the `RequestOptions`, `OrderClient`, and `MPApiException` imports and access-token configuration established above. ```php -protected function authenticate() -{ - // Getting the access token from .env file (create your own function) - $mpAccessToken = getVariableFromEnv('mercado_pago_access_token'); - // Set the token the SDK's config - MercadoPagoConfig::setAccessToken($mpAccessToken); - // (Optional) Set the runtime enviroment to LOCAL if you want to test on localhost - // Default value is set to SERVER - MercadoPagoConfig::setRuntimeEnviroment(MercadoPagoConfig::LOCAL); -} -``` - -### Step 3: Create customer's preference before proceeding to Checkout Pro page - -```php -// Function that will return a request object to be sent to Mercado Pago API -function createPreferenceRequest($items, $payer): array -{ - $paymentMethods = [ - "excluded_payment_methods" => [], - "installments" => 12, - "default_installments" => 1 - ]; - - $backUrls = array( - 'success' => route('mercadopago.success'), - 'failure' => route('mercadopago.failed') - ); - - $request = [ - "items" => $items, - "payer" => $payer, - "payment_methods" => $paymentMethods, - "back_urls" => $backUrls, - "statement_descriptor" => "NAME_DISPLAYED_IN_USER_BILLING", - "external_reference" => "1234567890", - "expires" => false, - "auto_return" => 'approved', - ]; - - return $request; -} -``` - -### Step 4: Create the preference on Mercado Pago ([DOCS](https://www.mercadopago.com.br/developers/pt/docs/sdks-library/server-side/php/preferences)) +$order_client = new OrderClient(); +$request = [ + 'type' => 'online', + 'processing_mode' => 'automatic', + 'capture_mode' => 'automatic_async', + 'external_reference' => 'checkout-pro-order-001', + 'total_amount' => '500.00', + 'payer' => [ + 'email' => '', + ], + 'transactions' => [ + 'payments' => [ + [ + 'amount' => '500.00', + 'payment_method' => [ + 'id' => 'master', + 'type' => 'credit_card', + 'token' => '', + 'installments' => 1, + ], + ], + ], + ], +]; -```php -public function createPaymentPreference(): ?Preference -{ - // Fill the data about the product(s) being purchased - $product1 = array( - "id" => "1234567890", - "title" => "Product 1 Title", - "description" => "Product 1 Description", - "currency_id" => "BRL", - "quantity" => 12, - "unit_price" => 9.90 - ); - - $product2 = array( - "id" => "9012345678", - "title" => "Product 2 Title", - "description" => "Product 2 Description", - "currency_id" => "BRL", - "quantity" => 5, - "unit_price" => 19.90 - ); - - // Mount the array of products that will integrate the purchase amount - $items = array($product1, $product2); - - // Retrieve information about the user (use your own function) - $user = getSessionUser(); - - $payer = array( - "name" => $user->name, - "surname" => $user->surname, - "email" => $user->email, - ); - - // Create the request object to be sent to the API when the preference is created - $request = createPreferenceRequest($item, $payer); - - // Instantiate a new Preference Client - $client = new PreferenceClient(); +$options = new RequestOptions(); +$options->setCustomHeaders([ + 'X-Idempotency-Key: ', +]); - try { - // Send the request that will create the new preference for user's checkout flow - $preference = $client->create($request); - - // Useful props you could use from this object is 'init_point' (URL to Checkout Pro) or the 'id' - return $preference; - } catch (MPApiException $error) { - // Here you might return whatever your app needs. - // We are returning null here as an example. - return null; - } +try { + $order = $order_client->create($request, $options); + echo 'Order ID: ' . $order->id; +} catch (MPApiException $e) { + echo 'Status code: ' . $e->getApiResponse()->getStatusCode() . "\n"; + var_dump($e->getApiResponse()->getContent()); } ``` -In case you need to retrieve the preference by ID: +`OrderClient` maps successful order responses to `MercadoPago\Resources\Order` and search responses to `MercadoPago\Resources\OrderSearch`. Nested transaction data is represented by `MercadoPago\Resources\Order\Transactions`, `MercadoPago\Resources\Order\Payment`, and `MercadoPago\Resources\Order\PaymentMethod`. -```php - $client = new PreferenceClient(); - $client->get("123456789"); -``` +The supported order routes are `/v1/orders`, `/v1/orders/{id}`, `/v1/orders/{order_id}/cancel`, `/v1/orders/{order_id}/process`, `/v1/orders/{order_id}/capture`, and `/v1/orders/{order_id}/refund`. `OrderTransactionClient` operates on `/v1/orders/{order_id}/transactions` and `/v1/orders/{order_id}/transactions/{transaction_id}`. Supply `X-Idempotency-Key` through `RequestOptions` only for operations that declare it: order create, cancel, process, capture, and refund, plus transaction create and update. The transaction delete operation does not declare this header. A full refund can omit the request body, while a partial refund provides the amount in the request body. ## 📚 Documentation diff --git a/examples/Order/CancelOrderById.php b/examples/Order/CancelOrderById.php index 0c62b466..b042e1ef 100644 --- a/examples/Order/CancelOrderById.php +++ b/examples/Order/CancelOrderById.php @@ -24,6 +24,7 @@ $request_options = new RequestOptions(); $request_options->setCustomHeaders(["X-Idempotency-Key: "]); + // POST /v1/orders/{order_id}/cancel $order = $client->cancel($order_id, $request_options); echo "Order ID: " . $order->id . "\n"; echo "Status: " . $order->status . "\n"; diff --git a/examples/Order/Capture.php b/examples/Order/Capture.php index faf567d0..93eccd19 100644 --- a/examples/Order/Capture.php +++ b/examples/Order/Capture.php @@ -58,7 +58,7 @@ $request_options_capture = new RequestOptions(); $request_options_capture->setCustomHeaders(["X-Idempotency-Key: "]); - // Step 7: Capture the order + // Step 7: Capture the order with POST /v1/orders/{order_id}/capture $order = $client->capture($order->id, $request_options_capture); echo "\nOrder status after capture: " . $order->status; diff --git a/examples/Order/Create.php b/examples/Order/Create.php index 6d38b03c..73b81153 100644 --- a/examples/Order/Create.php +++ b/examples/Order/Create.php @@ -78,7 +78,7 @@ $request_options = new RequestOptions(); $request_options->setCustomHeaders(["X-Idempotency-Key: "]); - // Step 6: Make the request + // Step 6: Create the order with POST /v1/orders $order = $client->create($request, $request_options); echo "Order ID:" . $order->id; diff --git a/examples/Order/CreateCheckoutPRO.php b/examples/Order/CreateCheckoutPRO.php index 1d4ad012..547e0c4c 100644 --- a/examples/Order/CreateCheckoutPRO.php +++ b/examples/Order/CreateCheckoutPRO.php @@ -20,8 +20,7 @@ $client = new OrderClient(); try { - // Step 4: Build the Checkout PRO request - // processing_mode "manual" triggers the Checkout PRO flow and returns a checkout_url + // Step 4: Build the manual Orders request used by Checkout Pro $request = [ "type" => "online", "processing_mode" => "manual", diff --git a/examples/Order/CreateOrderPSE.php b/examples/Order/CreateOrderPSE.php index e81db164..0e0e2624 100644 --- a/examples/Order/CreateOrderPSE.php +++ b/examples/Order/CreateOrderPSE.php @@ -93,7 +93,7 @@ $request_options = new RequestOptions(); $request_options->setCustomHeaders(["X-Idempotency-Key: "]); - // Step 6: Make the request + // Step 6: Create the PSE order with POST /v1/orders $order = $client->create($request, $request_options); print_r($order); diff --git a/examples/Order/CreateOrderWith3DS.php b/examples/Order/CreateOrderWith3DS.php index 04419718..c48a11ef 100644 --- a/examples/Order/CreateOrderWith3DS.php +++ b/examples/Order/CreateOrderWith3DS.php @@ -62,7 +62,7 @@ $request_options = new RequestOptions(); $request_options->setCustomHeaders(["X-Idempotency-Key: "]); - // Step 6: Make the request + // Step 6: Create the 3DS order with POST /v1/orders $order = $client->create($request, $request_options); // Step 7: Check if 3DS Challenge is required diff --git a/examples/Order/CreateOrderWithAutomaticPayments.php b/examples/Order/CreateOrderWithAutomaticPayments.php index 74576dbe..421214bd 100644 --- a/examples/Order/CreateOrderWithAutomaticPayments.php +++ b/examples/Order/CreateOrderWithAutomaticPayments.php @@ -20,8 +20,9 @@ * 2. Recurring charge — subsequent MIT charge without CVV, referencing step 1. * * Prerequisites: - * - A customer created via POST /v1/customers → CUSTOMER_ID - * - A payment profile created via POST /v1/customers/{id}/payment-profiles → PAYMENT_PROFILE_ID + * - An existing customer ID and automatic-payment profile ID. + * + * Both charges in this example are created only through POST /v1/orders. * * @see https://www.mercadopago.com/developers/en/docs/automatic-payments-orders/overview */ diff --git a/examples/Order/CreateOrderWithIndustryFields.php b/examples/Order/CreateOrderWithIndustryFields.php index 5f61eb64..2c1a88d0 100644 --- a/examples/Order/CreateOrderWithIndustryFields.php +++ b/examples/Order/CreateOrderWithIndustryFields.php @@ -28,7 +28,6 @@ "external_reference" => "ext_ref_1234", "capture_mode" => "automatic_async", "processing_mode" => "automatic", - "marketplace" => "NONE", "total_amount" => "1000.00", "transactions" => [ "payments" => [ diff --git a/examples/Order/GetOrderById.php b/examples/Order/GetOrderById.php index fba88efc..ee3565db 100644 --- a/examples/Order/GetOrderById.php +++ b/examples/Order/GetOrderById.php @@ -5,7 +5,6 @@ // Step 1: Require the library from your Composer vendor folder require_once '../../vendor/autoload.php'; -use MercadoPago\Client\Common\RequestOptions; use MercadoPago\Client\Order\OrderClient; use MercadoPago\Exceptions\MPApiException; use MercadoPago\MercadoPagoConfig; diff --git a/examples/Order/ProcessOrder.php b/examples/Order/ProcessOrder.php index d6507f5c..8262d4ba 100644 --- a/examples/Order/ProcessOrder.php +++ b/examples/Order/ProcessOrder.php @@ -21,6 +21,7 @@ $order_id = ""; try { + // POST /v1/orders/{order_id}/process $request_options = new RequestOptions(); $request_options->setCustomHeaders(["X-Idempotency-Key: "]); diff --git a/examples/Order/RefundPartial.php b/examples/Order/RefundPartial.php index 3113788d..2bd5e510 100644 --- a/examples/Order/RefundPartial.php +++ b/examples/Order/RefundPartial.php @@ -51,7 +51,7 @@ // Step 6: Create the Order $order = $order_client->create($create_order_request, $request_options); - // Step 7: Create the request to refund Order partially + // Step 7: Create the body for POST /v1/orders/{order_id}/refund $refund_request = [ "transactions" => [ [ diff --git a/examples/Order/RefundTotal.php b/examples/Order/RefundTotal.php index a407e1da..dd004692 100644 --- a/examples/Order/RefundTotal.php +++ b/examples/Order/RefundTotal.php @@ -54,7 +54,8 @@ // Step 7: Set a new X-Idempotency-Key $request_options->setCustomHeaders(["X-Idempotency-Key: "]); - // Step 8: Refund the Order + // Step 8: Refund the full Order through POST /v1/orders/{order_id}/refund. + // A null body requests a total refund. sleep(3); $refunded_order = $order_client->refund($order->id, null, $request_options); diff --git a/examples/Order/Transaction/Create.php b/examples/Order/Transaction/Create.php index 74e490ff..6bbbb9dd 100644 --- a/examples/Order/Transaction/Create.php +++ b/examples/Order/Transaction/Create.php @@ -20,7 +20,7 @@ $client = new OrderTransactionClient(); try { - // Step 4: Create the request + // Step 4: Create the transaction payload for POST /v1/orders/{order_id}/transactions $request = [ "payments" => [ [ diff --git a/examples/Order/Transaction/Delete.php b/examples/Order/Transaction/Delete.php index 87c1633d..35192dd7 100644 --- a/examples/Order/Transaction/Delete.php +++ b/examples/Order/Transaction/Delete.php @@ -51,9 +51,8 @@ $transaction_id = $order->transactions->payments[0]->id; $order_id = $order->id; - // Step 5: Delete a transaction - $request_options->setCustomHeaders(["X-Idempotency-Key: "]); - $response = $client_transactions->delete($order_id, $transaction_id, $request_options); + // Step 5: Delete the transaction with DELETE /v1/orders/{order_id}/transactions/{transaction_id} + $response = $client_transactions->delete($order_id, $transaction_id); if ($response->getStatusCode() === 204) { echo "Transaction deleted successfully. HTTP Status Code: 204\n"; } else { diff --git a/examples/Order/Transaction/Update.php b/examples/Order/Transaction/Update.php index 4ee34973..74ecab15 100644 --- a/examples/Order/Transaction/Update.php +++ b/examples/Order/Transaction/Update.php @@ -59,7 +59,7 @@ echo "\nPayment ID: " . $order->transactions->payments[0]->id; echo "\nAmount: " . $order->transactions->payments[0]->amount; - // Step 8: Create the request to update a transaction + // Step 8: Create the payload for PUT /v1/orders/{order_id}/transactions/{transaction_id} $update_transaction_request = [ "payment_method" => [ "installments" => 3, diff --git a/src/MercadoPago/Client/Order/OrderClient.php b/src/MercadoPago/Client/Order/OrderClient.php index f0bc0ba6..a2e5ba44 100644 --- a/src/MercadoPago/Client/Order/OrderClient.php +++ b/src/MercadoPago/Client/Order/OrderClient.php @@ -4,180 +4,74 @@ 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\Resources\Order; +use MercadoPago\Resources\OrderSearch; use MercadoPago\Serialization\Serializer; -/** - * Client for the Orders API (`/v1/orders`). - * - * Provides full lifecycle management for orders: create, get, capture, cancel, - * process, refund, and search. Transaction-level operations (add/update/delete - * individual payments) are handled by the dedicated {@see OrderTransactionClient}. - * - * @see https://www.mercadopago.com/developers/en/reference/order/_v1_orders/post - */ +/** Client for the Orders API (`/v1/orders`). */ 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'; - private const URL_REFUND = self::URL_WITH_ID . '/refund'; + private const URL_CANCEL = "/v1/orders/%s/cancel"; + private const URL_PROCESS = "/v1/orders/%s/process"; + private const URL_CAPTURE = "/v1/orders/%s/capture"; + private const URL_REFUND = "/v1/orders/%s/refund"; - /** @param MPHttpClient|null $MPHttpClient Custom HTTP client. Defaults to the SDK global client. */ public function __construct(?MPHttpClient $MPHttpClient = null) { parent::__construct($MPHttpClient ?: MercadoPagoConfig::getHttpClient()); } - /** - * Creates a new order. - * - * @param array $request Order data (type, total_amount, external_reference, payer, transactions, items, etc.). - * @param RequestOptions|null $request_options Per-request configuration overrides. - * @return Order The created order resource. - * @throws \MercadoPago\Exceptions\MPApiException When the API returns a non-2xx status code. - * @throws \Exception On transport-level errors. - * @see https://www.mercadopago.com/developers/en/reference/order/_v1_orders/post - */ public function create(array $request, ?RequestOptions $request_options = null): Order { - $response = parent::send(self::URL, HttpMethod::POST, json_encode($request), null, $request_options); - $result = Serializer::deserializeFromJson(Order::class, $response->getContent()); - $result->setResponse($response); - return $result; + return $this->sendOrder(self::URL, HttpMethod::POST, $request, null, $request_options); } - /** - * Captures an authorized order. - * - * Only applies to orders created with `capture_mode: "manual"`. Once captured, - * the funds are transferred from the buyer to the seller. - * - * @param string $order_id Unique identifier of the order to capture. - * @param RequestOptions|null $request_options Per-request configuration overrides. - * @return Order The captured order resource with updated status. - * @throws \MercadoPago\Exceptions\MPApiException When the API returns a non-2xx status code. - * @throws \Exception On transport-level errors. - * @see https://www.mercadopago.com/developers/en/reference/order/_v1_orders_id_capture/post - */ - public function capture(string $order_id, ?RequestOptions $request_options = null): Order + public function search(MPSearchRequest $request, ?RequestOptions $request_options = null): OrderSearch { - $response = parent::send(sprintf(self::URL_CAPTURE, rawurlencode($order_id)), HttpMethod::POST, null, null, $request_options); - $result = Serializer::deserializeFromJson(Order::class, $response->getContent()); + $response = parent::send(self::URL, HttpMethod::GET, null, $request->getParameters(), $request_options); + $result = Serializer::deserializeFromJson(OrderSearch::class, $response->getContent()); $result->setResponse($response); return $result; } - /** - * Retrieves an existing order by its ID. - * - * @param string $order_id Unique identifier of the order. - * @param RequestOptions|null $request_options Per-request configuration overrides. - * @return Order The found order resource. - * @throws \MercadoPago\Exceptions\MPApiException When the API returns a non-2xx status code. - * @throws \Exception On transport-level errors. - * @see https://www.mercadopago.com/developers/en/reference/order/_v1_orders_id/get - */ - public function get(string $order_id, ?RequestOptions $request_options = null): Order + public function get(string $id, ?RequestOptions $request_options = null): Order { - $response = parent::send(sprintf(self::URL_WITH_ID, rawurlencode($order_id)), HttpMethod::GET, null, null, $request_options); - $result = Serializer::deserializeFromJson(Order::class, $response->getContent()); - $result->setResponse($response); - return $result; + return $this->sendOrder(sprintf(self::URL_WITH_ID, rawurlencode($id)), HttpMethod::GET, null, null, $request_options); } - /** - * Cancels an existing order. - * - * Only orders that have not yet been fully captured can be cancelled. - * Cancellation releases any authorized funds back to the buyer. - * - * @param string $order_id Unique identifier of the order to cancel. - * @param RequestOptions|null $request_options Per-request configuration overrides. - * @return Order The cancelled order resource with updated status. - * @throws \MercadoPago\Exceptions\MPApiException When the API returns a non-2xx status code. - * @throws \Exception On transport-level errors. - * @see https://www.mercadopago.com/developers/en/reference/order/_v1_orders_id_cancel/post - */ public function cancel(string $order_id, ?RequestOptions $request_options = null): Order { - $response = parent::send(sprintf(self::URL_CANCEL, rawurlencode($order_id)), HttpMethod::POST, null, null, $request_options); - $result = Serializer::deserializeFromJson(Order::class, $response->getContent()); - $result->setResponse($response); - return $result; + return $this->sendOrder(sprintf(self::URL_CANCEL, rawurlencode($order_id)), HttpMethod::POST, null, null, $request_options); } - /** - * Processes an order, triggering its payment execution. - * - * Initiates the payment flow for all transactions attached to the order. - * The order must have at least one transaction configured before processing. - * - * @param string $order_id Unique identifier of the order to process. - * @param RequestOptions|null $request_options Per-request configuration overrides. - * @return Order The processed order resource with updated status. - * @throws \MercadoPago\Exceptions\MPApiException When the API returns a non-2xx status code. - * @throws \Exception On transport-level errors. - * @see https://www.mercadopago.com/developers/en/reference/order/_v1_orders_id_process/post - */ public function process(string $order_id, ?RequestOptions $request_options = null): Order { - $response = parent::send(sprintf(self::URL_PROCESS, rawurlencode($order_id)), HttpMethod::POST, null, null, $request_options); - $result = Serializer::deserializeFromJson(Order::class, $response->getContent()); - $result->setResponse($response); - return $result; + return $this->sendOrder(sprintf(self::URL_PROCESS, rawurlencode($order_id)), HttpMethod::POST, null, null, $request_options); + } + + public function capture(string $order_id, ?RequestOptions $request_options = null): Order + { + return $this->sendOrder(sprintf(self::URL_CAPTURE, rawurlencode($order_id)), HttpMethod::POST, null, null, $request_options); } - /** - * Refunds an order (total or partial). - * - * Pass null for the request to perform a total refund of the entire order amount. - * For partial refunds, provide an array with the desired refund details (e.g., transactions to refund). - * - * @param string $order_id Unique identifier of the order to refund. - * @param array|null $request Refund data for partial refunds, or null for a total refund. - * @param RequestOptions|null $request_options Per-request configuration overrides. - * @return Order The refunded order resource with updated refund details. - * @throws \MercadoPago\Exceptions\MPApiException When the API returns a non-2xx status code. - * @throws \Exception On transport-level errors. - * @see https://www.mercadopago.com/developers/en/reference/order/_v1_orders_id_refund/post - */ public function refund(string $order_id, ?array $request = null, ?RequestOptions $request_options = null): Order { - $path = sprintf(self::URL_REFUND, rawurlencode($order_id)); - if ($request !== null) { - $request = json_encode($request); - } - $response = parent::send($path, HttpMethod::POST, $request, null, $request_options); - $result = Serializer::deserializeFromJson(Order::class, $response->getContent()); - $result->setResponse($response); - return $result; + return $this->sendOrder(sprintf(self::URL_REFUND, rawurlencode($order_id)), HttpMethod::POST, $request, null, $request_options); } - /** - * Searches orders with pagination and filters. - * - * @param MPSearchRequest $request Search criteria (limit, offset, filters like status, external_reference, etc.). - * @param RequestOptions|null $request_options Per-request configuration overrides. - * @return OrderSearch Paginated search results containing matching orders. - * @throws \MercadoPago\Exceptions\MPApiException When the API returns a non-2xx status code. - * @throws \Exception On transport-level errors. - * @see https://www.mercadopago.com/developers/en/reference/order/_v1_orders_search/get - */ - public function search(MPSearchRequest $request, ?RequestOptions $request_options = null): OrderSearch + /** @param array|null $request @param array|null $query */ + private function sendOrder(string $path, string $method, ?array $request, ?array $query, ?RequestOptions $options): Order { - $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()); + $payload = $request === null ? null : json_encode($request); + $response = parent::send($path, $method, $payload, $query, $options); + $result = Serializer::deserializeFromJson(Order::class, $response->getContent()); $result->setResponse($response); return $result; } -} +} \ No newline at end of file diff --git a/src/MercadoPago/Client/Order/OrderTransactionClient.php b/src/MercadoPago/Client/Order/OrderTransactionClient.php index a806a2ca..955f7095 100644 --- a/src/MercadoPago/Client/Order/OrderTransactionClient.php +++ b/src/MercadoPago/Client/Order/OrderTransactionClient.php @@ -7,80 +7,42 @@ use MercadoPago\MercadoPagoConfig; use MercadoPago\Net\HttpMethod; use MercadoPago\Net\MPHttpClient; +use MercadoPago\Net\MPResponse; use MercadoPago\Resources\Order\Transaction\UpdateTransaction; use MercadoPago\Resources\Order\Transactions; use MercadoPago\Serialization\Serializer; -use MercadoPago\Net\MPResponse; -/** - * Client for the Order Transactions API (`/v1/orders/{id}/transactions`). - * - * Manages payment transactions within an order, supporting multi-payment - * scenarios where an order can contain multiple transactions (split payments). - */ +/** Client for `/v1/orders/{order_id}/transactions`. */ final class OrderTransactionClient extends MercadoPagoClient { private const URL = "/v1/orders/%s/transactions"; - private const URL_WITH_ID = self::URL . "/%s"; + private const URL_WITH_ID = "/v1/orders/%s/transactions/%s"; - /** @param MPHttpClient|null $MPHttpClient Custom HTTP client. Defaults to the SDK global client. */ public function __construct(?MPHttpClient $MPHttpClient = null) { parent::__construct($MPHttpClient ?: MercadoPagoConfig::getHttpClient()); } - /** - * Creates a new transaction within an order. - * - * @param string $order_id Order ID. - * @param array $request Transaction data (payment method, amount, etc.). - * @param RequestOptions|null $request_options Per-request configuration overrides. - * @return Transactions The created transaction resource. - * @throws \MercadoPago\Exceptions\MPApiException When the API returns a non-2xx status code. - * @throws \Exception On transport-level errors. - */ public function create(string $order_id, array $request, ?RequestOptions $request_options = null): Transactions { - $path = sprintf(self::URL, rawurlencode($order_id)); - $response = parent::send($path, HttpMethod::POST, json_encode($request), null, $request_options); + $response = parent::send(sprintf(self::URL, rawurlencode($order_id)), HttpMethod::POST, json_encode($request), null, $request_options); $result = Serializer::deserializeFromJson(Transactions::class, $response->getContent()); $result->setResponse($response); return $result; } - /** - * Updates an existing transaction within an order. - * - * @param string $order_id Order ID. - * @param string $transaction_id Transaction ID to update. - * @param array $request Fields to update. - * @param RequestOptions|null $request_options Per-request configuration overrides. - * @return UpdateTransaction The updated transaction resource. - * @throws \MercadoPago\Exceptions\MPApiException When the API returns a non-2xx status code. - * @throws \Exception On transport-level errors. - */ - public function update(string $order_id, string $transaction_id, array $request, ?RequestOptions $request_options = null): UpdateTransaction + public function update(string $order_id, string $transaction_id, array $request, ?RequestOptions $request_options = null): Payment { $path = sprintf(self::URL_WITH_ID, rawurlencode($order_id), rawurlencode($transaction_id)); $response = parent::send($path, HttpMethod::PUT, json_encode($request), null, $request_options); - $result = Serializer::deserializeFromJson(UpdateTransaction::class, $response->getContent()); + $result = Serializer::deserializeFromJson(Payment::class, $response->getContent()); $result->setResponse($response); return $result; } - /** - * Deletes a transaction from an order. - * - * @param string $order_id Order ID. - * @param string $transaction_id Transaction ID to delete. - * @param RequestOptions|null $request_options Per-request configuration overrides. - * @return MPResponse Raw API response (typically empty body with 204 status). - * @throws \MercadoPago\Exceptions\MPApiException When the API returns a non-2xx status code. - * @throws \Exception On transport-level errors. - */ public function delete(string $order_id, string $transaction_id, ?RequestOptions $request_options = null): MPResponse { $path = sprintf(self::URL_WITH_ID, rawurlencode($order_id), rawurlencode($transaction_id)); return parent::send($path, HttpMethod::DELETE, null, null, $request_options); } -} +} \ No newline at end of file diff --git a/src/MercadoPago/Resources/Order.php b/src/MercadoPago/Resources/Order.php index 1b970989..7cf1c5d0 100644 --- a/src/MercadoPago/Resources/Order.php +++ b/src/MercadoPago/Resources/Order.php @@ -30,10 +30,10 @@ class Order extends MPResource /** Seller-defined reference to correlate the order with an external system. */ public ?string $external_reference; - /** ISO 3166-1 alpha-2 country code where the order is processed. */ + /** MercadoPago site identifier where the order was created (for example, "MLB"). */ public ?string $country_code; - /** Current high-level status of the order (e.g., "opened", "closed", "expired"). */ + /** Current high-level status of the order (e.g., "created", "processed", "canceled"). */ public ?string $status; /** Granular detail complementing the order status. */ diff --git a/src/MercadoPago/Resources/Order/Config.php b/src/MercadoPago/Resources/Order/Config.php index 99183637..1e0430d5 100644 --- a/src/MercadoPago/Resources/Order/Config.php +++ b/src/MercadoPago/Resources/Order/Config.php @@ -22,7 +22,7 @@ class Config /** Text shown on the buyer's credit card statement. Approximately 10 characters max depending on the card issuer. */ public ?string $statement_descriptor; - /** Offline payment expiration duration in ISO 8601 format (e.g. "P1D" = 1 day). */ + /** Default payment due date returned by the Orders API. */ public ?string $default_payment_due_date; /** Payment method restrictions, defaults, and installment settings. Maps to {@see PaymentMethodConfig}. */ diff --git a/src/MercadoPago/Resources/Order/IntegrationData.php b/src/MercadoPago/Resources/Order/IntegrationData.php index 57bf1400..05e4b95c 100644 --- a/src/MercadoPago/Resources/Order/IntegrationData.php +++ b/src/MercadoPago/Resources/Order/IntegrationData.php @@ -22,7 +22,7 @@ class IntegrationData /** Identifier of the corporation that owns the integration. */ public ?string $corporation_id; - /** MercadoPago application ID used to create the order. */ + /** MercadoPago application identifier used to create the order. */ public ?string $application_id; /** Certified integrator identifier assigned by MercadoPago. */ diff --git a/src/MercadoPago/Resources/Order/Items.php b/src/MercadoPago/Resources/Order/Items.php index c7d126fd..d021298a 100644 --- a/src/MercadoPago/Resources/Order/Items.php +++ b/src/MercadoPago/Resources/Order/Items.php @@ -26,8 +26,8 @@ class Items /** Display name of the product or service. */ public ?string $title; - /** Price per unit in the order's currency. */ - public ?string $unit_price; + /** Price per unit in the order's currency. Strings remain accepted for backwards compatibility. */ + public float|string|null $unit_price; /** Number of units of this item being purchased. */ public ?int $quantity; diff --git a/src/MercadoPago/Resources/Order/OnlineConfig.php b/src/MercadoPago/Resources/Order/OnlineConfig.php index 78ec8093..3740fc9a 100644 --- a/src/MercadoPago/Resources/Order/OnlineConfig.php +++ b/src/MercadoPago/Resources/Order/OnlineConfig.php @@ -38,7 +38,7 @@ class OnlineConfig /** URL to redirect the buyer after a failed payment. */ public ?string $failure_url; - /** Legacy URL field for automatic redirection. Prefer auto_return plus success/failure/pending URLs for online orders. */ + /** URL used by the API for automatic redirection after checkout. */ public ?string $auto_return_url; /** Automatic redirect behavior. "approved" redirects to success_url on approval; "all" redirects on any outcome. */ diff --git a/src/MercadoPago/Resources/Order/Shipment.php b/src/MercadoPago/Resources/Order/Shipment.php index 8d7024c2..b034dbb9 100644 --- a/src/MercadoPago/Resources/Order/Shipment.php +++ b/src/MercadoPago/Resources/Order/Shipment.php @@ -31,7 +31,7 @@ class Shipment /** When true, shipping is free for the buyer. Cannot be combined with cost > 0. */ public ?bool $free_shipping; - /** List of free shipping method IDs available to the buyer. */ + /** List of free shipping method objects available to the buyer. */ public ?array $free_methods; /** Delivery address for the shipment. Maps to Address. */ diff --git a/src/MercadoPago/Resources/Order/Transaction/UpdateTransaction.php b/src/MercadoPago/Resources/Order/Transaction/UpdateTransaction.php index 1fc5ab8b..8e323046 100644 --- a/src/MercadoPago/Resources/Order/Transaction/UpdateTransaction.php +++ b/src/MercadoPago/Resources/Order/Transaction/UpdateTransaction.php @@ -4,8 +4,7 @@ namespace MercadoPago\Resources\Order\Transaction; -use MercadoPago\Net\MPResource; -use MercadoPago\Serialization\Mapper; +use MercadoPago\Resources\Order\Payment; /** * Represents the response from updating a transaction within a MercadoPago order. @@ -15,23 +14,6 @@ * * @see \MercadoPago\Client\Order\OrderTransactionClient */ -class UpdateTransaction extends MPResource +class UpdateTransaction extends Payment { - /** Class mapper. */ - use Mapper; - - /** Updated payment method details for the transaction. Maps to {@see \MercadoPago\Resources\Order\PaymentMethod}. */ - public array|object|null $payment_method; - - private $map = [ - "payment_method" => "MercadoPago\Resources\Order\PaymentMethod", - ]; - - /** - * Method responsible for getting map of entities. - */ - public function getMap(): array - { - return $this->map; - } } diff --git a/src/MercadoPago/Resources/Order/TransactionSecurity.php b/src/MercadoPago/Resources/Order/TransactionSecurity.php index 47547e02..3e255c5c 100644 --- a/src/MercadoPago/Resources/Order/TransactionSecurity.php +++ b/src/MercadoPago/Resources/Order/TransactionSecurity.php @@ -29,7 +29,7 @@ class TransactionSecurity /** Whether liability shifted to the issuer after 3DS authentication (e.g., "yes", "no"). */ public ?string $liability_shift; - /** Challenge URL where the buyer must complete 3DS authentication. */ + /** URL where the buyer completes the 3DS authentication challenge. */ public ?string $url; /** diff --git a/src/MercadoPago/Resources/Order/Transactions.php b/src/MercadoPago/Resources/Order/Transactions.php index f3ee7609..c6e74c03 100644 --- a/src/MercadoPago/Resources/Order/Transactions.php +++ b/src/MercadoPago/Resources/Order/Transactions.php @@ -22,13 +22,13 @@ class Transactions extends MPResource /** Class mapper. */ use Mapper; - /** Payments associated with this order. Each element maps to {@see Payment}. */ + /** @var Payment[]|null Payments associated with this order. */ public ?array $payments; - /** Refunds processed for this order's payments. Each element maps to {@see Refund}. */ + /** @var Refund[]|null Refunds processed for this order's payments. */ public ?array $refunds; - /** Chargebacks filed against this order's payments. Each element maps to {@see Chargeback}. */ + /** @var Chargeback[]|null Chargebacks filed against this order's payments. */ public ?array $chargebacks; private $map = [ diff --git a/src/MercadoPago/Resources/OrderSearch.php b/src/MercadoPago/Resources/OrderSearch.php index 0496eb2f..c0153550 100644 --- a/src/MercadoPago/Resources/OrderSearch.php +++ b/src/MercadoPago/Resources/OrderSearch.php @@ -21,8 +21,8 @@ class OrderSearch extends MPResource /** Pagination metadata (offset, limit, total). Maps to {@see \MercadoPago\Resources\Common\Paging}. */ public array|object|null $paging; - /** Array of {@see Order} resources matching the search criteria. */ - public array|object|null $data; + /** @var Order[]|null Orders in the current result page. */ + public ?array $data; private $map = [ "paging" => "MercadoPago\Resources\Common\Paging", diff --git a/tests/MercadoPago/Client/Integration/Order/OrderTransactionClientITTest.php b/tests/MercadoPago/Client/Integration/Order/OrderTransactionClientITTest.php index 96d06727..12bba11f 100644 --- a/tests/MercadoPago/Client/Integration/Order/OrderTransactionClientITTest.php +++ b/tests/MercadoPago/Client/Integration/Order/OrderTransactionClientITTest.php @@ -28,8 +28,12 @@ public function testCreateSuccess(): void $client = new OrderTransactionClient(); $request = $this->createRequest(); - $order = $order_client->create($create_order_request); - $transaction = $client->create($order->id, $request); + $order_options = new RequestOptions(); + $order_options->setCustomHeaders(["X-Idempotency-Key: " . bin2hex(random_bytes(16))]); + $order = $order_client->create($create_order_request, $order_options); + $transaction_options = new RequestOptions(); + $transaction_options->setCustomHeaders(["X-Idempotency-Key: " . bin2hex(random_bytes(16))]); + $transaction = $client->create($order->id, $request, $transaction_options); $this->assertNotNull($transaction->payments[0]->id); } catch (MPApiException $e) { @@ -83,9 +87,11 @@ public function testUpdateSuccess(): void ] ]; - $order = $order_client->create($create_order_request); + $request_options = new RequestOptions(); + $request_options->setCustomHeaders(["X-Idempotency-Key: " . bin2hex(random_bytes(16))]); + $order = $order_client->create($create_order_request, $request_options); sleep(3); - $transaction = $order_transaction_client->update($order->id, $order->transactions->payments[0]->id, $update_transaction_request); + $transaction = $order_transaction_client->update($order->id, $order->transactions->payments[0]->id, $update_transaction_request, $request_options); $this->assertSame("master", $transaction->payment_method->id); $this->assertSame("credit_card", $transaction->payment_method->type); diff --git a/tests/MercadoPago/Client/Unit/Order/OrderClientUnitTest.php b/tests/MercadoPago/Client/Unit/Order/OrderClientUnitTest.php index 51659baf..959b2775 100644 --- a/tests/MercadoPago/Client/Unit/Order/OrderClientUnitTest.php +++ b/tests/MercadoPago/Client/Unit/Order/OrderClientUnitTest.php @@ -4,7 +4,6 @@ use MercadoPago\Client\Common\RequestOptions; use MercadoPago\Client\Order\OrderClient; -use MercadoPago\Exceptions\MPApiException; use MercadoPago\MercadoPagoConfig; use MercadoPago\Net\MPDefaultHttpClient; use MercadoPago\Tests\Client\Unit\Base\BaseClient; @@ -17,14 +16,16 @@ final class OrderClientUnitTest extends BaseClient public function testCreateSuccess(): void { $filepath = '../../../../Resources/Mocks/Response/Order/order.json'; - $mock_http_request = $this->mockHttpRequest($filepath, 200); + $mock_http_request = $this->mockHttpRequest($filepath, 201); $http_client = new MPDefaultHttpClient($mock_http_request); MercadoPagoConfig::setHttpClient($http_client); $client = new OrderClient(); + $request_options = new RequestOptions(); + $request_options->setCustomHeaders(["X-Idempotency-Key: create-order-key"]); - $order = $client->create($this->createRequest()); + $order = $client->create($this->createRequest(), $request_options); - $this->assertSame(200, $order->getResponse()->getStatusCode()); + $this->assertSame(201, $order->getResponse()->getStatusCode()); $this->assertSame("01HRYFWNYRE1MR1E60MW3X0T2P", $order->id); $this->assertSame("online", $order->type); $this->assertSame("1000.00", $order->total_amount); diff --git a/tests/MercadoPago/Resources/Mocks/Response/Order/get_order_response.json b/tests/MercadoPago/Resources/Mocks/Response/Order/get_order_response.json index 5b25ae66..08ed437c 100644 --- a/tests/MercadoPago/Resources/Mocks/Response/Order/get_order_response.json +++ b/tests/MercadoPago/Resources/Mocks/Response/Order/get_order_response.json @@ -5,6 +5,8 @@ "capture_mode": "automatic_async", "external_reference": "ext_ref_1234", "total_amount": "200.00", + "total_paid_amount": "200.00", + "currency": "BRL", "site_id": "MLB", "status": "processed", "status_detail": "accredited", diff --git a/tests/MercadoPago/Resources/Mocks/Response/Order/order.json b/tests/MercadoPago/Resources/Mocks/Response/Order/order.json index e3719735..abad0dbc 100644 --- a/tests/MercadoPago/Resources/Mocks/Response/Order/order.json +++ b/tests/MercadoPago/Resources/Mocks/Response/Order/order.json @@ -2,8 +2,10 @@ "id": "01HRYFWNYRE1MR1E60MW3X0T2P", "type": "online", "total_amount": "1000.00", + "total_paid_amount": "1000.00", + "currency": "BRL", "external_reference": "ext_ref_1234", - "site_id": "MLB", + "country_code": "MLB", "created_date": "2024-09-02T22:04:01.880469Z", "last_updated_date": "2024-09-02T22:04:04.429289Z", "status": "processed", diff --git a/tests/MercadoPago/Resources/Mocks/Response/Order/order_cancel.json b/tests/MercadoPago/Resources/Mocks/Response/Order/order_cancel.json index a0bad234..12afbb78 100644 --- a/tests/MercadoPago/Resources/Mocks/Response/Order/order_cancel.json +++ b/tests/MercadoPago/Resources/Mocks/Response/Order/order_cancel.json @@ -5,9 +5,11 @@ "capture_mode": "manual", "external_reference": "ext_ref_1234", "total_amount": "200.00", - "site_id": "MLB", - "status": "cancelled", - "status_detail": "cancelled", + "total_paid_amount": "0.00", + "currency": "BRL", + "country_code": "MLB", + "status": "canceled", + "status_detail": "canceled", "created_date": "2024-11-22T20:45:16.572Z", "last_updated_date": "2024-11-22T20:45:44.063Z", "integration_data": { diff --git a/tests/MercadoPago/Resources/Mocks/Response/Order/order_capture.json b/tests/MercadoPago/Resources/Mocks/Response/Order/order_capture.json index 8b54135d..0aedf33c 100644 --- a/tests/MercadoPago/Resources/Mocks/Response/Order/order_capture.json +++ b/tests/MercadoPago/Resources/Mocks/Response/Order/order_capture.json @@ -1,6 +1,13 @@ { "id": "01HRYFWNYRE1MR1E60MW3X0T2P", + "type": "online", + "processing_mode": "automatic", + "capture_mode": "manual", + "total_amount": "1000.00", + "total_paid_amount": "1000.00", + "currency": "BRL", "status": "processed", + "status_detail": "accredited", "transactions": { "payments": [ { diff --git a/tests/MercadoPago/Resources/Mocks/Response/Order/order_checkout_pro.json b/tests/MercadoPago/Resources/Mocks/Response/Order/order_checkout_pro.json index cb05ca05..173cf396 100644 --- a/tests/MercadoPago/Resources/Mocks/Response/Order/order_checkout_pro.json +++ b/tests/MercadoPago/Resources/Mocks/Response/Order/order_checkout_pro.json @@ -5,7 +5,7 @@ "external_reference": "ext_ref_checkout_pro_001", "marketplace_fee": "5.00", "total_amount": "500.00", - "checkout_url": "https://www.mercadopago.com/checkout/v1/redirect?order_id=ORDTST01KS5AJ6HTK2HRQ3XJ3C2JCKP9", + "total_paid_amount": "0.00", "expiration_time": "P1D", "country_code": "ARG", "user_id": "1858095454", diff --git a/tests/MercadoPago/Resources/Mocks/Response/Order/order_process.json b/tests/MercadoPago/Resources/Mocks/Response/Order/order_process.json index 0fb761d2..3c245905 100644 --- a/tests/MercadoPago/Resources/Mocks/Response/Order/order_process.json +++ b/tests/MercadoPago/Resources/Mocks/Response/Order/order_process.json @@ -5,9 +5,11 @@ "capture_mode": "automatic_async", "external_reference": "ext_12345", "total_amount": "100.00", - "site_id": "MLB", + "total_paid_amount": "100.00", + "currency": "BRL", + "country_code": "MLB", "status": "processed", - "status_detail": "processed", + "status_detail": "accredited", "created_date": "2024-11-22T15:26:56.704Z", "last_updated_date": "2024-11-22T15:27:23.987Z", "integration_data": { diff --git a/tests/MercadoPago/Resources/Mocks/Response/Order/order_refund_partial.json b/tests/MercadoPago/Resources/Mocks/Response/Order/order_refund_partial.json index aa4d1f3f..9ff945a0 100644 --- a/tests/MercadoPago/Resources/Mocks/Response/Order/order_refund_partial.json +++ b/tests/MercadoPago/Resources/Mocks/Response/Order/order_refund_partial.json @@ -1,8 +1,32 @@ { "id": "01JDWMFW1WQK1YJR6SJFW7KND5", + "type": "online", + "processing_mode": "automatic", + "capture_mode": "automatic_async", + "external_reference": "ext_ref_partial_refund", + "total_amount": "100.00", + "total_paid_amount": "75.00", + "currency": "BRL", + "site_id": "MLB", "status": "processed", "status_detail": "partially_refunded", + "created_date": "2024-11-29T14:20:01.000Z", + "last_updated_date": "2024-11-29T14:25:10.000Z", "transactions": { + "payments": [ + { + "id": "pay_01JDWMFW1WQK1YJR6SJHYTY0MY", + "reference_id": "payment_reference_001", + "amount": "100.00", + "status": "processed", + "status_detail": "partially_refunded", + "payment_method": { + "id": "master", + "type": "credit_card", + "installments": 1 + } + } + ], "refunds": [ { "id": "ref_01JDWMHTXPBT4117BVGAWV29HG", diff --git a/tests/MercadoPago/Resources/Mocks/Response/Order/order_refund_total.json b/tests/MercadoPago/Resources/Mocks/Response/Order/order_refund_total.json index b3c31b7f..33c83245 100644 --- a/tests/MercadoPago/Resources/Mocks/Response/Order/order_refund_total.json +++ b/tests/MercadoPago/Resources/Mocks/Response/Order/order_refund_total.json @@ -1,8 +1,32 @@ { "id": "01JDWHNG2GR2WHGBMRFX126YBC", + "type": "online", + "processing_mode": "automatic", + "capture_mode": "automatic_async", + "external_reference": "ext_ref_total_refund", + "total_amount": "100.00", + "total_paid_amount": "0.00", + "currency": "BRL", + "site_id": "MLB", "status": "refunded", "status_detail": "refunded", + "created_date": "2024-11-29T13:10:01.000Z", + "last_updated_date": "2024-11-29T13:15:10.000Z", "transactions": { + "payments": [ + { + "id": "pay_01JDWHNG2GR2WHGBMRFY7HP5ZB", + "reference_id": "payment_reference_002", + "amount": "100.00", + "status": "refunded", + "status_detail": "refunded", + "payment_method": { + "id": "master", + "type": "credit_card", + "installments": 1 + } + } + ], "refunds": [ { "id": "ref_01JDWHPXYC42ESJ40V4D3SMHW1", diff --git a/tests/MercadoPago/Resources/Mocks/Response/Order/order_search.json b/tests/MercadoPago/Resources/Mocks/Response/Order/order_search.json index 45f781f1..661daad1 100644 --- a/tests/MercadoPago/Resources/Mocks/Response/Order/order_search.json +++ b/tests/MercadoPago/Resources/Mocks/Response/Order/order_search.json @@ -13,16 +13,34 @@ "capture_mode": "automatic_async", "external_reference": "ext_ref_1234", "total_amount": "200.00", + "total_paid_amount": "200.00", + "currency": "BRL", "site_id": "MLB", "status": "processed", "status_detail": "accredited", "created_date": "2024-11-19T17:07:31.486Z", "last_updated_date": "2024-11-19T17:07:33.068Z", + "integration_data": { + "application_id": "7329832788213154" + }, "payer": { "email": "test_1731354550@testuser.com" }, "transactions": { - "payments": [] + "payments": [ + { + "id": "pay_01JD2P9GGXAPBDGG6YT92J5305", + "reference_id": "0001ozsb5o", + "amount": "200.00", + "status": "processed", + "status_detail": "accredited", + "payment_method": { + "id": "master", + "type": "credit_card", + "installments": 1 + } + } + ] } } ] diff --git a/tests/MercadoPago/Resources/Mocks/Response/Order/transaction.json b/tests/MercadoPago/Resources/Mocks/Response/Order/transaction.json index 8006f12d..a7e90a22 100644 --- a/tests/MercadoPago/Resources/Mocks/Response/Order/transaction.json +++ b/tests/MercadoPago/Resources/Mocks/Response/Order/transaction.json @@ -1,13 +1,21 @@ { - "payments": [ - { - "id": "pay_01JD26HQ96FFHBD2CHDW984TZM", - "amount": "100.00", - "payment_method": { - "id": "master", - "type": "credit_card", - "installments": 3 - } + "payments": [ + { + "id": "pay_01JD26HQ96FFHBD2CHDW984TZM", + "reference_id": "transaction_reference_001", + "amount": "100.00", + "status": "created", + "status_detail": "pending", + "payment_method": { + "id": "master", + "type": "credit_card", + "token": "card_token", + "issuer_id": "master", + "statement_descriptor": "MERCADOPAGO", + "installments": 3 } - ] + } + ], + "refunds": [], + "chargebacks": [] } diff --git a/tests/MercadoPago/Resources/Mocks/Response/Order/updated_transaction.json b/tests/MercadoPago/Resources/Mocks/Response/Order/updated_transaction.json index 8f78ed69..9fc86599 100644 --- a/tests/MercadoPago/Resources/Mocks/Response/Order/updated_transaction.json +++ b/tests/MercadoPago/Resources/Mocks/Response/Order/updated_transaction.json @@ -1,7 +1,15 @@ { + "id": "pay_01JD26HQ96FFHBD2CHDW984TZM", + "reference_id": "transaction_reference_001", + "amount": "100.00", + "status": "created", + "status_detail": "pending", "payment_method": { "id": "master", "type": "credit_card", + "token": "updated_card_token", + "issuer_id": "master", + "statement_descriptor": "MERCADOPAGO", "installments": 1 } }