updateCheckout method

Future<CheckoutObject> updateCheckout({
  1. required String checkoutID,
  2. required String description,
  3. required String name,
  4. int? amount,
  5. required PricingType pricingType,
  6. required CurrencyType currency,
})

Updates a previously updated checkout. amount amount to be charged.

name name of what you are charging for

description describe the good or service

pricingType indicate if there is a fixed price or no fixed price

currency optional value to use. only important when the priceType is PriceType.fixed

Implementation

/// [amount] 	amount to be charged.
///
/// [name] name of what you are charging for
///
/// [description] describe the good or service
///
/// [pricingType] indicate if there is a fixed price or no fixed price
///
/// [currency] optional value to use. only important when the [priceType] is [PriceType.fixed]
Future<CheckoutObject> updateCheckout(
    {required String checkoutID,
    required String description,
    required String name,
    int? amount,
    required PricingType pricingType,
    required CurrencyType currency}) async {
  CheckoutObject coinbaseResponse;
  Map data;
  Map<String, dynamic> body = {
    "name": name,
    "description": description,
    "pricing_type": getPricingType(pricingType),
    "requested_info": ['email', 'name']
  };
  if (pricingType == PricingType.fixedPrice) {
    assert(amount != null);
    body["local_price"] = {
      "amount": amount,
      "currency": getCurrency(currency)
    };
  }
  Map response = await putOnDB(
      api: 'https://api.commerce.coinbase.com/checkouts/$checkoutID',
      apiKey: _apiKey,
      body: body);
  if (response.containsKey('error')) {
    data = response['error'];
  } else {
    data = response['data'];
  }
  coinbaseResponse = CheckoutObject.fromJson(data);
  Logger(debug).displayLog(coinbaseResponse.toString());
  return coinbaseResponse;
}