cancelCharge method
Cancels a charge that has been previously created. Supply the unique charge code that was returned when the charge was created. Note: Only new charges can be successfully canceled. Once payment is detected, charge can no longer be canceled.
Implementation
Future<ChargeObject> cancelCharge(String code) async {
ChargeObject coinbaseResponse;
Map data;
Map response = await postToDB(
body: {},
apiKey: _apiKey,
api: 'https://api.commerce.coinbase.com/charges/$code/cancel',
);
if (response.containsKey('error')) {
data = response['error'];
} else {
data = response['data'];
}
coinbaseResponse = ChargeObject().fromJson(data);
Logger(debug).displayLog(coinbaseResponse.toString());
return coinbaseResponse;
}