ordersRetryPayment method

Future<OrderPaymentRetryResult?> ordersRetryPayment(
  1. String orderId,
  2. String idempotencyKey, {
  3. Future<void>? abortTrigger,
})

Retry an order's payment

Charges the wallet again for an order whose payment failed. Available only while the order is paymentPending and has no completed payment, as actions.paymentRetry shows; otherwise the call returns 400 with code 10001. Orders created in the dashboard and paid by card must be retried in the dashboard. Returns the order id, its status and the new payment attempt. When the charge succeeds the order becomes paid and fulfillment starts; when it fails again payment.failure carries 16000 (PAYMENT_FAILED). A concurrent retry of the same order returns 409. Requires an Idempotency-Key header (a UUID). Repeating a completed request with the same key returns 409 with code 12000 (IDEMPOTENCY_KEY_ALREADY_USED) instead of charging again; one still running returns 409 with code 12002. A request that ended in an error can be sent again with the same key and body. Use a new key for each new retry attempt.

Parameters:

  • String orderId (required): Order id.

  • String idempotencyKey (required): UUID idempotency key for safe retries of this operation.

Implementation

Future<OrderPaymentRetryResult?> ordersRetryPayment(String orderId, String idempotencyKey, { Future<void>? abortTrigger, }) async {
  final response = await ordersRetryPaymentWithHttpInfo(orderId, idempotencyKey, abortTrigger: abortTrigger,);
  if (response.statusCode >= HttpStatus.badRequest) {
    throw ApiException(response.statusCode, await _decodeBodyBytes(response));
  }
  // When a remote server returns no body with a status of 204, we shall not decode it.
  // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
  // FormatException when trying to decode an empty string.
  if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
    return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'OrderPaymentRetryResult',) as OrderPaymentRetryResult;

  }
  return null;
}