public async Task can_create_a_checkout() { var requestInfo = @"""email"""; SetupServerSingleResponse(Examples.CheckoutWithRequestInfo(requestInfo)); var newCheckout = new CreateCheckout { Name = "The Sovereign Individual", Description = "Mastering the Transition to the Information Age", LocalPrice = new Money { Amount = 100.00m, Currency = "USD" }, PricingType = PricingType.FixedPrice, RequestEmail = true }; var checkout = await com.CreateCheckoutAsync(newCheckout); var truth = new Response <Checkout> { Data = Examples.CheckoutModel }; truth.Data.RequestedInfo.Add("email"); truth.Should().BeEquivalentTo(checkout); server.ShouldHaveCalled("https://api.commerce.coinbase.com/checkouts") .WithVerb(HttpMethod.Post); }
public async Task can_update_a_checkout() { var requestInfo = @"""email"""; SetupServerSingleResponse(Examples.CheckoutWithRequestInfo(requestInfo)); var updateCheckout = new UpdateCheckout { LocalPrice = new Money { Amount = 200.00m, Currency = "USD" } }; var update = await com.UpdateCheckoutAsync(Examples.CheckoutModel.Id, updateCheckout); var truth = new Response <Checkout> { Data = Examples.CheckoutModel }; truth.Data.RequestedInfo.Add("email"); truth.Should().BeEquivalentTo(update); server.ShouldHaveCalled($"https://api.commerce.coinbase.com/checkouts/{Examples.CheckoutModel.Id}") .WithVerb(HttpMethod.Put); }
public async Task can_create_a_charge() { var metadata = @"{ ""customer_id"": ""id_1005"", ""customer_name"": ""Satoshi Nakamoto"" }"; SetupServerSingleResponse(Examples.ChargeWithMetadata(metadata)); var newCharge = new CreateCharge { Name = "The Sovereign Individual", Description = "Mastering the Transition to the Information Age", LocalPrice = new Money { Amount = 100.00m, Currency = "USD" }, PricingType = PricingType.FixedPrice, Metadata = new JObject { { "customer_id", "id_1005" }, { "customer_name", "Satoshi Nakamoto" } } }; var charge = await com.CreateChargeAsync(newCharge); var truth = new Response <Charge> { Data = Examples.ChargeModel }; truth.Data.Metadata = newCharge.Metadata; charge.Should().BeEquivalentTo(truth); server.ShouldHaveCalled("https://api.commerce.coinbase.com/charges") .WithVerb(HttpMethod.Post); }