capture method
Future<Response<RazorpayPayment> >
capture({
- required String paymentId,
- required dynamic amount,
- required String currency,
- void callback(
- RazorpayApiException?,
- Response<
RazorpayPayment> ?
Capture payment
@param paymentId - The unique identifier of the payment. @param amount - The amount to be captured (should be equal to the authorised amount, in the smallest unit of the chosen currency). @param currency - ISO code of the currency in which the payment was made.
Implementation
Future<Response<RazorpayPayment>> capture({
required String paymentId,
required dynamic amount, // number | string
required String currency,
void Function(RazorpayApiException?, Response<RazorpayPayment>?)? callback,
}) async {
if (paymentId.isEmpty) {
throw ArgumentError(ID_REQUIRED_MSG);
}
// Amount validation happens implicitly via model or API
final payload = {
'amount': amount,
'currency': currency,
};
return api.post<RazorpayPayment>(
{
'url': '$BASE_URL/$paymentId/capture',
'data': payload,
},
fromJsonFactory: RazorpayPayment.fromJson,
callback: callback,
);
}