Can we change Razorpay Status "Authorize" to "Capture" from flutter?

273 Views Asked by At

Is it possible to change Razorpay Status from Flutter?

I am using razorpay for my app and after getting success status the the status of Razorpay payment is "Authorized". I need to change this status to "Captured".

1

There are 1 best solutions below

10
On

Yes, you can use capture API /payments/:id/capture for converting the status. source

import 'package:http/http.dart' as http;
import 'dart:convert';

final paymentId = 'your_payment_id';

final apiKey = 'your_razorpay_api_key';

final url = 'https://api.razorpay.com/v1/payments/$paymentId/capture';

final response = await http.post(
  Uri.parse(url),
  headers: {
    'Authorization': 'Basic ' + base64Encode(utf8.encode('$apiKey:')),
    'Content-Type': 'application/json',
  },
);

if (response.statusCode == 200) {
  // Payment captured successfully
} else {
  // Error occurred while capturing payment
}