updateOrder method

Future<void> updateOrder(
  1. String id,
  2. List<Patch> patchRequests
)

Updates an order with a CREATED or APPROVED status. You cannot update an order with the COMPLETED status.

To make an update, you must provide a reference_id. If you omit this value with an order that contains only one purchase unit, PayPal sets the value to default which enables you to use the path: "/purchase_units/@reference_id=='default'/{attribute-or-object}".

  • intent. Operations: replace
  • payer. Operations: replace, add. Notes: Using replace op for payer will replace the whole payer object with the value sent in request.
  • purchase_units. Operations: replace, add
  • purchase_units[].custom_id. Operations: replace, add, remove
  • purchase_units[].description. Operations: replace, add, remove
  • purchase_units[].payee.email. Operations: replace
  • purchase_units[].shipping.name. Operations: replace, add
  • purchase_units[].shipping.address. Operations: replace, add
  • purchase_units[].shipping.type. Operations: replace, add
  • purchase_units[].soft_descriptor. Operations: replace, remove
  • purchase_units[].amount. Operations: replace
  • purchase_units[].invoice_id. Operations: replace, add, remove
  • purchase_units[].payment_instruction. Operations: replace
  • purchase_units[].payment_instruction.disbursement_mode. Operations: replace
  • purchase_units[].payment_instruction.platform_fees. Operations: replace, add, remove. Notes: By default, disbursement_mode is INSTANT.

Implementation

Future<void> updateOrder(String id, List<Patch> patchRequests) async {
  var url = _payPalHttpClient.getUrl('/v2/checkout/orders/$id');

  var patchRequest = List.generate(
      patchRequests.length, (index) => patchRequests[index].toJson());

  var body = jsonEncode(patchRequest);

  await _payPalHttpClient.patch(url, body: body);
}