Skip to content

Commit

Permalink
Merge pull request #569 from SwedbankPay/release/3.3.0
Browse files Browse the repository at this point in the history
Release/3.3.0
  • Loading branch information
zunkas authored Feb 27, 2023
2 parents a4c329c + 8c1d43e commit bc486b4
Show file tree
Hide file tree
Showing 54 changed files with 622 additions and 229 deletions.
2 changes: 1 addition & 1 deletion .github/mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ queue_rules:
- name: default
conditions:
# Conditions to get out of the queue (= merged)
- check-success=build
- check-success=Run Unit and UI tests
- check-success=license/cla

pull_request_rules:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/deploy_pro_package_samplesite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ jobs:
with:
workflow_conclusion: success
run_id: ${{ github.event.workflow_run.id }}
name: packages
path: packages

- name: Publish to nuget
run: dotnet nuget push packages/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }} --skip-duplicate
Expand Down
11 changes: 7 additions & 4 deletions .github/workflows/template_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
- uses: actions/checkout@v3

- name: Setup .NET
uses: actions/setup-dotnet@v3.0.0
uses: actions/setup-dotnet@v3.0.3
with:
dotnet-version: ${{ env.dotnetVersion }}

Expand Down Expand Up @@ -83,7 +83,7 @@ jobs:
./src/Samples/Sample.AspNetCore.SystemTests/chrome-driver-udpate.ps1
- name: Publish Sdk Sample site system test
run: dotnet publish --configuration ${{ inputs.Configuration }} -p:Version=${{ inputs.nuGetVersionV2 }} --no-restore ${{ inputs.SystemTestsCsprojPath }} --output '${{ env.AZURE_WEBAPP_PACKAGE_PATH }}/systemtests' --os win
run: dotnet publish --configuration ${{ inputs.Configuration }} -p:Version=${{ inputs.nuGetVersionV2 }} ${{ inputs.SystemTestsCsprojPath }} --output '${{ env.AZURE_WEBAPP_PACKAGE_PATH }}/systemtests' --os win

- name: Copy wwwroot to publish directory
shell: pwsh
Expand All @@ -96,8 +96,11 @@ jobs:
name: Sample.AspNetCore.SystemTests
path: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}/systemtests

- name: Nuget pack
run: dotnet pack ${{ inputs.SlnPath }} -p:PackageVersion=${{ inputs.NUGETVERSIONV2 }} -p:Version=${{ inputs.NUGETVERSIONV2 }} --no-restore --configuration=${{ inputs.Configuration }} --output=artifacts
- name: Nuget pack SwedbankPay.Sdk
run: dotnet pack ./src/SwedbankPay.Sdk.Infrastructure/SwedbankPay.Sdk.Infrastructure.csproj -p:PackageVersion=${{ inputs.NUGETVERSIONV2 }} -p:Version=${{ inputs.NUGETVERSIONV2 }} --no-restore --configuration=${{ inputs.Configuration }} --output=artifacts

- name: Nuget pack SwedbankPay.Sdk.Extensions
run: dotnet pack ./src/SwedbankPay.Sdk.Extensions/SwedbankPay.Sdk.Extensions.csproj -p:PackageVersion=${{ inputs.NUGETVERSIONV2 }} -p:Version=${{ inputs.NUGETVERSIONV2 }} --no-restore --configuration=${{ inputs.Configuration }} --output=artifacts

- name: Archive nuget packages artifacts
uses: actions/upload-artifact@v3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/template_version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- uses: actions/checkout@v3

- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0.9.13
uses: gittools/actions/gitversion/setup@v0.9.15
with:
versionSpec: '5.x.x'

Expand All @@ -26,4 +26,4 @@ jobs:

- name: Use GitVersion
id: gitversion # step id used as reference for output values
uses: gittools/actions/gitversion/execute@v0.9.13
uses: gittools/actions/gitversion/execute@v0.9.15
6 changes: 3 additions & 3 deletions .github/workflows/test_deploy_samplesite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
run_id: ${{ github.event.workflow_run.id }}

- name: Setup .NET
uses: actions/setup-dotnet@v3.0.0
uses: actions/setup-dotnet@v3.0.3
with:
dotnet-version: ${{ env.dotnetVersion }}

Expand All @@ -66,7 +66,7 @@ jobs:

