From b7a1ec4294bc909107dc213c5d5fe9eafe3d5957 Mon Sep 17 00:00:00 2001 From: fred Date: Thu, 7 Mar 2024 16:44:52 +0100 Subject: [PATCH 01/13] Updated readme for 3.1 (#618) * Updated readme for 3.1 * Updated readme * Updated readme * Remove dependabot status and build status from README The dependabot status badge and the build status section have been removed from the README.md file. This change was made to simplify the readme content and remove unnecessary details. --- README.md | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 5f36308b2d..1197cceac3 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,6 @@ [![NuGet downloads][nuget-downloads-badge]][nuget] [![CLA assistant][cla-badge]][cla] [![License][license-badge]][license] -[![Dependabot Status][dependabot-badge]][dependabot] [![Contributor Covenant][coc-badge]][coc] [`SwedbankPay.Sdk`][nuget] is a library that allows you to interact with @@ -23,23 +22,28 @@ supported as of yet by Swedbank Pay. It is provided as a convenience to speed up your development, so please feel free to play around. However, if you need support, please wait for a future, stable release. -## Build status - -| Platform | Status | -| -------- | --------------------------------------------------------------------- | -| Windows | [![Windows develop build status][azdo-win-badge]][azdo-win-link] | -| macOS | [![macOS develop build status][azdo-mac-badge]][azdo-mac-link] | -| Ubuntu | [![Ubuntu develop build status][azdo-ubuntu-badge]][azdo-ubuntu-link] | - -## Supported APIs - -- **Payment Order v3** - - create payment order - - get payment order - - capture - - cancel - - reversal - - abort +## Supported APIs Version 3.1 + +- **Payment Order** + - Create PaymentOrder + - GET PaymentOrder + - UpdateOrder + - Capture + - Cancel + - Reversal + - Abort +- **Tokens** + - Network Tokenization + - Get stored details + - Delete stored details + +## Use Cases + + - Subscriptions + - Verify + - Collect and store payment details for future usage. + - Collect and replace current payment details (Subscriptions) + - Instrument Mode (Build your own menu) ## Sample App From 66a0ed639e5b0f703f2d8cba52cea080e581d993 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 13 Mar 2024 02:12:01 +0000 Subject: [PATCH 02/13] Bump gittools/actions from 0 to 1 (#620) Bumps [gittools/actions](https://github.com/gittools/actions) from 0 to 1. - [Release notes](https://github.com/gittools/actions/releases) - [Commits](https://github.com/gittools/actions/compare/v0...v1) --- updated-dependencies: - dependency-name: gittools/actions dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/template_version.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/template_version.yml b/.github/workflows/template_version.yml index 7dd026f930..9317872c2f 100644 --- a/.github/workflows/template_version.yml +++ b/.github/workflows/template_version.yml @@ -19,10 +19,10 @@ jobs: fetch-depth: 0 - name: Install GitVersion - uses: gittools/actions/gitversion/setup@v0 + uses: gittools/actions/gitversion/setup@v1 with: versionSpec: '5.x' - name: Use GitVersion id: gitversion # step id used as reference for output values - uses: gittools/actions/gitversion/execute@v0 \ No newline at end of file + uses: gittools/actions/gitversion/execute@v1 \ No newline at end of file From 46b23193a69a8228148a305d7cb3b3a811908c04 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 13 Mar 2024 02:36:42 +0000 Subject: [PATCH 03/13] Bump Microsoft.Extensions.Logging.Abstractions from 8.0.0 to 8.0.1 (#622) Bumps [Microsoft.Extensions.Logging.Abstractions](https://github.com/dotnet/runtime) from 8.0.0 to 8.0.1. - [Release notes](https://github.com/dotnet/runtime/releases) - [Commits](https://github.com/dotnet/runtime/compare/v8.0.0...v8.0.1) --- updated-dependencies: - dependency-name: Microsoft.Extensions.Logging.Abstractions dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .../Sample.AspNetCore.csproj | 62 +++++++++---------- .../SwedbankPay.Sdk.Tests.csproj | 2 +- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/Samples/Sample.AspNetCore/Sample.AspNetCore.csproj b/src/Samples/Sample.AspNetCore/Sample.AspNetCore.csproj index 46328220fd..d4406265fc 100644 --- a/src/Samples/Sample.AspNetCore/Sample.AspNetCore.csproj +++ b/src/Samples/Sample.AspNetCore/Sample.AspNetCore.csproj @@ -1,32 +1,32 @@ - - - - net8.0 - 04B663D5-41D4-4161-92E7-970FC5A865A9 - - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - - - - - - - Always - - + + + + net8.0 + 04B663D5-41D4-4161-92E7-970FC5A865A9 + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + + + + Always + + \ No newline at end of file diff --git a/src/SwedbankPay.Sdk.Tests/SwedbankPay.Sdk.Tests.csproj b/src/SwedbankPay.Sdk.Tests/SwedbankPay.Sdk.Tests.csproj index aa3d4340bc..9817385e9d 100644 --- a/src/SwedbankPay.Sdk.Tests/SwedbankPay.Sdk.Tests.csproj +++ b/src/SwedbankPay.Sdk.Tests/SwedbankPay.Sdk.Tests.csproj @@ -14,7 +14,7 @@ - + From bd30e18c6ada9f88176bc753a1283f4acaa1519b Mon Sep 17 00:00:00 2001 From: Daniel Sundqvist Date: Tue, 19 Mar 2024 13:50:23 +0100 Subject: [PATCH 04/13] Update project reference properties in SwedbankPay.Sdk.Extensions.csproj (#628) This commit modifies the SwedbankPay.Sdk.Extensions.csproj to change the properties of the project reference to SwedbankPay.Sdk. Now, all the project's assets are marked as private to ensure they are not exposed or shared with other projects unintentionally. --- .../SwedbankPay.Sdk.Extensions.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SwedbankPay.Sdk.Extensions/SwedbankPay.Sdk.Extensions.csproj b/src/SwedbankPay.Sdk.Extensions/SwedbankPay.Sdk.Extensions.csproj index d724a7f595..fba4bc0ada 100644 --- a/src/SwedbankPay.Sdk.Extensions/SwedbankPay.Sdk.Extensions.csproj +++ b/src/SwedbankPay.Sdk.Extensions/SwedbankPay.Sdk.Extensions.csproj @@ -32,7 +32,7 @@ - + From 4cce85d805918b0e2f7c5d4428df2e11ceaf1b62 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 19 Mar 2024 13:02:53 +0000 Subject: [PATCH 05/13] Bump coverlet.collector from 6.0.1 to 6.0.2 (#621) Bumps [coverlet.collector](https://github.com/coverlet-coverage/coverlet) from 6.0.1 to 6.0.2. - [Release notes](https://github.com/coverlet-coverage/coverlet/releases) - [Commits](https://github.com/coverlet-coverage/coverlet/compare/v6.0.1...v6.0.2) --- updated-dependencies: - dependency-name: coverlet.collector dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- src/SwedbankPay.Sdk.Tests/SwedbankPay.Sdk.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SwedbankPay.Sdk.Tests/SwedbankPay.Sdk.Tests.csproj b/src/SwedbankPay.Sdk.Tests/SwedbankPay.Sdk.Tests.csproj index 9817385e9d..fde3a02c40 100644 --- a/src/SwedbankPay.Sdk.Tests/SwedbankPay.Sdk.Tests.csproj +++ b/src/SwedbankPay.Sdk.Tests/SwedbankPay.Sdk.Tests.csproj @@ -22,7 +22,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all From 0766d9a4eea61f0e14c6e8c8e3d7512a67a705a4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 19 Mar 2024 13:14:26 +0000 Subject: [PATCH 06/13] Bump Microsoft.EntityFrameworkCore.InMemory and Microsoft.EntityFrameworkCore (#624) Bumps [Microsoft.EntityFrameworkCore.InMemory](https://github.com/dotnet/efcore) and [Microsoft.EntityFrameworkCore](https://github.com/dotnet/efcore). These dependencies needed to be updated together. Updates `Microsoft.EntityFrameworkCore.InMemory` from 8.0.2 to 8.0.3 - [Release notes](https://github.com/dotnet/efcore/releases) - [Commits](https://github.com/dotnet/efcore/compare/v8.0.2...v8.0.3) Updates `Microsoft.EntityFrameworkCore` from 8.0.2 to 8.0.3 - [Release notes](https://github.com/dotnet/efcore/releases) - [Commits](https://github.com/dotnet/efcore/compare/v8.0.2...v8.0.3) --- updated-dependencies: - dependency-name: Microsoft.EntityFrameworkCore.InMemory dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: Microsoft.EntityFrameworkCore dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- src/Samples/Sample.AspNetCore/Sample.AspNetCore.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Samples/Sample.AspNetCore/Sample.AspNetCore.csproj b/src/Samples/Sample.AspNetCore/Sample.AspNetCore.csproj index d4406265fc..5db7aeab51 100644 --- a/src/Samples/Sample.AspNetCore/Sample.AspNetCore.csproj +++ b/src/Samples/Sample.AspNetCore/Sample.AspNetCore.csproj @@ -6,8 +6,8 @@ - - + + all From 92dc68b5ca49b57d675d3539aa7b0d73618d80a2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 19 Mar 2024 13:25:40 +0000 Subject: [PATCH 07/13] Bump Microsoft.Extensions.Http.Polly from 8.0.2 to 8.0.3 (#627) Bumps [Microsoft.Extensions.Http.Polly](https://github.com/dotnet/aspnetcore) from 8.0.2 to 8.0.3. - [Release notes](https://github.com/dotnet/aspnetcore/releases) - [Changelog](https://github.com/dotnet/aspnetcore/blob/main/docs/ReleasePlanning.md) - [Commits](https://github.com/dotnet/aspnetcore/compare/v8.0.2...v8.0.3) --- updated-dependencies: - dependency-name: Microsoft.Extensions.Http.Polly dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- src/Samples/Sample.AspNetCore/Sample.AspNetCore.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Samples/Sample.AspNetCore/Sample.AspNetCore.csproj b/src/Samples/Sample.AspNetCore/Sample.AspNetCore.csproj index 5db7aeab51..d4fbe42813 100644 --- a/src/Samples/Sample.AspNetCore/Sample.AspNetCore.csproj +++ b/src/Samples/Sample.AspNetCore/Sample.AspNetCore.csproj @@ -14,7 +14,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + From d52a34702022f6c9556f17dd85588b3ddf94129c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 19 Mar 2024 13:37:20 +0000 Subject: [PATCH 08/13] Bump Microsoft.EntityFrameworkCore.Tools from 8.0.2 to 8.0.3 (#630) Bumps [Microsoft.EntityFrameworkCore.Tools](https://github.com/dotnet/efcore) from 8.0.2 to 8.0.3. - [Release notes](https://github.com/dotnet/efcore/releases) - [Commits](https://github.com/dotnet/efcore/compare/v8.0.2...v8.0.3) --- updated-dependencies: - dependency-name: Microsoft.EntityFrameworkCore.Tools dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- src/Samples/Sample.AspNetCore/Sample.AspNetCore.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Samples/Sample.AspNetCore/Sample.AspNetCore.csproj b/src/Samples/Sample.AspNetCore/Sample.AspNetCore.csproj index d4fbe42813..9a2692bc44 100644 --- a/src/Samples/Sample.AspNetCore/Sample.AspNetCore.csproj +++ b/src/Samples/Sample.AspNetCore/Sample.AspNetCore.csproj @@ -9,7 +9,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive From d9d6b2124fddfb6005994970d376f68b6705610d Mon Sep 17 00:00:00 2001 From: Daniel Sundqvist Date: Tue, 19 Mar 2024 16:38:02 +0100 Subject: [PATCH 09/13] Add Cypress artifacts upload to test_deploy workflow The commit adds a new step in the GitHub Actions workflow file for the testing and deployment of SampleSite. Specifically, it introduces an upload action for Cypress screenshot artifacts. This means whenever tests are run by Cypress, related screenshots will automatically be uploaded, helping with debugging and review. --- .github/workflows/test_deploy_samplesite.yml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test_deploy_samplesite.yml b/.github/workflows/test_deploy_samplesite.yml index 3c9ce6c33c..67bfd4b208 100644 --- a/.github/workflows/test_deploy_samplesite.yml +++ b/.github/workflows/test_deploy_samplesite.yml @@ -61,9 +61,18 @@ jobs: wait-on: 'https://localhost:5001' browser: chrome env: - NODE_TLS_REJECT_UNAUTHORIZED: 0 - - + NODE_TLS_REJECT_UNAUTHORIZED: 0 + + + - name: Upload Cypress artifact + uses: actions/upload-artifact@v4 + # add the line below to store screenshots only on failures + # if: failure() + with: + name: cypress-screenshots + path: cypress/screenshots + if-no-files-found: ignore # 'warn' or 'error' are also available, defaults to `warn` + - name: Commit Action Status if: ${{ always() }} uses: LouisBrunner/checks-action@v2.0.0 From 4ffebe826f474e11633dbdb61e5ac61bcdb316d5 Mon Sep 17 00:00:00 2001 From: Daniel Sundqvist Date: Tue, 19 Mar 2024 21:13:29 +0100 Subject: [PATCH 10/13] Update Cypress artifact upload condition The condition for the Cypress artifact upload action has been updated in the GitHub workflow file. Previously, it was configured to store screenshots only on failure events. This has been changed to ensure screenshots are always stored, irrespective of the test results. --- .github/workflows/test_deploy_samplesite.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/test_deploy_samplesite.yml b/.github/workflows/test_deploy_samplesite.yml index 67bfd4b208..79b245657d 100644 --- a/.github/workflows/test_deploy_samplesite.yml +++ b/.github/workflows/test_deploy_samplesite.yml @@ -66,8 +66,7 @@ jobs: - name: Upload Cypress artifact uses: actions/upload-artifact@v4 - # add the line below to store screenshots only on failures - # if: failure() + if: ${{ always() }} with: name: cypress-screenshots path: cypress/screenshots From 4464b516bbf9f5cc18ee93d2a6c42d046ac39884 Mon Sep 17 00:00:00 2001 From: Daniel Sundqvist Date: Tue, 19 Mar 2024 21:40:30 +0100 Subject: [PATCH 11/13] Update path for cypress screenshots in workflow The path assigned for cypress screenshots in the test_deploy_samplesite workflow has been updated. It has been shifted from the generic cypress/screenshots location to a specific directory under ./src/Samples/Sample.AspNetCore.UiTests. This change helps in better organization and management of test snapshots. --- .github/workflows/test_deploy_samplesite.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_deploy_samplesite.yml b/.github/workflows/test_deploy_samplesite.yml index 79b245657d..845a2395ea 100644 --- a/.github/workflows/test_deploy_samplesite.yml +++ b/.github/workflows/test_deploy_samplesite.yml @@ -69,7 +69,7 @@ jobs: if: ${{ always() }} with: name: cypress-screenshots - path: cypress/screenshots + path: ./src/Samples/Sample.AspNetCore.UiTests/cypress/screenshots if-no-files-found: ignore # 'warn' or 'error' are also available, defaults to `warn` - name: Commit Action Status From f3afad11e96f0ee4759c2b078943c5bace04492e Mon Sep 17 00:00:00 2001 From: fred Date: Wed, 20 Mar 2024 08:20:19 +0100 Subject: [PATCH 12/13] Dynamic payer reference for sample site (#631) * Dynamic payer reference for sample site * increase timeout --------- Co-authored-by: Daniel Sundqvist --- .../creditcard/creditcard-e2e.spec.cy.js | 10 +++++----- .../Controllers/CheckOutController.cs | 8 +++++--- .../Controllers/PaymentController.cs | 9 ++++++--- .../Controllers/TokensController.cs | 7 +++++-- src/Samples/Sample.AspNetCore/PayerReference.cs | 14 ++++++++++++++ src/Samples/Sample.AspNetCore/Startup.cs | 3 +++ 6 files changed, 38 insertions(+), 13 deletions(-) create mode 100644 src/Samples/Sample.AspNetCore/PayerReference.cs diff --git a/src/Samples/Sample.AspNetCore.UiTests/cypress/e2e/paymentorder/creditcard/creditcard-e2e.spec.cy.js b/src/Samples/Sample.AspNetCore.UiTests/cypress/e2e/paymentorder/creditcard/creditcard-e2e.spec.cy.js index cffd4a30f9..86901bb931 100644 --- a/src/Samples/Sample.AspNetCore.UiTests/cypress/e2e/paymentorder/creditcard/creditcard-e2e.spec.cy.js +++ b/src/Samples/Sample.AspNetCore.UiTests/cypress/e2e/paymentorder/creditcard/creditcard-e2e.spec.cy.js @@ -14,7 +14,7 @@ describe('Pay with Credit card', () => { new SwedbankBlock().payWithSwedbank(PaymentMethods.card); - cy.get('h2', {timeout: 30000}).then(($h) => { + cy.get('h2', {timeout: 60000}).then(($h) => { expect($h).to.contain('Thanks!'); cy.getByAutomation('paymentorderlink').then(($paymentOrderLink) => { @@ -39,7 +39,7 @@ describe('Pay with Credit card', () => { new SwedbankBlock().payWithSwedbank(PaymentMethods.card); - cy.get('h2', {timeout: 30000}).then(($h) => { + cy.get('h2', {timeout: 60000}).then(($h) => { expect($h).to.contain('Thanks!'); cy.getByAutomation('paymentorderlink').then(($paymentOrderLink) => { @@ -111,7 +111,7 @@ describe('Pay with Credit card and Payment token', () => { let swedbankBlock = new SwedbankBlock(); swedbankBlock.payWithSwedbank(PaymentMethods.card); - cy.get('h2', {timeout: 30000}).then(($h) => { + cy.get('h2', {timeout: 60000}).then(($h) => { expect($h).to.contain('Thanks!'); cy.getByAutomation('paymentorderlink').then(($paymentOrderLink) => { @@ -136,7 +136,7 @@ describe('Pay with Credit card', () => { new SwedbankBlock().payWithSwedbank(PaymentMethods.card); - cy.get('h2', {timeout: 30000}).then(($h) => { + cy.get('h2', {timeout: 60000}).then(($h) => { expect($h).to.contain('Thanks!'); cy.getByAutomation('paymentorderlink').then(($paymentOrderLink) => { @@ -161,7 +161,7 @@ describe('Pay with Credit card', () => { new SwedbankBlock().payWithSwedbank(PaymentMethods.card); - cy.get('h2', {timeout: 30000}).then(($h) => { + cy.get('h2', {timeout: 60000}).then(($h) => { expect($h).to.contain('Thanks!'); cy.getByAutomation('paymentorderlink').then(($paymentOrderLink) => { diff --git a/src/Samples/Sample.AspNetCore/Controllers/CheckOutController.cs b/src/Samples/Sample.AspNetCore/Controllers/CheckOutController.cs index 26dc1f3328..835d5ad121 100644 --- a/src/Samples/Sample.AspNetCore/Controllers/CheckOutController.cs +++ b/src/Samples/Sample.AspNetCore/Controllers/CheckOutController.cs @@ -29,6 +29,7 @@ public class CheckOutController : Controller private readonly StoreDbContext _context; private readonly PayeeInfoConfig _payeeInfoOptions; private readonly ISwedbankPayClient _swedbankPayClient; + private readonly PayerReference _payerReference; private readonly UrlsOptions _urls; @@ -37,7 +38,8 @@ public CheckOutController(IOptionsSnapshot payeeInfoOptionsAcce Cart cart, ILogger logger, StoreDbContext storeDbContext, - ISwedbankPayClient payClient) + ISwedbankPayClient payClient, + PayerReference payerReference) { _payeeInfoOptions = payeeInfoOptionsAccessor.Value; _urls = urlsAccessor.Value; @@ -45,6 +47,7 @@ public CheckOutController(IOptionsSnapshot payeeInfoOptionsAcce _logger = logger; _context = storeDbContext; _swedbankPayClient = payClient; + _payerReference = payerReference; } public void Callback([FromBody] CallbackInfo callbackInfo) @@ -172,13 +175,12 @@ public async Task CreatePaymentOrder(bool? generatePaymen paymentOrderRequest.Metadata = null; paymentOrderRequest.GenerateRecurrenceToken = generateRecurrenceToken; paymentOrderRequest.GenerateUnscheduledToken = generateUnscheduledToken; - ; paymentOrderRequest.Payer = new Payer { FirstName = "Olivia", LastName = "Nyhuus", - PayerReference = "AB1234", + PayerReference = _payerReference.Id, Email = new EmailAddress("olivia.nyhuus@payex.com"), Msisdn = new Msisdn("+46739000001"), WorkPhoneNumber = new Msisdn("+4787654321"), diff --git a/src/Samples/Sample.AspNetCore/Controllers/PaymentController.cs b/src/Samples/Sample.AspNetCore/Controllers/PaymentController.cs index e4c498e48f..69c080af9e 100644 --- a/src/Samples/Sample.AspNetCore/Controllers/PaymentController.cs +++ b/src/Samples/Sample.AspNetCore/Controllers/PaymentController.cs @@ -29,6 +29,7 @@ public class PaymentController : Controller private readonly StoreDbContext _context; private readonly PayeeInfoConfig _payeeInfoOptions; private readonly ISwedbankPayClient _swedbankPayClient; + private readonly PayerReference _payerReference; private readonly UrlsOptions _urls; @@ -37,12 +38,14 @@ public PaymentController( Cart cart, StoreDbContext dbContext, ISwedbankPayClient payClient, - IOptionsSnapshot urlsAccessor) + IOptionsSnapshot urlsAccessor, + PayerReference payerReference) { _payeeInfoOptions = payeeInfoOptionsAccessor.Value; _cartService = cart; _context = dbContext; _swedbankPayClient = payClient; + _payerReference = payerReference; _urls = urlsAccessor.Value; } @@ -293,7 +296,7 @@ private async Task GetRecurringRequest(string description, OrderItems = orderItems.ToList(), Payer = new Payer { - PayerReference = "AB1234", + PayerReference = _payerReference.Id, } }; @@ -322,7 +325,7 @@ private async Task GetUnscheduledRequest(string description OrderItems = orderItems.ToList(), Payer = new Payer { - PayerReference = "AB1234", + PayerReference = _payerReference.Id, } }; diff --git a/src/Samples/Sample.AspNetCore/Controllers/TokensController.cs b/src/Samples/Sample.AspNetCore/Controllers/TokensController.cs index 045ed645c2..2e75febf09 100644 --- a/src/Samples/Sample.AspNetCore/Controllers/TokensController.cs +++ b/src/Samples/Sample.AspNetCore/Controllers/TokensController.cs @@ -19,14 +19,17 @@ public class TokensController : Controller private readonly ISwedbankPayClient _swedbankPayClient; private readonly ILogger _logger; private readonly Cart _cart; + private readonly PayerReference _payerReference; public TokensController(ISwedbankPayClient swedbankPayClient, ILogger logger, - Cart cart) + Cart cart, + PayerReference payerReference) { _swedbankPayClient = swedbankPayClient; _logger = logger; _cart = cart; + _payerReference = payerReference; } @@ -106,7 +109,7 @@ private async Task GetViewModel() try { - var tokenResponse = await _swedbankPayClient.PaymentOrders.GetOwnedTokens("AB1234"); + var tokenResponse = await _swedbankPayClient.PaymentOrders.GetOwnedTokens(_payerReference.Id); viewModel.Id = tokenResponse?.Id; viewModel.PayerReference = tokenResponse?.PayerReference; viewModel.Tokens = tokenResponse?.Tokens; diff --git a/src/Samples/Sample.AspNetCore/PayerReference.cs b/src/Samples/Sample.AspNetCore/PayerReference.cs new file mode 100644 index 0000000000..11b1e099a0 --- /dev/null +++ b/src/Samples/Sample.AspNetCore/PayerReference.cs @@ -0,0 +1,14 @@ +using System; + +namespace Sample.AspNetCore; + +public class PayerReference +{ + public PayerReference() + { + Id = Guid.NewGuid().ToString().Replace("-", ""); + } + + public string Id { get; } + +} \ No newline at end of file diff --git a/src/Samples/Sample.AspNetCore/Startup.cs b/src/Samples/Sample.AspNetCore/Startup.cs index d85d6f3648..de785e889a 100644 --- a/src/Samples/Sample.AspNetCore/Startup.cs +++ b/src/Samples/Sample.AspNetCore/Startup.cs @@ -80,6 +80,9 @@ public void ConfigureServices(IServiceCollection services) services.Configure(Configuration.GetSection("Urls")); services.AddScoped(provider => SessionCart.GetCart(provider)); + + services.AddSingleton(); + services.AddTransient(); services.AddSwedbankPayClient(swedBankPayOptions.ApiBaseUrl, swedBankPayOptions.Token); services.AddSession(); From 3c1580e9706e9503049d513c9e4abfaeae6a44de Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 20 Mar 2024 08:33:11 +0000 Subject: [PATCH 13/13] Bump Microsoft.EntityFrameworkCore.SqlServer from 8.0.2 to 8.0.3 (#629) Bumps [Microsoft.EntityFrameworkCore.SqlServer](https://github.com/dotnet/efcore) from 8.0.2 to 8.0.3. - [Release notes](https://github.com/dotnet/efcore/releases) - [Commits](https://github.com/dotnet/efcore/compare/v8.0.2...v8.0.3) --- updated-dependencies: - dependency-name: Microsoft.EntityFrameworkCore.SqlServer dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- src/Samples/Sample.AspNetCore/Sample.AspNetCore.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Samples/Sample.AspNetCore/Sample.AspNetCore.csproj b/src/Samples/Sample.AspNetCore/Sample.AspNetCore.csproj index 9a2692bc44..855088b072 100644 --- a/src/Samples/Sample.AspNetCore/Sample.AspNetCore.csproj +++ b/src/Samples/Sample.AspNetCore/Sample.AspNetCore.csproj @@ -8,7 +8,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive