Skip to content

Commit

Permalink
Merge branch 'hotfix/13.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
mattbrailsford committed Jan 12, 2024
2 parents 35c98bb + c725471 commit 5574dd3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public override async Task<PaymentFormResult> GenerateFormAsync(PaymentProviderC
}).ToList();

// Add shipping method fee ctx.Orderline
if (ctx.Order.ShippingInfo.ShippingMethodId.HasValue && ctx.Order.ShippingInfo.TotalPrice.Value.WithTax > 0)
if (ctx.Order.ShippingInfo.ShippingMethodId.HasValue && ctx.Order.ShippingInfo.TotalPrice.WithoutAdjustments.WithTax > 0)
{
var shippingMethod = Context.Services.ShippingMethodService.GetShippingMethod(ctx.Order.ShippingInfo.ShippingMethodId.Value);

Expand Down Expand Up @@ -173,6 +173,26 @@ public override async Task<PaymentFormResult> GenerateFormAsync(PaymentProviderC
});
}

// Add gift cards
if (ctx.Order.TransactionAmount.Adjustment.Value < 0)
{
foreach (GiftCardAdjustment giftcard in ctx.Order.TransactionAmount.Adjustments)
{
orderLines.Add(new KlarnaOrderLine
{
Reference = "Gift Card " + giftcard.GiftCardCode,
Name = "Discounts",
Type = KlarnaOrderLine.Types.GIFT_CARD,
TaxRate = (int)(ctx.Order.TaxRate * 10000),
UnitPrice = 0,
Quantity = 1,
TotalDiscountAmount = (int)AmountToMinorUnits(giftcard.Amount) * -1,
TotalAmount = (int)AmountToMinorUnits(giftcard.Amount),
TotalTaxAmount = 0,
});
}
}

// Create a merchant session
var resp1 = await client.CreateMerchantSessionAsync(
new KlarnaCreateMerchantSessionOptions
Expand All @@ -183,7 +203,7 @@ public override async Task<PaymentFormResult> GenerateFormAsync(PaymentProviderC
Locale = ctx.Order.LanguageIsoCode, // TODO: Validate?

OrderLines = orderLines,
OrderAmount = (int)AmountToMinorUnits(ctx.Order.TotalPrice.Value.WithTax),
OrderAmount = (int)AmountToMinorUnits(ctx.Order.TransactionAmount.Value),
OrderTaxAmount = (int)AmountToMinorUnits(ctx.Order.TotalPrice.Value.Tax),

BillingAddress = new KlarnaAddress
Expand Down
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
"version": "13.0.0",
"version": "13.0.1",
"assemblyVersion": {
"precision": "build"
},
Expand Down

0 comments on commit 5574dd3

Please sign in to comment.