Testing for orders which end up in order state "Attention" and payment state "Pending" can be tricky. This article explains in detail how to test this state and how to verify the checkout flow implementation. Also, it shows what to do, if you would like the order status to change automatically as well to Processing.
Pre-requisites
You should have configured the OSN reports at Handelsbanken. Send them the URL http://<your domain name>/PaymentProviderResult.axd/Report/HandelsbankenFinans and ask them to configure OSN reports. Also, the mac parameter must be correct in the Litium.Studio.AddOns.HandelsbankenFinans.dll.config file in your wwwroot/bin folder.
Creating a payment that goes to Pending state
In the website, create a order with a order grand total which does not have the end digit 8 or 9. Use the payment method "Account". If you are not using Handelsbanken part payment options dropdown box but only the default Litium Studio checkout pages, in the step 3 under "Campaign Code" enter 1 as the campaign code. If you are using the dropdown box, select a partpayment option. Click Sumit button.
If handelsbanken checkout is used (in the Litium.Studio.AddOns.HandelsbankenFinans.dll.config file useHandelsbankenFinansCheckout="true" is set), you will come to the following screen. Click "Ansök" button.

In the following screen you see next, do not click "signera avtal" button when on Handelsbanken checkout flow pages, but simply click "Till butiken" button.

Now you should get redirected back to your "Receipt" page of the checkout flow. The Payment status will be set to "Pending". You should ideally check whether payment status is Reserved or Pending, and if its Pending show a warning message to the user.

Note: You have to edit your checkout flow page to show this message. In Litium Studio default implementation, the message is fetched from following code in the checkout receipt page:
//...other code
//note in following code, m_checkOutOrderReceipt is the user control responsible for showing the receipt and any messages.
else if (paymentStatus == PaymentStatus.Pending)
{
m_placeHolderCheckOutOrderReceipt.Visible = true;
CurrentState.ShoppingCart.Clear();
m_checkOutOrderReceipt.DataBind(order.ID);
m_checkOutOrderReceipt.SetErrorMessage(CurrentState.WebSite.Strings[CheckOutStringConstants.STRING_PAYMENT_PENDING]);
}
In Litium Studio backoffice, if you observe now, the Order status is "Attention" and Payment status is "Pending". (If you have not modified the default Litium Studio state machine)

Signing the Contract
Now the payment is in Pending, because the contract is not signed. In practise, Handelsbanken will contact the real customer and sign the contract. In testing, this can be done using a mock-up.
Go to https://test.saljfinans.handelsbanken.se/orderpanel/ and put the avtalsnummer and the OrgNummer and click Hämta button.

