captureOrder method

Future<CaptureOrderResponse> captureOrder(
  1. CaptureOrderRequest request,
  2. String merchantId,
  3. String orderId, {
  4. String? $fields,
})

Capture funds from the customer for the current order total.

This method should be called after the merchant verifies that they are able and ready to start shipping the order. This method blocks until a response is received from the payment processsor. If this method succeeds, the merchant is guaranteed to receive funds for the order after shipment. If the request fails, it can be retried or the order may be cancelled. This method cannot be called after the entire order is already shipped. A rejected error code is returned when the payment service provider has declined the charge. This indicates a problem between the PSP and either the merchant's or customer's account. Sometimes this error will be resolved by the customer. We recommend retrying these errors once per day or cancelling the order with reason failedToCaptureFunds if the items cannot be held.

request - The metadata request object.

Request parameters:

merchantId - Required. The ID of the account that manages the order. This cannot be a multi-client account.

orderId - Required. The ID of the Order.

$fields - Selector specifying which fields to include in a partial response.

Completes with a CaptureOrderResponse.

Completes with a commons.ApiRequestError if the API endpoint returned an error.

If the used http.Client completes with an error when making a REST call, this method will complete with the same error.

Implementation

async.Future<CaptureOrderResponse> captureOrder(
  CaptureOrderRequest request,
  core.String merchantId,
  core.String orderId, {
  core.String? $fields,
}) async {
  final body_ = convert.json.encode(request);
  final queryParams_ = <core.String, core.List<core.String>>{
    if ($fields != null) 'fields': [$fields],
  };

  final url_ = commons.escapeVariable('$merchantId') +
      '/orders/' +
      commons.escapeVariable('$orderId') +
      '/captureOrder';

  final response_ = await _requester.request(
    url_,
    'POST',
    body: body_,
    queryParams: queryParams_,
  );
  return CaptureOrderResponse.fromJson(
      response_ as core.Map<core.String, core.dynamic>);
}