public async void TestPlansCreateRequest() { Product product1 = await ProductsCreateTest.CreateProductIfNotExists(ProductsCreateTest.ProductId1); var response = await CreatePlan(product1.Id, freeTrial : true, qtySupported : true); Assert.Equal(201, (int)response.StatusCode); Assert.NotNull(response.Result <Plan>()); Plan createdPlan = response.Result <Plan>(); Assert.NotNull(createdPlan.Id); Assert.NotNull(createdPlan.CreateTime); Assert.NotNull(createdPlan.Links); bool foundApproveURL = false; foreach (var linkDescription in createdPlan.Links) { if ("edit".Equals(linkDescription.Rel)) { foundApproveURL = true; Assert.NotNull(linkDescription.Href); Assert.Equal("PATCH", linkDescription.Method); Console.WriteLine(linkDescription.Href); } } Console.WriteLine(createdPlan.Id); Assert.True(foundApproveURL); }
public async void TestSubscriptionsCreateRequest() { Product product2 = await ProductsCreateTest.CreateProductIfNotExists(ProductsCreateTest.ProductId2); var planResponse = await PlansCreateTest.CreatePlan(product2.Id, freeTrial : true, qtySupported : true); Assert.Equal(201, (int)planResponse.StatusCode); Assert.NotNull(planResponse.Result <Plan>()); Plan createdPlan = planResponse.Result <Plan>(); var response = await CreateSubscription(createdPlan.Id); Assert.Equal(201, (int)response.StatusCode); Assert.NotNull(response.Result <Subscription>()); Subscription createdSubscription = response.Result <Subscription>(); Assert.NotNull(createdSubscription.Id); Assert.NotNull(createdSubscription.CreateTime); Assert.NotNull(createdSubscription.Links); bool foundApproveURL = false; foreach (var linkDescription in createdSubscription.Links) { if ("edit".Equals(linkDescription.Rel)) { foundApproveURL = true; Assert.NotNull(linkDescription.Href); Assert.Equal("PATCH", linkDescription.Method); Console.WriteLine(linkDescription.Href); } } Console.WriteLine(createdSubscription.Id); Assert.True(foundApproveURL); // - Get Subscription SubscriptionsGetRequest getRequest = new SubscriptionsGetRequest(createdSubscription.Id, fields: "last_failed_payment,plan"); var getResponse = await TestHarness.client().Execute(getRequest); Assert.Equal(200, (int)getResponse.StatusCode); Subscription getSubscription = getResponse.Result <Subscription>(); Assert.NotNull(getSubscription); Assert.NotNull(getSubscription.Plan); }