createPlan method
Creates a plan that defines pricing and billing cycle details for subscriptions.
Parameter planRequest: The create plan request object
Parameter paypalRequestId: The server stores keys for 72 hours.
Implementation
Future<Plan> createPlan(
PlanRequest planRequest, {
String? payPalRequestId,
}) async {
var url = _payPalHttpClient.getUrl('/v1/billing/plans');
var headers =
payPalRequestId != null ? {'PayPal-Request-Id': payPalRequestId} : null;
var body = jsonEncode(planRequest.toJson());
var response =
await _payPalHttpClient.post(url, headers: headers, body: body);
return Plan.fromJson(jsonDecode(response.body));
}