reauthorizeAuthorizedPayment method

Future<Authorization> reauthorizeAuthorizedPayment(
  1. String authorizationId,
  2. Money amount, {
  3. String? payPalRequestId,
  4. Prefer? prefer,
})

Reauthorizes an authorized PayPal account payment, by ID. To ensure that funds are still available, reauthorize a payment after its initial three-day honor period expires. Within the 29-day authorization period, you can issue multiple re-authorizations after the honor period expires.

If 30 days have transpired since the date of the original authorization, you must create an authorized payment instead of reauthorizing the original authorized payment.

A reauthorized payment itself has a new honor period of three days.

You can reauthorize an authorized payment once for up to 115% of the original authorized amount, not to exceed an increase of $75 USD.

Supports only the amount request parameter.

Note: This request is currently not supported for Partner use cases.

Parameter authorizationId: The PayPal-generated ID for the authorized payment to reauthorize.

Parameter amount: The amount to reauthorize for an authorized payment.

Parameter payPalRequestId: The server stores keys for 45 days.

Parameter prefer: 'minimal', The server returns a minimal response to optimize communication between the API caller and the server. A minimal response includes the id, status and HATEOAS links. 'representation', The server returns a complete resource representation, including the current state of the resource.

Implementation

Future<Authorization> reauthorizeAuthorizedPayment(
  String authorizationId,
  Money amount, {
  String? payPalRequestId,
  Prefer? prefer,
}) async {
  var url = _payPalHttpClient.getUrl(
    '/v2/payments/authorizations/$authorizationId/reauthorize',
  );

  Map<String, String> headers = {};

  if (prefer != null) {
    headers['Prefer'] = preferTypeEnumMap[prefer]!;
  }

  if (payPalRequestId != null) {
    headers['PayPal-Request-Id'] = payPalRequestId;
  }

  var body = jsonEncode(amount.toJson());
  var response =
      await _payPalHttpClient.post(url, headers: headers, body: body);
  return Authorization.fromJson(jsonDecode(response.body));
}