Posted on 03/09/2014 12:23:01
Hi Keld
In quickpay, only split capture is supported for Dankort. It is a Dankort transaction that has been used in the test? (Can also be a VDK card, but it has to be a DK-transaction)
This is how we do it in our code:
Private Sub AJAXCapture()
'Get OrderID
Dim orderID As String = Base.Request("CaptureOrderID")
If String.IsNullOrEmpty(orderID) Then
Return
End If
'Get Order
Dim order As Order = If(order.GetOrderByID(orderID), New Order())
If String.IsNullOrEmpty(order.ID) Then
Return
End If
Dim serializer As JavaScriptSerializer = New JavaScriptSerializer()
Dim CaptureAmount As Double = Base.DoubleParseWithCulture(Base.Request("CaptureAmount"))
Dim FinalCapture As Boolean = Base.ChkBoolean(Base.Request("FinalCapture"))
Dim SplitAmount As Boolean = Base.ChkBoolean(Base.Request("SplitAmount"))
Dim authorizedAmount As Double = order.TransactionAmount + order.ExternalPaymentFee
If SplitAmount AndAlso CaptureAmount + order.CaptureAmount > authorizedAmount Then
Dim toJson As New Dictionary(Of String, Object)
toJson.Add("orderCaptureState", OrderCaptureInfo.OrderCaptureState.Failed.ToString())
toJson.Add("orderCaptureInfoDate", DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss", Base.GetCulture(False)))
toJson.Add("orderCaptureMessage", Dynamicweb.Backend.Translate.Translate("The amount to capture is greater than the remainder of the authorized amount."))
'Write to response
Response.Write(serializer.Serialize(toJson))
Return
End If
'Capture
Dim result As OrderCaptureInfo
If SplitAmount Then
If Math.Abs(authorizedAmount - order.CaptureAmount - CaptureAmount) < 0.001 Then
FinalCapture = True
End If
result = order.Capture(CType(CaptureAmount * 100, Long), FinalCapture)
ElseIf order.CaptureAmount > 0 Then
FinalCapture = True
CaptureAmount = authorizedAmount - order.CaptureAmount
result = order.Capture(CType(CaptureAmount * 100, Long), True)
Else
result = order.Capture()
End If
'Write json
If result IsNot Nothing Then
Dim toJson As New Dictionary(Of String, Object)
toJson.Add("orderCaptureState", result.State.ToString())
toJson.Add("orderCaptureInfoDate", result.CaptureTime.ToString("dd-MM-yyyy HH:mm:ss", Base.GetCulture(False)))
toJson.Add("orderCaptureMessage", result.Message)
If result.State = OrderCaptureInfo.OrderCaptureState.Split Then
toJson.Add("orderCaptureAmount", Dynamicweb.eCommerce.Common.Application.DefaultCurrency.Format(authorizedAmount - order.CaptureAmount, False))
toJson.Add("orderCaptureHistoryMsg", "Split capture")
toJson.Add("orderCaptureHistoryAmount", Dynamicweb.eCommerce.Common.Application.DefaultCurrency.Format(CaptureAmount, False))
ElseIf result.State = OrderCaptureInfo.OrderCaptureState.Success AndAlso FinalCapture Then
toJson.Add("orderCaptureHistoryMsg", "Split capture(final)")
toJson.Add("orderCaptureHistoryAmount", Dynamicweb.eCommerce.Common.Application.DefaultCurrency.Format(CaptureAmount, False))
End If
'Write to response
Response.Write(serializer.Serialize(toJson))
End If
End Sub