Select the order from the grid and click "Signera avtal" button. This will cause the status to change in Handelsbanken side and Litium Studio will get a OSN callback, and Litium Studio Payment status will change to Reserved. This will take about one minute for the Studio to get the notification.
Order state will remain in Attention
Note that, due to integration reasons, the order status will not change automatically from attention. The order state machine is to notify of abnormal behaviour to administrators and due to this reason Litium Studio does not normally change the status back from attention.
But you may override the studio default behaviour and place the order status also to processing. Read about how to setup your own state machine here >>.
Following code shows the total payment state builder implementation that will cause the Order Status also to go into Processing.
using Litium.Foundation.Modules.ECommerce.Orders;
using Litium.Foundation.Modules.ECommerce.Payments;
using Litium.Foundation.Modules.ECommerce.StateTransitionSystem;
namespace Litium.Studio.Site.ECommerce.StateTransition
{
/// <summary>
/// Builds Payment State Machine
/// </summary>
public class PaymentStateBuilder
{
/// <summary>
/// Builds related transitions to payment state.
/// </summary>
/// <param name="stateManager">State transitions manager.</param>
public virtual void BuildStateTransitions(StateTransitionsManager stateManager)
{
//If order is not confirmed, when starting payments, it should be confirmed.
stateManager.AddRelatedStateToPaymentState((short)PaymentStatus.ExecuteCharge, FiniteStateMachineType.Order, (short)OrderState.Confirmed);
stateManager.AddRelatedStateToPaymentState((short)PaymentStatus.ExecuteReserve, FiniteStateMachineType.Order, (short)OrderState.Confirmed);
stateManager.AddRelatedStateToPaymentState((short)PaymentStatus.ExecuteCancel, FiniteStateMachineType.Order, (short)OrderState.Confirmed);
//If any payments are initiated, order state should goto processing.
stateManager.AddRelatedStateToPaymentState((short)PaymentStatus.ExecuteCharge, FiniteStateMachineType.Order, (short)OrderState.Processing);
stateManager.AddRelatedStateToPaymentState((short)PaymentStatus.ExecuteReserve, FiniteStateMachineType.Order, (short)OrderState.Processing);
stateManager.AddRelatedStateToPaymentState((short)PaymentStatus.ExecuteCancel, FiniteStateMachineType.Order, (short)OrderState.Processing);
stateManager.AddRelatedStateToPaymentState((short)PaymentStatus.ExecuteCapture, FiniteStateMachineType.Order, (short)OrderState.Processing);
//If payment is completed, order state should be in either processing or completed.
stateManager.AddRelatedStateToPaymentState((short)PaymentStatus.Paid, FiniteStateMachineType.Order, (short)OrderState.Processing);
stateManager.AddRelatedStateToPaymentState((short)PaymentStatus.Paid, FiniteStateMachineType.Order, (short)OrderState.Completed);
//If a payment failed, order should be in attention.
stateManager.AddRelatedStateToPaymentState((short)PaymentStatus.ReserveFailed, FiniteStateMachineType.Order, (short)OrderState.Attention);
stateManager.AddRelatedStateToPaymentState((short)PaymentStatus.ChargeFailed, FiniteStateMachineType.Order, (short)OrderState.Attention);
stateManager.AddRelatedStateToPaymentState((short)PaymentStatus.ReturnFailed, FiniteStateMachineType.Order, (short)OrderState.Attention);
stateManager.AddRelatedStateToPaymentState((short)PaymentStatus.CaptureFailed, FiniteStateMachineType.Order, (short)OrderState.Attention);
stateManager.AddRelatedStateToPaymentState((short)PaymentStatus.Cancelled, FiniteStateMachineType.Order, (short)OrderState.Attention);
stateManager.AddRelatedStateToPaymentState((short)PaymentStatus.Pending, FiniteStateMachineType.Order, (short)OrderState.Attention);
//following line causes the order status to move from Attention to Processing when payment status is going to reserved.
stateManager.AddRelatedStateToPaymentState((short)PaymentStatus.Reserved, FiniteStateMachineType.Order, (short)OrderState.Processing);
//if a payment is returned, order should go to returned state.
stateManager.AddRelatedStateToPaymentState((short)PaymentStatus.Returned, FiniteStateMachineType.Order, (short)OrderState.Returned);
//the order payment status is always changed through the OrderPaymentStatus.Combination,
//because if we have more than on payment, atleast at one given moment the payment states are not the same.'
//one payment state will change first before the other payment state, unless the transition is truely parallel. - so always use combination state.
//If a payment is Paid, attempt to put orderPayment to Paid. First put to combination, then attempt to go to Paid.
stateManager.AddRelatedStateToPaymentState((short)PaymentStatus.Paid, FiniteStateMachineType.OrderPayment, (short)OrderPaymentStatus.Combination);
stateManager.AddRelatedStateToPaymentState((short)PaymentStatus.Paid, FiniteStateMachineType.OrderPayment, (short)OrderPaymentStatus.Paid);
//If a payment is Reserved, attempt to put orderPayment to Reserved. First put to combination, then attempt to go to Reserved.
stateManager.AddRelatedStateToPaymentState((short)PaymentStatus.Reserved, FiniteStateMachineType.OrderPayment, (short)OrderPaymentStatus.Combination);
stateManager.AddRelatedStateToPaymentState((short)PaymentStatus.Reserved, FiniteStateMachineType.OrderPayment, (short)OrderPaymentStatus.Reserved);
//If a payment is Failed, attempt to put orderPayment to Failed. First put to combination, then attempt to go to Failed.
stateManager.AddRelatedStateToPaymentState((short)PaymentStatus.ReserveFailed, FiniteStateMachineType.OrderPayment, (short)OrderPaymentStatus.Combination);
stateManager.AddRelatedStateToPaymentState((short)PaymentStatus.ReserveFailed, FiniteStateMachineType.OrderPayment, (short)OrderPaymentStatus.Failed);
stateManager.AddRelatedStateToPaymentState((short)PaymentStatus.ChargeFailed, FiniteStateMachineType.OrderPayment, (short)OrderPaymentStatus.Combination);
stateManager.AddRelatedStateToPaymentState((short)PaymentStatus.ChargeFailed, FiniteStateMachineType.OrderPayment, (short)OrderPaymentStatus.Failed);
stateManager.AddRelatedStateToPaymentState((short)PaymentStatus.ReturnFailed, FiniteStateMachineType.OrderPayment, (short)OrderPaymentStatus.Combination);
stateManager.AddRelatedStateToPaymentState((short)PaymentStatus.ReturnFailed, FiniteStateMachineType.OrderPayment, (short)OrderPaymentStatus.Failed);
stateManager.AddRelatedStateToPaymentState((short)PaymentStatus.CaptureFailed, FiniteStateMachineType.OrderPayment, (short)OrderPaymentStatus.Combination);
stateManager.AddRelatedStateToPaymentState((short)PaymentStatus.CaptureFailed, FiniteStateMachineType.OrderPayment, (short)OrderPaymentStatus.Failed);
stateManager.AddRelatedStateToPaymentState((short)PaymentStatus.Pending, FiniteStateMachineType.OrderPayment, (short)OrderPaymentStatus.Combination);
stateManager.AddRelatedStateToPaymentState((short)PaymentStatus.Pending, FiniteStateMachineType.OrderPayment, (short)OrderPaymentStatus.Pending);
//If a payment is cancelled, attempt to put orderPayment to Cancelled. First put to combination, then attempt to go to Cancelled.
stateManager.AddRelatedStateToPaymentState((short)PaymentStatus.Cancelled, FiniteStateMachineType.OrderPayment, (short)OrderPaymentStatus.Combination);
stateManager.AddRelatedStateToPaymentState((short)PaymentStatus.Cancelled, FiniteStateMachineType.OrderPayment, (short)OrderPaymentStatus.Cancelled);
//If a payment is returned, attempt to put order payment to Returned. First put to combination, then attempt to go to Returned.
stateManager.AddRelatedStateToPaymentState((short)PaymentStatus.Returned, FiniteStateMachineType.OrderPayment, (short)OrderPaymentStatus.Combination);
stateManager.AddRelatedStateToPaymentState((short)PaymentStatus.Returned, FiniteStateMachineType.OrderPayment, (short)OrderPaymentStatus.Returned);
}
}
}