captureAuthorizedPaymentOnSubscription method
Future<Transaction>
captureAuthorizedPaymentOnSubscription(
- String subscriptionId,
- SubscriptionCaptureRequest request, {
- String? payPalRequestId,
Captures an authorized payment from the subscriber on the subscription.
Parameter subscriptionId: The ID of the subscription
Parameter request: The subscription capture request
Parameter paypalRequestId: The server stores keys for 72 hours.
Implementation
Future<Transaction> captureAuthorizedPaymentOnSubscription(
String subscriptionId,
SubscriptionCaptureRequest request, {
String? payPalRequestId,
}) async {
var url = _payPalHttpClient
.getUrl('/v1/billing/subscriptions/$subscriptionId/capture');
var headers =
payPalRequestId != null ? {'PayPal-Request-Id': payPalRequestId} : null;
var body = jsonEncode(request.toJson());
var response =
await _payPalHttpClient.post(url, headers: headers, body: body);
return Transaction.fromJson(jsonDecode(response.body));
}