- name: Commit Action Status
if: ${{ always() }}
uses: LouisBrunner/checks-action@v1.3.1
uses: LouisBrunner/checks-action@v1.5.0
with:
sha: ${{ steps.source-run-info.outputs.sourceHeadSha }}
token: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -91,7 +91,7 @@ jobs:
path: packages

- name: Publish test package to GitHub Package Registry
run: dotnet nuget push "packages/*.nupkg" --api-key ${{secrets.GITHUB_TOKEN}} --source https://nuget.pkg.github.com/sveawebpay/index.json --skip-duplicate
run: dotnet nuget push "packages/*.nupkg" --api-key ${{secrets.GITHUB_TOKEN}} --source https://nuget.pkg.github.com/swedbankpay/index.json --skip-duplicate

publish_sample_site:
needs: [test-unit-ui]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,8 @@ public class ActionRow : TableRow<_>

[FindByAutomation("div", "div-orders")]
public ItemsControl<OrderItem, _> Orders { get; set; }

[FindByClass("alert-success")]
public Text<_> SuccessMessage { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ public class LocalPaymentMenuPage : Page<_>
[FindById("trustly")]
public Button<_> Trustly { get; private set; }

[FindById("recurring")]
public Button<_> Recurring { get; private set; }

[WaitFor(Until.Visible, TriggerEvents.BeforeAccess)]
public Frame<_> PaymentFrame { get; private set; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@
<ItemGroup>
<PackageReference Include="Atata" Version="2.2.0" />
<PackageReference Include="Atata.WebDriverExtras" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="6.0.9" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="6.0.10" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.*" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
<PackageReference Include="coverlet.collector" Version="3.1.2">
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.*" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
<PackageReference Include="coverlet.collector" Version="3.2.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1">
<PackageReference Include="NUnit3TestAdapter" Version="4.3.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Selenium.Firefox.WebDriver" Version="0.27.0" />
<PackageReference Include="Selenium.WebDriver" Version="4.5.0" />
<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="106.0.5249.6100" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="6.*" />
<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="110.0.5481.7700" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="7.*" />
</ItemGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ public static TOwner StoreValueAsUri<TOwner>(this UIComponent<TOwner> component,
return component.Owner;
}

public static string StorePaymentUri<TOwner>(this UIComponent<TOwner> component)
where TOwner : PageObject<TOwner>
{
var val = component.Content.Value;
var limit = val.IndexOf("/transactions");
var value = val.Substring(0, limit);
return value;
}

public static TOwner StoreValue<TOwner>(this UIComponent<TOwner> component, out string value)
where TOwner : PageObject<TOwner>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ public enum Option
{
Anonymous,
Standard,
LocalPaymentMenu
LocalPaymentMenu,
LocalPaymentMenuVerification,
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@
{
public class PayexCardInfo : PayexInfo
{
public PayexCardInfo(string creditCardNumber, string expiryDate, string cvc)
public PayexCardInfo(string creditCardNumber, string expiryDate, string cvc, bool isVerification)
{
CreditCardNumber = creditCardNumber;
ExpiryDate = expiryDate;
Cvc = cvc;
IsVerification = isVerification;
}


public string CreditCardNumber { get; }
public string Cvc { get; }
public bool IsVerification { get; }
public string ExpiryDate { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
public class PaymentMethods
{
public const string Card = "Kort";
public const string Recurring = "Recurring";
public const string Swish = "Swish";
public const string Invoice = "Faktura";
public const string Trustly = "Bankbetalning";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public void Setup()
.SetBasePath(Environment.CurrentDirectory)
.AddJsonFile("appsettings.json", true)
.AddJsonFile("appsettings.local.json", true)
.AddUserSecrets("e6f89439-1a88-4120-92cf-be2d9fe6457d", true)
.AddEnvironmentVariables()
.Build();

Expand Down Expand Up @@ -86,16 +87,29 @@ protected OrdersPage GoToOrdersPage(Product[] products, PayexInfo payexInfo, Che
});
}

protected PayexCardFramePage GoToPayexCardPaymentFrame(Product[] products, Checkout.Option checkout = Checkout.Option.Anonymous)
protected PayexCardFramePage GoToPayexCardPaymentFrame(Product[] products, PayexCardInfo payexCardInfo, Checkout.Option checkout = Checkout.Option.Anonymous)
{
PayexCardFramePage frame = null;

switch (checkout)
{
case Checkout.Option.LocalPaymentMenu:
frame = GoToLocalPaymentPage(products, checkout)
.CreditCard.IsVisible.WaitTo.BeTrue()
.CreditCard.Click()
.Do(x =>
{
if(payexCardInfo.IsVerification)
{
x
.Recurring.IsVisible.WaitTo.BeTrue()
.Recurring.Click();
}
else
{
x
.CreditCard.IsVisible.WaitTo.BeTrue()
.CreditCard.Click();
}
})
.PaymentFrame.IsVisible.WaitTo.BeTrue()
.PaymentFrame.SwitchTo<PayexCardFramePage>()
.PageSource.WaitTo.WithinSeconds(15).Contain("/psp/");
Expand Down Expand Up @@ -219,6 +233,7 @@ protected PaymentFramePage GoToPaymentFramePage(Product[] products, Checkout.Opt
.Email.SetWithSpeed(TestDataService.Email, interval: 0.1)
.PhoneNumber.SetWithSpeed(TestDataService.SwedishPhoneNumber, interval: 0.1)
.Next.Click()
.Next.IsVisible.WaitTo.WithinSeconds(10).BeFalse()
.WaitSeconds(1)
.Do(x => {
if(x.SaveMyInformation.IsVisible)
Expand Down Expand Up @@ -299,7 +314,7 @@ protected ThankYouPage PayWithPayexCard(Product[] products, PayexCardInfo info,
{
return checkout switch
{
Checkout.Option.Standard => GoToPayexCardPaymentFrame(products, checkout)
Checkout.Option.Standard => GoToPayexCardPaymentFrame(products, info, checkout)
.Do(x =>
{
if (x.PreFilledCards.Exists(new SearchOptions { IsSafely = true, Timeout = TimeSpan.FromSeconds(3) }))
Expand Down Expand Up @@ -332,12 +347,11 @@ protected ThankYouPage PayWithPayexCard(Product[] products, PayexCardInfo info,
})
.Pay.Content.Should.BeEquivalent($"Betala {string.Format("{0:N2}", Convert.ToDecimal(products.Sum(x => x.UnitPrice / 100 * x.Quantity)))} kr")
.Pay.ClickAndGo(),
_ => GoToPayexCardPaymentFrame(products, checkout)
_ => GoToPayexCardPaymentFrame(products, info, checkout)
.CreditCardNumber.IsVisible.WaitTo.BeTrue()
.CreditCardNumber.SetWithSpeed(info.CreditCardNumber, interval: 0.1)
.ExpiryDate.SetWithSpeed(info.ExpiryDate, interval: 0.1)
.Cvc.SetWithSpeed(info.Cvc, interval: 0.1)
.Pay.Content.Should.BeEquivalent($"Betala {string.Format("{0:N2}", Convert.ToDecimal(products.Sum(x => x.UnitPrice / 100 * x.Quantity)))} kr")
.Pay.ClickAndGo(),
};
}
Expand Down Expand Up @@ -429,7 +443,12 @@ protected static IEnumerable TestData(bool singleProduct = true, string paymentM
{
case PaymentMethods.Card:
data.Add(new PayexCardInfo(TestDataService.CreditCardNumber, TestDataService.CreditCardExpirationDate,
TestDataService.CreditCardCvc));
TestDataService.CreditCardCvc, false));
break;

case PaymentMethods.Recurring:
data.Add(new PayexCardInfo(TestDataService.CreditCardNumber, TestDataService.CreditCardExpirationDate,
TestDataService.CreditCardCvc, true));
break;

case PaymentMethods.Swish:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
using Atata;
using NUnit.Framework;
using Sample.AspNetCore.SystemTests.Services;
using Sample.AspNetCore.SystemTests.Test.Helpers;
using SwedbankPay.Sdk;
using SwedbankPay.Sdk.PaymentInstruments;
using SwedbankPay.Sdk.PaymentOrders;
using System;
using System.Linq;
using System.Threading.Tasks;

namespace Sample.AspNetCore.SystemTests.Test.PaymentTests.Payment
{
public class PaymentVerificationTests : Base.PaymentTests
{
public PaymentVerificationTests(string driverAlias)
: base(driverAlias)
{
}


[Test]
[Retry(2)]
[TestCaseSource(nameof(TestData), new object[] { false, PaymentMethods.Recurring })]
public async Task Payment_Card_Verification(Product[] products, PayexInfo payexInfo)
{
GoToOrdersPage(products, payexInfo, Checkout.Option.LocalPaymentMenu)
.RefreshPageUntil(x => x.Orders[y => y.Attributes["data-paymentlink"] == _referenceLink].IsVisible, 60, 10);

var cardPayment = await SwedbankPayClient.Payments.CardPayments.Get(new Uri(_referenceLink, UriKind.RelativeOrAbsolute), PaymentExpand.All);

// Global Order
Assert.That(cardPayment.Payment.Amount.InLowestMonetaryUnit, Is.EqualTo(0));
Assert.That(cardPayment.Payment.Currency.ToString(), Is.EqualTo("SEK"));
Assert.That(cardPayment.Payment.State, Is.EqualTo(State.Ready));

// Operations
Assert.That(cardPayment.Operations.Count, Is.EqualTo(2));
Assert.That(cardPayment.Operations[LinkRelation.ViewPayment], Is.Not.Null);
Assert.That(cardPayment.Operations[LinkRelation.PaidPayment], Is.Not.Null);

Assert.That(cardPayment.Payment.RecurrenceToken, Is.Not.Null);

// Transactions
Assert.That(cardPayment.Payment.Transactions.TransactionList.Count, Is.EqualTo(1));
Assert.That(cardPayment.Payment.Transactions.TransactionList.First(x => x.Type == TransactionType.Verification).State,
Is.EqualTo(State.Completed));
}

[Test]
[Retry(2)]
[TestCaseSource(nameof(TestData), new object[] { false, PaymentMethods.Recurring })]
public async Task Payment_Card_Recurring(Product[] products, PayexInfo payexInfo)
{
var page = GoToOrdersPage(products, payexInfo, Checkout.Option.LocalPaymentMenu)
.RefreshPageUntil(x => x.Orders[y => y.Attributes["data-paymentlink"] == _referenceLink].IsVisible, 60, 10)
.Orders[y => y.Attributes["data-paymentlink"] == _referenceLink].Actions.Rows[y => y.Name.Value.Contains("create-recurring")].ExecuteAction.ClickAndGo();

var paymentUriLink1 = page.SuccessMessage.StorePaymentUri();

await VerifyPayment(paymentUriLink1, products);


page = page.Orders[y => y.Attributes["data-paymentlink"] == _referenceLink].Actions.Rows[y => y.Name.Value.Contains("create-recurring")].ExecuteAction.ClickAndGo();

var paymentUriLink2 = page.SuccessMessage.StorePaymentUri();

await VerifyPayment(paymentUriLink2, products);
}

private async Task VerifyPayment(string paymentLink, Product[] products)
{
var cardPayment = await SwedbankPayClient.Payments.CardPayments.Get(new Uri(paymentLink, UriKind.RelativeOrAbsolute), PaymentExpand.All);

// Global Order
Assert.That(cardPayment.Payment.Amount.InLowestMonetaryUnit, Is.EqualTo(products.Select(x => x.UnitPrice * x.Quantity).Sum()));
Assert.That(cardPayment.Payment.Currency.ToString(), Is.EqualTo("SEK"));
Assert.That(cardPayment.Payment.State, Is.EqualTo(State.Ready));

// Operations
Assert.That(cardPayment.Operations.Count, Is.EqualTo(2));
Assert.That(cardPayment.Operations[LinkRelation.CreateReversal], Is.Not.Null);
Assert.That(cardPayment.Operations[LinkRelation.PaidPayment], Is.Not.Null);

// Transactions
Assert.That(cardPayment.Payment.Transactions.TransactionList.Count, Is.EqualTo(2));
Assert.That(cardPayment.Payment.Transactions.TransactionList.First(x => x.Type == TransactionType.Authorization).State,
Is.EqualTo(State.Completed));
Assert.That(cardPayment.Payment.Transactions.TransactionList.First(x => x.Type == TransactionType.Capture).State,
Is.EqualTo(State.Completed));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void FieldValidationCard(Product[] products)
{
Assert.DoesNotThrow(() => {
GoToPayexCardPaymentFrame(products)
GoToPayexCardPaymentFrame(products, null)
.CreditCardNumber.Set("abc")
.ExpiryDate.Set("abcd")
.Cvc.Set("abc")
Expand Down
Loading

0 comments on commit bc486b4

Please sign in to comment.