Class PaymentClient
Client that use the Payments APIs.
Inherited Members
Namespace: MercadoPago.Client.Payment
Assembly: MercadoPago.dll
Syntax
public class PaymentClient : MercadoPagoClient<Payment>
Constructors
| Edit this page View SourcePaymentClient()
Initializes a new instance of the PaymentClient class.
Declaration
public PaymentClient()
PaymentClient(IHttpClient)
Initializes a new instance of the PaymentClient class.
Declaration
public PaymentClient(IHttpClient httpClient)
Parameters
Type | Name | Description |
---|---|---|
IHttpClient | httpClient | The http client that will be used in HTTP requests. |
PaymentClient(IHttpClient, ISerializer)
Initializes a new instance of the PaymentClient class.
Declaration
public PaymentClient(IHttpClient httpClient, ISerializer serializer)
Parameters
Type | Name | Description |
---|---|---|
IHttpClient | httpClient | The http client that will be used in HTTP requests. |
ISerializer | serializer | The serializer that will be used to serialize the HTTP requests content and to deserialize the HTTP response content. |
PaymentClient(ISerializer)
Initializes a new instance of the PaymentClient class.
Declaration
public PaymentClient(ISerializer serializer)
Parameters
Type | Name | Description |
---|---|---|
ISerializer | serializer | The serializer that will be used to serialize the HTTP requests content and to deserialize the HTTP response content. |
Methods
| Edit this page View SourceCancel(long, RequestOptions)
Cancels a pending payment.
Declaration
public Payment Cancel(long id, RequestOptions requestOptions = null)
Parameters
Type | Name | Description |
---|---|---|
long | id | Payment id. |
RequestOptions | requestOptions |
Returns
Type | Description |
---|---|
Payment | The cancelled payment. |
Exceptions
Type | Condition |
---|---|
MercadoPagoException | If a unexpected exception occurs. |
MercadoPagoApiException | If the API returns a error. |
CancelAsync(long, RequestOptions, CancellationToken)
Cancels a pending payment async.
Declaration
public Task<Payment> CancelAsync(long id, RequestOptions requestOptions = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
long | id | Payment id. |
RequestOptions | requestOptions | |
CancellationToken | cancellationToken | Cancellation token. |
Returns
Type | Description |
---|---|
Task<Payment> | A task whose the result is the cancelled payment. |
Exceptions
Type | Condition |
---|---|
MercadoPagoException | If a unexpected exception occurs. |
MercadoPagoApiException | If the API returns a error. |
Capture(long, RequestOptions)
Captures a authorized payment.
Declaration
public Payment Capture(long id, RequestOptions requestOptions = null)
Parameters
Type | Name | Description |
---|---|---|
long | id | Payment id. |
RequestOptions | requestOptions |
Returns
Type | Description |
---|---|
Payment | The captured payment. |
Exceptions
Type | Condition |
---|---|
MercadoPagoException | If a unexpected exception occurs. |
MercadoPagoApiException | If the API returns a error. |
Capture(long, decimal?, RequestOptions)
Captures a authorized payment.
Declaration
public Payment Capture(long id, decimal? amount, RequestOptions requestOptions = null)
Parameters
Type | Name | Description |
---|---|---|
long | id | Payment id. |
decimal? | amount | Amount to capture (if null, will capture the total payment amount). |
RequestOptions | requestOptions |
Returns
Type | Description |
---|---|
Payment | The captured payment. |
Exceptions
Type | Condition |
---|---|
MercadoPagoException | If a unexpected exception occurs. |
MercadoPagoApiException | If the API returns a error. |
CaptureAsync(long, RequestOptions, CancellationToken)
Captures a authorized payment async.
Declaration
public Task<Payment> CaptureAsync(long id, RequestOptions requestOptions = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
long | id | Payment id. |
RequestOptions | requestOptions | |
CancellationToken | cancellationToken | Cancellation token. |
Returns
Type | Description |
---|---|
Task<Payment> | A task whose the result is the captured payment. |
Exceptions
Type | Condition |
---|---|
MercadoPagoException | If a unexpected exception occurs. |
MercadoPagoApiException | If the API returns a error. |
CaptureAsync(long, decimal?, RequestOptions, CancellationToken)
Captures a authorized payment async.
Declaration
public Task<Payment> CaptureAsync(long id, decimal? amount, RequestOptions requestOptions = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
long | id | Payment id. |
decimal? | amount | Amount to capture (if null, will capture the total payment amount). |
RequestOptions | requestOptions | |
CancellationToken | cancellationToken | Cancellation token. |
Returns
Type | Description |
---|---|
Task<Payment> | A task whose the result is the captured payment. |
Exceptions
Type | Condition |
---|---|
MercadoPagoException | If a unexpected exception occurs. |
MercadoPagoApiException | If the API returns a error. |
Create(PaymentCreateRequest, RequestOptions)
Creates a payment.
Declaration
public Payment Create(PaymentCreateRequest request, RequestOptions requestOptions = null)
Parameters
Type | Name | Description |
---|---|---|
PaymentCreateRequest | request | The data to create the payment. |
RequestOptions | requestOptions |
Returns
Type | Description |
---|---|
Payment | The created payment. |
Remarks
Check the API documentation here.
Exceptions
Type | Condition |
---|---|
MercadoPagoException | If a unexpected exception occurs. |
MercadoPagoApiException | If the API returns a error. |
CreateAsync(PaymentCreateRequest, RequestOptions, CancellationToken)
Creates a payment as an asynchronous operation.
Declaration
public Task<Payment> CreateAsync(PaymentCreateRequest request, RequestOptions requestOptions = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
PaymentCreateRequest | request | The data to create the payment. |
RequestOptions | requestOptions | |
CancellationToken | cancellationToken | Cancellation token. |
Returns
Type | Description |
---|---|
Task<Payment> | A task whose the result is the created payment. |
Remarks
Check the API documentation here.
Exceptions
Type | Condition |
---|---|
MercadoPagoException | If a unexpected exception occurs. |
MercadoPagoApiException | If the API returns a error. |
Get(long, RequestOptions)
Get a payment by your ID.
Declaration
public Payment Get(long id, RequestOptions requestOptions = null)
Parameters
Type | Name | Description |
---|---|---|
long | id | The payment id. |
RequestOptions | requestOptions |
Returns
Type | Description |
---|---|
Payment | The payment. |
Remarks
Check the API documentation here.
Exceptions
Type | Condition |
---|---|
MercadoPagoException | If a unexpected exception occurs. |
MercadoPagoApiException | If the API returns a error. |
GetAsync(long, RequestOptions, CancellationToken)
Get async a payment by your ID.
Declaration
public Task<Payment> GetAsync(long id, RequestOptions requestOptions = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
long | id | The payment id. |
RequestOptions | requestOptions | |
CancellationToken | cancellationToken | Cancellation token. |
Returns
Type | Description |
---|---|
Task<Payment> | A task whose the result is the payment. |
Remarks
Check the API documentation here.
Exceptions
Type | Condition |
---|---|
MercadoPagoException | If a unexpected exception occurs. |
MercadoPagoApiException | If the API returns a error. |
GetRefund(long, long, RequestOptions)
Gets a refund by id from the payment.
Declaration
public PaymentRefund GetRefund(long paymentId, long refundId, RequestOptions requestOptions = null)
Parameters
Type | Name | Description |
---|---|---|
long | paymentId | The payment ID. |
long | refundId | The refund ID. |
RequestOptions | requestOptions |
Returns
Type | Description |
---|---|
PaymentRefund | A task whose the result is the refund. |
Exceptions
Type | Condition |
---|---|
MercadoPagoException | If a unexpected exception occurs. |
MercadoPagoApiException | If the API returns a error. |
GetRefundAsync(long, long, RequestOptions, CancellationToken)
Gets async a refund by id from the payment.
Declaration
public Task<PaymentRefund> GetRefundAsync(long id, long refundId, RequestOptions requestOptions = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
long | id | The payment ID. |
long | refundId | The refund ID. |
RequestOptions | requestOptions | |
CancellationToken | cancellationToken | Cancellation token. |
Returns
Type | Description |
---|---|
Task<PaymentRefund> | A task whose the result is the refund. |
Exceptions
Type | Condition |
---|---|
MercadoPagoException | If a unexpected exception occurs. |
MercadoPagoApiException | If the API returns a error. |
ListRefunds(long, RequestOptions)
Lists the refunds of the payment.
Declaration
public ResourcesList<PaymentRefund> ListRefunds(long id, RequestOptions requestOptions = null)
Parameters
Type | Name | Description |
---|---|---|
long | id | The payment ID. |
RequestOptions | requestOptions |
Returns
Type | Description |
---|---|
ResourcesList<PaymentRefund> | A task whose the result is the list of refund. |
Exceptions
Type | Condition |
---|---|
MercadoPagoException | If a unexpected exception occurs. |
MercadoPagoApiException | If the API returns a error. |
ListRefundsAsync(long, RequestOptions, CancellationToken)
Lists async the refunds of the payment.
Declaration
public Task<ResourcesList<PaymentRefund>> ListRefundsAsync(long id, RequestOptions requestOptions = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
long | id | The payment ID. |
RequestOptions | requestOptions | |
CancellationToken | cancellationToken | Cancellation token. |
Returns
Type | Description |
---|---|
Task<ResourcesList<PaymentRefund>> | A task whose the result is the list of refund. |
Exceptions
Type | Condition |
---|---|
MercadoPagoException | If a unexpected exception occurs. |
MercadoPagoApiException | If the API returns a error. |
Refund(long, RequestOptions)
Creates a total refund for payment.
Declaration
public PaymentRefund Refund(long id, RequestOptions requestOptions = null)
Parameters
Type | Name | Description |
---|---|---|
long | id | The payment ID. |
RequestOptions | requestOptions |
Returns
Type | Description |
---|---|
PaymentRefund | The refund. |
Exceptions
Type | Condition |
---|---|
MercadoPagoException | If a unexpected exception occurs. |
MercadoPagoApiException | If the API returns a error. |
Refund(long, decimal?, RequestOptions)
Creates a refund for payment.
Declaration
public PaymentRefund Refund(long id, decimal? amount, RequestOptions requestOptions = null)
Parameters
Type | Name | Description |
---|---|---|
long | id | The payment ID. |
decimal? | amount | The amount to refund. |
RequestOptions | requestOptions |
Returns
Type | Description |
---|---|
PaymentRefund | The refund. |
Exceptions
Type | Condition |
---|---|
MercadoPagoException | If a unexpected exception occurs. |
MercadoPagoApiException | If the API returns a error. |
RefundAsync(long, RequestOptions, CancellationToken)
Creates async a total refund for payment.
Declaration
public Task<PaymentRefund> RefundAsync(long id, RequestOptions requestOptions = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
long | id | The payment ID. |
RequestOptions | requestOptions | |
CancellationToken | cancellationToken | Cancellation token. |
Returns
Type | Description |
---|---|
Task<PaymentRefund> | A task whose the result is the refund. |
Exceptions
Type | Condition |
---|---|
MercadoPagoException | If a unexpected exception occurs. |
MercadoPagoApiException | If the API returns a error. |
RefundAsync(long, decimal?, RequestOptions, CancellationToken)
Creates async a refund for payment.
Declaration
public Task<PaymentRefund> RefundAsync(long id, decimal? amount, RequestOptions requestOptions = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
long | id | The payment ID. |
decimal? | amount | The amount to refund. |
RequestOptions | requestOptions | |
CancellationToken | cancellationToken | Cancellation token. |
Returns
Type | Description |
---|---|
Task<PaymentRefund> | A task whose the result is the refund. |
Exceptions
Type | Condition |
---|---|
MercadoPagoException | If a unexpected exception occurs. |
MercadoPagoApiException | If the API returns a error. |
Search(SearchRequest, RequestOptions)
Searches for payments that match the criteria of AdvancedSearchRequest.
Declaration
public ResultsResourcesPage<Payment> Search(SearchRequest request, RequestOptions requestOptions = null)
Parameters
Type | Name | Description |
---|---|---|
SearchRequest | request | The search request parameters. |
RequestOptions | requestOptions |
Returns
Type | Description |
---|---|
ResultsResourcesPage<Payment> | A page of payments. |
Remarks
Check the API documentation here.
Exceptions
Type | Condition |
---|---|
MercadoPagoException | If a unexpected exception occurs. |
MercadoPagoApiException | If the API returns a error. |
SearchAsync(SearchRequest, RequestOptions, CancellationToken)
Searches async for payments that match the criteria of AdvancedSearchRequest.
Declaration
public Task<ResultsResourcesPage<Payment>> SearchAsync(SearchRequest request, RequestOptions requestOptions = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
SearchRequest | request | The search request parameters. |
RequestOptions | requestOptions | |
CancellationToken | cancellationToken | Cancellation token. |
Returns
Type | Description |
---|---|
Task<ResultsResourcesPage<Payment>> | A task whose the result is a page of payments. |
Remarks
Check the API documentation here.
Exceptions
Type | Condition |
---|---|
MercadoPagoException | If a unexpected exception occurs. |
MercadoPagoApiException | If the API returns a error. |