diff --git a/src/GroundsForSupport.Client/package-lock.json b/src/GroundsForSupport.Client/package-lock.json index be14638..8dfdda5 100644 --- a/src/GroundsForSupport.Client/package-lock.json +++ b/src/GroundsForSupport.Client/package-lock.json @@ -8,6 +8,8 @@ "name": "groundsforsupport-client", "version": "0.0.0", "dependencies": { + "@stripe/react-stripe-js": "^5.4.1", + "@stripe/stripe-js": "^8.6.0", "react": "^19.2.0", "react-dom": "^19.2.0" }, @@ -1123,6 +1125,29 @@ "dev": true, "license": "MIT" }, + "node_modules/@stripe/react-stripe-js": { + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/@stripe/react-stripe-js/-/react-stripe-js-5.4.1.tgz", + "integrity": "sha512-ipeYcAHa4EPmjwfv0lFE+YDVkOQ0TMKkFWamW+BqmnSkEln/hO8rmxGPPWcd9WjqABx6Ro8Xg4pAS7evCcR9cw==", + "license": "MIT", + "dependencies": { + "prop-types": "^15.7.2" + }, + "peerDependencies": { + "@stripe/stripe-js": ">=8.0.0 <9.0.0", + "react": ">=16.8.0 <20.0.0", + "react-dom": ">=16.8.0 <20.0.0" + } + }, + "node_modules/@stripe/stripe-js": { + "version": "8.6.0", + "resolved": "https://registry.npmjs.org/@stripe/stripe-js/-/stripe-js-8.6.0.tgz", + "integrity": "sha512-EB0/GGgs4hfezzkiMkinlRgWtjz8fSdwVQhwYS7Sg/RQrSvuNOz+ssPjD+lAzqaYTCB0zlbrt0fcqVziLJrufQ==", + "license": "MIT", + "engines": { + "node": ">=12.16" + } + }, "node_modules/@testing-library/dom": { "version": "10.4.1", "resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-10.4.1.tgz", @@ -2851,7 +2876,6 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", - "dev": true, "license": "MIT" }, "node_modules/js-yaml": { @@ -3262,6 +3286,18 @@ "dev": true, "license": "MIT" }, + "node_modules/loose-envify": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", + "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", + "license": "MIT", + "dependencies": { + "js-tokens": "^3.0.0 || ^4.0.0" + }, + "bin": { + "loose-envify": "cli.js" + } + }, "node_modules/lru-cache": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", @@ -3403,6 +3439,15 @@ "dev": true, "license": "MIT" }, + "node_modules/object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/obug": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/obug/-/obug-2.1.1.tgz", @@ -3620,6 +3665,23 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, + "node_modules/prop-types": { + "version": "15.8.1", + "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz", + "integrity": "sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==", + "license": "MIT", + "dependencies": { + "loose-envify": "^1.4.0", + "object-assign": "^4.1.1", + "react-is": "^16.13.1" + } + }, + "node_modules/prop-types/node_modules/react-is": { + "version": "16.13.1", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", + "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==", + "license": "MIT" + }, "node_modules/punycode": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", diff --git a/src/GroundsForSupport.Client/package.json b/src/GroundsForSupport.Client/package.json index 04f08ca..d9c8a5e 100644 --- a/src/GroundsForSupport.Client/package.json +++ b/src/GroundsForSupport.Client/package.json @@ -12,6 +12,8 @@ "test": "vitest --coverage" }, "dependencies": { + "@stripe/react-stripe-js": "^5.4.1", + "@stripe/stripe-js": "^8.6.0", "react": "^19.2.0", "react-dom": "^19.2.0" }, diff --git a/src/GroundsForSupport.Server/GroundsForSupport.Server.csproj b/src/GroundsForSupport.Server/GroundsForSupport.Server.csproj index f5531b4..7b6b496 100644 --- a/src/GroundsForSupport.Server/GroundsForSupport.Server.csproj +++ b/src/GroundsForSupport.Server/GroundsForSupport.Server.csproj @@ -8,6 +8,7 @@ + diff --git a/src/GroundsForSupport.Server/Program.cs b/src/GroundsForSupport.Server/Program.cs index ed49d31..45b5c9e 100644 --- a/src/GroundsForSupport.Server/Program.cs +++ b/src/GroundsForSupport.Server/Program.cs @@ -9,6 +9,23 @@ if (app.Environment.IsDevelopment()) app.MapOpenApi(); } +// We need a /create-payment-intent endpoint + +app.MapPost("/create-payment-intent", static () => +{ + // we need to get the amount and email + // from the frontend + + // we need to validate the amount and email + + // we are going to use the Stripe API to create + // a payment intent + + // return the secret for that intent + // to the frontend + return Results.Ok("Hello"); +}); + app.UseDefaultFiles(); app.UseStaticFiles(); diff --git a/tests/GroundsForSupport.Server.Tests/ExampleTests.cs b/tests/GroundsForSupport.Server.Tests/ExampleTests.cs deleted file mode 100644 index 7f219a9..0000000 --- a/tests/GroundsForSupport.Server.Tests/ExampleTests.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace GroundsForSupport.Server.Tests; - -public class ExampleTests -{ - [Fact] - public void SampleTest() - { - Assert.True(true); - } -} \ No newline at end of file diff --git a/tests/GroundsForSupport.Server.Tests/GroundsForSupport.API.Tests.csproj b/tests/GroundsForSupport.Server.Tests/GroundsForSupport.API.Tests.csproj index 6e71ac6..31a8799 100644 --- a/tests/GroundsForSupport.Server.Tests/GroundsForSupport.API.Tests.csproj +++ b/tests/GroundsForSupport.Server.Tests/GroundsForSupport.API.Tests.csproj @@ -14,6 +14,7 @@ + @@ -26,6 +27,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all + diff --git a/tests/GroundsForSupport.Server.Tests/Integration/Infra/TestApi.cs b/tests/GroundsForSupport.Server.Tests/Integration/Infra/TestApi.cs new file mode 100644 index 0000000..913d514 --- /dev/null +++ b/tests/GroundsForSupport.Server.Tests/Integration/Infra/TestApi.cs @@ -0,0 +1,7 @@ +using Microsoft.AspNetCore.Mvc.Testing; + +namespace GroundsForSupport.API.Tests.Integration.Infra; + +public sealed class TestApi : WebApplicationFactory +{ +} diff --git a/tests/GroundsForSupport.Server.Tests/Integration/PaymentTests.cs b/tests/GroundsForSupport.Server.Tests/Integration/PaymentTests.cs new file mode 100644 index 0000000..5651db7 --- /dev/null +++ b/tests/GroundsForSupport.Server.Tests/Integration/PaymentTests.cs @@ -0,0 +1,25 @@ +using System.Net; +using System.Net.Http.Json; +using GroundsForSupport.API.Tests.Integration.Infra; + +namespace GroundsForSupport.API.Tests.Integration; + +public sealed class PaymentTests(TestApi api) : IClassFixture +{ + private readonly TestApi _api = api; + + [Fact] + public async Task CreatePaymentIntent_WhenGivenInvalidAmount_ItShouldReturnBadRequest() + { + var client = _api.CreateClient(); + + var request = new { + amount = 0, + email = string.Empty, + }; + + var response = await client.PostAsJsonAsync("/create-payment-intent", request, TestContext.Current.CancellationToken); + + response.StatusCode.Should().Be(HttpStatusCode.BadRequest); + } +} \ No newline at end of file