- If you already have SwedbankPay installed, back up the Litium.AddOns.SwedbankPay.dll.config file from wwwroot.
- Open Visual Studio and your solution.
- Open Package Manager Console on the Tools > NuGet Package Manager menu. If you have multiple projects in the solution, ensure that the web application project (e.g. Litium.Accelerator.Mvc ) is selected as Default project in Package Manager Console.
- Install the nuget-packages with the following commands in Package Manager Console:
Install-Package Litium.AddOns.SwedbankPay
Install-Package Litium.AddOns.SwedbankPay.UI
- Update the Litium.AddOns.SwedbankPay.dll.config found in wwwroot and enter your configuration options.
- It is mandatory to use TLS security (HTTPS). (If you are using Accelerator 7, enable this by setting a HSTS max age value in the domain url to be a value more than zero.)
Checkout page code changes
Following checkout page code changes are required for the SwedbankPay payments to work.
Constants used in below code such as "TermsUrl", "LogoUrl" are defined in the Litium.AddOns.SwedbankPay.dll assembly in Litium.AddOns.SwedbankPay.ConstantsAndKeys class.
Terms Url
Terms page is mandatory and its Url is mandatory when creating the payments, and should be an absolute Url. This page should specify the merchnats terms and conditions. It need to be sent as part of CheckoutFlow info, when placing the order.
In accelerator, you may obtain the terms url as follows.
var checkoutPage = _requestModelAccessor.RequestModel.WebsiteModel.Fields.GetValue<PointerPageItem>(AcceleratorWebsiteFieldNameConstants.CheckouPage);
var checkoutPageUrl = GetAbsolutePageUrl(checkoutPage);
var checkoutPageEntity = checkoutPage.EntitySystemId.MapTo<Web.Models.Websites.PageModel>();
var termsAndConditionPage = checkoutPageEntity.GetValue<PointerPageItem>(CheckoutPageFieldNameConstants.TermsAndConditionsPage);
var termsAndConditionPageUrl = GetAbsolutePageUrl(termsAndConditionPage);
Then, the url should be sent using the CheckFlowInfo, in PlaceOrder method.
//Method signature is modified to pass in the absolute Urls
public override ExecutePaymentResult PlaceOrder(CheckoutViewModel model, string responseUrl, string cancelUrl, string termsUrl, string logoUrl, out string redirectUrl)
{
//Other code...
checkoutFlowInfo.SetValue("TermsUrl", termsUrl);
checkoutFlowInfo.SetValue("LogoUrl", logoUrl);
//Other code...
_cartService.PlaceOrder(out PaymentInfo[] paymentInfos);
//Other code...
}
Logo Url
Logo Url is not mandatory, but can be used to show the merchants website logo in the SwedbankPay site.
Url should be an absolute Url.
checkoutFlowInfo.SetValue("LogoUrl", logoUrl);
Description
A text description (maximum 40 charactors) can be shown in the page where buyer is entering payment details in SwedbankPay.
checkoutFlowInfo.SetValue("Description", "your description to show to buyer");