Developer forum

Forum » Integration » RE: Capture part of full payment API

RE: Capture part of full payment API

Keld Gøtterup
Reply

Im having trouble capturing a smaller amount than what the order was originally.



if (order.IsCaptureSupported)
{

      order.CaptureAmount = partAmount;
      order.Save();
      OrderCaptureInfo result = order.Capture(partAmount, true);

}

The above code does capture but its always the full amount. what am i missing to capture only part of the full amount?


Replies

 
Nicolai Høeg Pedersen
Reply

Hi keld

What payment provider are you using?

BR Nicolai

 
Keld Gøtterup
Reply

Quickpay

 
Nicolai Høeg Pedersen
Reply

Ok, then it should work if you are using 8.4+ where the quickpay provider supports split capture¨.

Which version are you running on?

 
Nicolai Høeg Pedersen
Reply
This post has been marked as an answer

From the release notes:

 

"It is now possible to split the capture amount when using DIBS (Visa, Mastercard, Visa-dankort, Dankort through the acquirer NETS/PBS) or Quickpay (Dankort). If the provider and card supports split capture you get a pop-up where you can select split capture and write the split amount to capture. It is possible to capture several times but maximum is the rest of the authorized amount.

 

In order to use split capture with DIBS you need to contact the DIBS support that will enable it for the merchant."

Votes for this answer: 1
 
Keld Gøtterup
Reply

im using version 8.4.1.11
Hmm... ill just check again to see if everything is set correctly in quickpay.

 
Keld Gøtterup
Reply

There doesn't seem to be any specifik setting for split payment in quickpay. It should work with default settings.
http://quickpay.dk/features/split-payment/

any idea to what might be wrong?

 
Nicolai Høeg Pedersen
Reply

Hi Keld

I've asked a developer to look into the matter and get back to you on this thread.

Nicolai

 
Keld Gøtterup
Reply

Any news from the developer? :)

 
Nicolai Høeg Pedersen
Reply

Yes.

You are doing it the same way as we do - so it should work.

Can you do it from the admin interface?

Nicolai

 
Keld Gøtterup
Reply

yes the admin interface does it correctly

 
Keld Gøtterup
Reply

Any idea of what could be wrong with my code?

 
Nicolai Høeg Pedersen
Reply
This post has been marked as an answer

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
Votes for this answer: 1
 
Keld Gøtterup
Reply

thank you i will look in your code and hopefully find my answer :)

 

You must be logged in to post in the forum