post https://sandbox.mundipaggone.com/Sale/Capture
Guid merchantKey = Guid.Parse("00000000-0000-0000-0000-000000000000");
// Chave do pedido
Guid orderKey = Guid.Parse("219d7581-78e2-4aa9-b708-b7c585780bfc");
// Cria o cliente para capturar as transações.
IGatewayServiceClient client = new GatewayServiceClient(merchantKey, new Uri("https://sandbox.mundipaggone.com"));
// Captura as transações de cartão de crédito do pedido.
var httpResponse = client.Sale.Manage(ManageOperationEnum.Capture, orderKey);
if (httpResponse.HttpStatusCode == HttpStatusCode.OK
&& httpResponse.Response.CreditCardTransactionResultCollection.Any()
&& httpResponse.Response.CreditCardTransactionResultCollection.All(p => p.Success == true)) {
Console.WriteLine("Transações capturadas.");
}
<?php
try
{
// Carrega dependências
require_once(dirname(__FILE__) . '/vendor/autoload.php');
// Define a URL a ser utilizada
\Gateway\ApiClient::setBaseUrl("https://sandbox.mundipaggone.com");
// Define a chave de loja a ser utilizada
\Gateway\ApiClient::setMerchantKey("85328786-8BA6-420F-9948-5352F5A183EB");
// Cria objeto da requisição
$request = new \Gateway\One\DataContract\Request\CaptureRequest();
// Define dados da requisição
$request->setOrderKey("219d7581-78e2-4aa9-b708-b7c585780bfc");
// Cria novo objeto ApiClient
$client = new Gateway\ApiClient();
// Faz a chamada
$response = $client->capture($request);
}
catch (\Gateway\One\DataContract\Report\ApiError $error)
{
$httpStatusCode = $error->errorCollection->ErrorItemCollection[0]->ErrorCode;
$response = array("message" => $error->errorCollection->ErrorItemCollection[0]->Description);
}
catch (Exception $ex)
{
$httpStatusCode = 500;
$response = array("message" => "Ocorreu um erro inesperado.");
}
finally {
header('Content-Type: application/json');
print json_encode($response->getData());
}
require 'mundipagg_sdk'
# variable with merchant key
merchantKey = '85328786-8BA6-420F-9948-5352F5A183EB'
# instantiate class with request methods
# :sandbox for sandbox ambient
# :production for production ambient
gateway = Gateway::Gateway.new(:sandbox, merchantKey)
# creates request object for transaction capture
captureSaleRequest = Gateway::ManageSaleRequest.new
captureSaleRequest.OrderKey = '219d7581-78e2-4aa9-b708-b7c585780bfc'
# make the request and returns a response hash
puts response = gateway.Capture(captureSaleRequest)
from uuid import UUID
from mundipaggOnePython import GatewayServiceClient
from data_contracts import manage_creditcard_transaction, manage_sale_request
from enum_types import PlatformEnvironment, HttpContentTypeEnum, ManageOperationEnum
merchant_key = UUID('85328786-8BA6-420F-9948-5352F5A183EB')
end_point = "https://sandbox.mundipaggone.com/"
service_client = GatewayServiceClient(merchant_key, PlatformEnvironment.sandbox, HttpContentTypeEnum.json, end_point)
# cria o request de cancelamento.
manage_request = manage_sale_request(order_key = '219d7581-78e2-4aa9-b708-b7c585780bfc')
http_response = service_client.sale.manage_with_request(manage_operation = ManageOperationEnum.Capture, manage_sale_request = manage_request)
# obtem o json da resposta.
json_response = http_response.json()
print json_response
// Define loja
UUID merchantKey = UUID.fromString("85328786-8BA6-420F-9948-5352F5A183EB"); // Chave da Loja - MerchantKey
// Cria o cliente que vai efetuar a operação
GatewayServiceClient serviceClient = new GatewayServiceClient(merchantKey, "https://sandbox.mundipaggone.com");
// Define a chave do pedido
UUID orderKey = UUID.fromString("219d7581-78e2-4aa9-b708-b7c585780bfc"); // Chave do pedido
// Submete a requisição
HttpResponseGenerics<ManageSaleResponse, ManageSaleRequest> httpResponse
= serviceClient.getSale().Manage(ManageOperationEnum.Capture, orderKey);
{
"OrderKey":"219d7581-78e2-4aa9-b708-b7c585780bfc"
}
Após uma pré-autorização, caso você não esteja utilizando antifraude, é necessário que sua transação seja capturada.
Após o envio a transação capturada terá o status Captured
.
Você pode capturar múltiplas transações dentro de um pedido, o exemplo a seguir mostra como fazer isso!
Guid merchantKey = Guid.Parse("00000000-0000-0000-0000-000000000000");
// Chave do pedido
Guid orderKey = Guid.Parse("219d7581-78e2-4aa9-b708-b7c585780bfc");
// Cria o cliente para capturar as transações.
IGatewayServiceClient client = new GatewayServiceClient(merchantKey, new Uri("https://sandbox.mundipaggone.com"));
// Transação específica que será cancelada.
var transactionToCapture = new ManageCreditCardTransaction() {
AmountInCents = 10000,
TransactionKey = Guid.Parse("20ba0520-7d09-44f8-8fbc-e4329e2b18d5")
};
// Captura as transações de cartão de crédito do pedido.
var httpResponse = client.Sale.Manage(ManageOperationEnum.Capture, orderKey, transactionToCapture);
if (httpResponse.HttpStatusCode == HttpStatusCode.OK
&& httpResponse.Response.CreditCardTransactionResultCollection.Any()
&& httpResponse.Response.CreditCardTransactionResultCollection.All(p => p.Success == true)) {
Console.WriteLine("Transações capturadas.");
}
<?php
try
{
// Carrega dependências
require_once(dirname(__FILE__) . '/vendor/autoload.php');
// Define a URL a ser utilizada
\Gateway\ApiClient::setBaseUrl("https://sandbox.mundipaggone.com");
// Define a chave de loja a ser utilizada
\Gateway\ApiClient::setMerchantKey("85328786-8BA6-420F-9948-5352F5A183EB");
// Cria objeto da requisição
$request = new \Gateway\One\DataContract\Request\CaptureRequest();
$request->addCreditCardTransaction()
->setAmountInCents(10000)
->setTransactionkey("20ba0520-7d09-44f8-8fbc-e4329e2b18d5");
// Define dados da requisição
$request->setOrderKey("219d7581-78e2-4aa9-b708-b7c585780bfc");
// Cria novo objeto ApiClient
$client = new Gateway\ApiClient();
// Faz a chamada
$response = $client->capture($request);
}
catch (\Gateway\One\DataContract\Report\ApiError $error)
{
$httpStatusCode = $error->errorCollection->ErrorItemCollection[0]->ErrorCode;
$response = array("message" => $error->errorCollection->ErrorItemCollection[0]->Description);
}
catch (Exception $ex)
{
$httpStatusCode = 500;
$response = array("message" => "Ocorreu um erro inesperado.");
}
finally {
header('Content-Type: application/json');
print json_encode($response->getData());
}
require 'mundipagg_sdk'
# variable with merchant key
merchantKey = '85328786-8BA6-420F-9948-5352F5A183EB'
# instantiate class with request methods
# :sandbox for sandbox ambient
# :production for production ambient
gateway = Gateway::Gateway.new(:sandbox, merchantKey)
# create credit card manage transaction object
creditCardTransaction = Gateway::ManageCreditCardTransaction.new
creditCardTransaction.AmountInCents = 10000
creditCardTransaction.TransactionKey = '20ba0520-7d09-44f8-8fbc-e4329e2b18d5'
# creates request object for transaction capture
captureSaleRequest = Gateway::ManageSaleRequest.new
captureSaleRequest.OrderKey = '219d7581-78e2-4aa9-b708-b7c585780bfc'
captureSaleRequest.CreditCardTransactionCollection << creditCardTransaction
# make the request and returns a response hash
puts response = gateway.Capture(captureSaleRequest)
from uuid import UUID
from mundipaggOnePython import GatewayServiceClient
from data_contracts import manage_creditcard_transaction, manage_sale_request
from enum_types import PlatformEnvironment, HttpContentTypeEnum, ManageOperationEnum
merchant_key = UUID('85328786-8BA6-420F-9948-5352F5A183EB')
end_point = "https://sandbox.mundipaggone.com/"
service_client = GatewayServiceClient(merchant_key, PlatformEnvironment.sandbox, HttpContentTypeEnum.json, end_point)
# dados da transacao que sera cancelada
manage_creditcard_collection_data = [manage_creditcard_transaction(transaction_key = '20ba0520-7d09-44f8-8fbc-e4329e2b18d5', amount_in_cents = 10000)]
# cria o request de cancelamento.
manage_request = manage_sale_request(creditcard_transaction_collection = manage_creditcard_collection_data, order_key = '219d7581-78e2-4aa9-b708-b7c585780bfc')
http_response = service_client.sale.manage_with_request(manage_operation = ManageOperationEnum.Capture, manage_sale_request = manage_request)
# obtem o json da resposta.
json_response = http_response.json()
print json_response
// Define loja
UUID merchantKey = UUID.fromString("85328786-8BA6-420F-9948-5352F5A183EB"); // Chave da Loja - MerchantKey
// Cria o cliente que vai efetuar a operação
GatewayServiceClient serviceClient = new GatewayServiceClient(merchantKey, "https://sandbox.mundipaggone.com");
ManageSaleRequest manageSaleRequest = new ManageSaleRequest();
// Define os detalhes da transação de cartão de crédito
ManageCreditCardTransaction manageCreditCardTransaction = new ManageCreditCardTransaction();
manageCreditCardTransaction.setAmountInCents(10000L);
manageCreditCardTransaction.setTransactionKey(UUID.fromString("20ba0520-7d09-44f8-8fbc-e4329e2b18d5"));
// Cria a lista de transações de cartão e adiciona a transação criada a lista
List<ManageCreditCardTransaction> manageCreditCardTransactionList = new ArrayList<ManageCreditCardTransaction>();
manageCreditCardTransactionList.add(manageCreditCardTransaction);
// Define a chave do pedido
manageSaleRequest.setOrderKey(UUID.fromString("219d7581-78e2-4aa9-b708-b7c585780bfc"));
manageSaleRequest.setCreditCardTransactionCollection(manageCreditCardTransactionList);
// Submete a requisição
HttpResponseGenerics<ManageSaleResponse, ManageSaleRequest> httpResponse
= serviceClient.getSale().Manage(ManageOperationEnum.Capture, manageSaleRequest);
{
"CreditCardTransactionCollection":[{
"AmountInCents":10000,
"TransactionKey":"20ba0520-7d09-44f8-8fbc-e4329e2b18d5"
}],
"OrderKey":"219d7581-78e2-4aa9-b708-b7c585780bfc"
}
Captura Parcial
Algumas adquirentes permitem que uma transação seja capturada com o valor menor do que o autorizado.
Normalmente esse cenário aparece quando um dos itens de uma compra não estão em estoque mas os outros podem ser entregues ao cliente. Basta capturar o valor dos itens que serão entregues.
Abaixo colocamos a tabela das adquirentes que permitem a captura parcial.
Adquirente | Captura parcial |
---|---|
Cielo | Sim |
Rede | Sim |
Stone | Sim |
Elavon | Sim |
GetNet | Sim |
Após uma captura parcial o status da transação será PartialCapture
.