// Create a billing plan and subscribe to it public IActionResult Subscribe() { var plan = PayPalSubscriptionsService.CreateBillingPlan("Tuts+ Plan", "Test plan for this article", GetBaseUrl()); var subscription = PayPalSubscriptionsService.CreateBillingAgreement(plan.id, new PayPal.Api.ShippingAddress { city = "London", line1 = "line 1", postal_code = "SW1A 1AA", country_code = "GB" }, "Pedro Alonso", "Tuts+", DateTime.Now); return(Redirect(subscription.GetApprovalUrl())); }
// Create a billing plan and subscribe to it public async Task <IActionResult> Subscribe() { var plan = await PayPalSubscriptionsService.CreateBillingPlan("Tuts+ Plan", "Test plan for this article", GetBaseUrl()); //active the plan await PayPalSubscriptionsService.ActivateBillingPlan(plan.Id); var subscription = await PayPalSubscriptionsService.CreateBillingAgreement(plan.Id, new PayPal.v1.BillingAgreements.SimplePostalAddress { City = "London", Line1 = "line 1", PostalCode = "SW1A 1AA", CountryCode = "GB" }, "Pedro Alonso", "Tuts+", DateTime.Now); var redirectUrl = subscription.Links.FirstOrDefault(f => f.Rel == "approval_url").Href; return(Redirect(redirectUrl)); }