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 diff --git a/.github/workflows/test_deploy_samplesite.yml b/.github/workflows/test_deploy_samplesite.yml index 3c9ce6c33c..845a2395ea 100644 --- a/.github/workflows/test_deploy_samplesite.yml +++ b/.github/workflows/test_deploy_samplesite.yml @@ -61,9 +61,17 @@ 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 + if: ${{ always() }} + with: + name: 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 if: ${{ always() }} uses: LouisBrunner/checks-action@v2.0.0 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 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/Sample.AspNetCore.csproj b/src/Samples/Sample.AspNetCore/Sample.AspNetCore.csproj index 46328220fd..855088b072 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/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(); 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 @@ - + diff --git a/src/SwedbankPay.Sdk.Tests/SwedbankPay.Sdk.Tests.csproj b/src/SwedbankPay.Sdk.Tests/SwedbankPay.Sdk.Tests.csproj index aa3d4340bc..fde3a02c40 100644 --- a/src/SwedbankPay.Sdk.Tests/SwedbankPay.Sdk.Tests.csproj +++ b/src/SwedbankPay.Sdk.Tests/SwedbankPay.Sdk.Tests.csproj @@ -14,7 +14,7 @@ - + @@ -22,7 +22,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all