Skip to content

Commit

Permalink
Merge pull request #632 from SwedbankPay/release/4.0.1
Browse files Browse the repository at this point in the history
Release/4.0.1
  • Loading branch information
zunkas authored Apr 2, 2024
2 parents 58c0a61 + 57d20bf commit 1cca999
Show file tree
Hide file tree
Showing 12 changed files with 107 additions and 70 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/template_version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
uses: gittools/actions/gitversion/execute@v1
14 changes: 11 additions & 3 deletions .github/workflows/test_deploy_samplesite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
40 changes: 22 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -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) => {
Expand Down Expand Up @@ -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) => {
Expand All @@ -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) => {
Expand All @@ -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) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;


Expand All @@ -37,14 +38,16 @@ public CheckOutController(IOptionsSnapshot<PayeeInfoConfig> payeeInfoOptionsAcce
Cart cart,
ILogger<CheckOutController> logger,
StoreDbContext storeDbContext,
ISwedbankPayClient payClient)
ISwedbankPayClient payClient,
PayerReference payerReference)
{
_payeeInfoOptions = payeeInfoOptionsAccessor.Value;
_urls = urlsAccessor.Value;
_cartService = cart;
_logger = logger;
_context = storeDbContext;
_swedbankPayClient = payClient;
_payerReference = payerReference;
}

public void Callback([FromBody] CallbackInfo callbackInfo)
Expand Down Expand Up @@ -172,13 +175,12 @@ public async Task<IPaymentOrderResponse> 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"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;


Expand All @@ -37,12 +38,14 @@ public PaymentController(
Cart cart,
StoreDbContext dbContext,
ISwedbankPayClient payClient,
IOptionsSnapshot<UrlsOptions> urlsAccessor)
IOptionsSnapshot<UrlsOptions> urlsAccessor,
PayerReference payerReference)
{
_payeeInfoOptions = payeeInfoOptionsAccessor.Value;
_cartService = cart;
_context = dbContext;
_swedbankPayClient = payClient;
_payerReference = payerReference;
_urls = urlsAccessor.Value;
}

Expand Down Expand Up @@ -293,7 +296,7 @@ private async Task<PaymentOrderRequest> GetRecurringRequest(string description,
OrderItems = orderItems.ToList(),
Payer = new Payer
{
PayerReference = "AB1234",
PayerReference = _payerReference.Id,
}
};

Expand Down Expand Up @@ -322,7 +325,7 @@ private async Task<PaymentOrderRequest> GetUnscheduledRequest(string description
OrderItems = orderItems.ToList(),
Payer = new Payer
{
PayerReference = "AB1234",
PayerReference = _payerReference.Id,
}
};

Expand Down
7 changes: 5 additions & 2 deletions src/Samples/Sample.AspNetCore/Controllers/TokensController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,17 @@ public class TokensController : Controller
private readonly ISwedbankPayClient _swedbankPayClient;
private readonly ILogger<TokensController> _logger;
private readonly Cart _cart;
private readonly PayerReference _payerReference;

public TokensController(ISwedbankPayClient swedbankPayClient,
ILogger<TokensController> logger,
Cart cart)
Cart cart,
PayerReference payerReference)
{
_swedbankPayClient = swedbankPayClient;
_logger = logger;
_cart = cart;
_payerReference = payerReference;
}


Expand Down Expand Up @@ -106,7 +109,7 @@ private async Task<TokenViewModel> 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;
Expand Down
14 changes: 14 additions & 0 deletions src/Samples/Sample.AspNetCore/PayerReference.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;

namespace Sample.AspNetCore;

public class PayerReference
{
public PayerReference()
{
Id = Guid.NewGuid().ToString().Replace("-", "");
}

public string Id { get; }

}
62 changes: 31 additions & 31 deletions src/Samples/Sample.AspNetCore/Sample.AspNetCore.csproj
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<UserSecretsId>04B663D5-41D4-4161-92E7-970FC5A865A9</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="8.0.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\SwedbankPay.Sdk.Extensions\SwedbankPay.Sdk.Extensions.csproj" />
<ProjectReference Include="..\..\SwedbankPay.Sdk\SwedbankPay.Sdk.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="appsettings.json">
<CopyToPublishDirectory>Always</CopyToPublishDirectory>
</None>
</ItemGroup>
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<UserSecretsId>04B663D5-41D4-4161-92E7-970FC5A865A9</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="8.0.3" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\SwedbankPay.Sdk.Extensions\SwedbankPay.Sdk.Extensions.csproj" />
<ProjectReference Include="..\..\SwedbankPay.Sdk\SwedbankPay.Sdk.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="appsettings.json">
<CopyToPublishDirectory>Always</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>
3 changes: 3 additions & 0 deletions src/Samples/Sample.AspNetCore/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ public void ConfigureServices(IServiceCollection services)

services.Configure<UrlsOptions>(Configuration.GetSection("Urls"));
services.AddScoped(provider => SessionCart.GetCart(provider));

services.AddSingleton<PayerReference>();

services.AddTransient<IHttpContextAccessor, HttpContextAccessor>();
services.AddSwedbankPayClient(swedBankPayOptions.ApiBaseUrl, swedBankPayOptions.Token);
services.AddSession();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

<ItemGroup>
<ProjectReference Include="..\SwedbankPay.Sdk.Infrastructure\SwedbankPay.Sdk.Infrastructure.csproj" />
<ProjectReference Include="..\SwedbankPay.Sdk\SwedbankPay.Sdk.csproj" />
<ProjectReference Include="..\SwedbankPay.Sdk\SwedbankPay.Sdk.csproj" PrivateAssets="All" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions src/SwedbankPay.Sdk.Tests/SwedbankPay.Sdk.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="8.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="xunit" Version="2.7.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.7">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.1">
<PackageReference Include="coverlet.collector" Version="6.0.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down

0 comments on commit 1cca999

Please sign in to comment.