To use Swedbank Pay PAX terminal for handling cards with certain product restrictions, such as fuel cards, only affects the implementation regarding the call to Payment
and handling the response.
When calling PaymentAsync
or the synchronous version Payment
the version using a TransactionSetup
as parameter must be used in order to pass a list of products for the purchase.
If the result has ResponseResult
set to failure and the ErrorCondition
is PaymentRestriction
the list of AllowedProducts
will indicate if any product may be purchase with the card.
Product List
The list of products that is passed in the TransactionSetup
consists of one or more SaleItem
objects.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
namespace SwpTrmLib.Nexo
{
public class SaleItem
{
public enum UnitsOfMeasure { None, Litre, Centilitre, Kilometre, Kilogram, Gram, Metre, Centimetre, Other};
public UnitsOfMeasure UnitOfMeasure { get; set; } = UnitsOfMeasure.None;
public string Quantity { get; set; } = string.Empty;
public Decimal UnitPrice { get; set; } = Decimal.Zero;
public string ProductLabel { get; set; } = string.Empty;
public string AdditionalProductInfo { get; set; } = string.Empty;
//Attributes
public int ItemID { get; set; } = int.MinValue ;
//digit strings
public string ProductCode { get; set; } = string.Empty;
public Decimal ItemAmount { get; set; } = Decimal.Zero;
public SaleItem();
public XElement XML();
public override string ToString();
}
}
Type | Name | Description | |
UnitsOfMeasure | UnitOfMeasures | Litre or Kilogram | Mandatory |
Decimal | Quantity | Mandatory | |
string | ProductLabel | Name of product | Optional |
string | AdditionalProductInfo | Optional | |
int | ItemID | 0-n | Mandatory |
string | ProductCode | Digits | Mandatory |
Decimal | ItemAmount | Total product price | Mandatory |
Functions | |||
XElement | XML | Returns the nexo SaleItem element | used internally |
Start Payment
Starting a payment would be done similar to the following:
Example creating a list of sale items for a purchase
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
ISwpTrmIf_1 PAX;
.
.
.
List<SaleItem> saleItems = new List<SaleItem>();
saleItems.Add(new SaleItem()
{
ItemID = 0,
ItemAmount = (decimal)25.5,
ProductCode = "24601",
UnitOfMeasure = SaleItem.UnitsOfMeasure.Litre,
Quantity = "10",
UnitPrice = (decimal)2.55,
ProductLabel = "Stellar",
AdditionalProductInfo = "The best there is"
});
saleItems.Add(new SaleItem()
{
ItemID = 1,
ItemAmount = (decimal)29.5,
ProductCode = "2564",
Quantity = "1",
UnitPrice = (decimal)29.5
});
PaymentRequestResult r = await PAX.Payment(new TransactionSetup(){
Amount = (decimal)55,
SaleItems = saleItems
});
When Failure
If the PaymentRequestResult.ResponseResult
is Failure
the transaction has failed either for a normal reason or, if ErrorCondition
is PaymentRestriction
, due to the restriction for the card used. The PaymentRequestResult
has a property named AllowedProducts
that is a list of product codes from the request that may be purchased using the same card. If the list is empty none of the products can be purchased with the card used.
Let’s say the above example failed and the AllowedProducts
has one item with value “24601”, then the customer may either change card or just buy that product. A new Payment must be issued with a new list of SaleItem with just that one product and the amount 25.5. This is also typically when you set the flag SplitPayment
if the other goods are paid with an other card or cash.