Skip to content

Commit

Permalink
Merge pull request #9 from gopaycommunity/partial-capture
Browse files Browse the repository at this point in the history
Added method for partial capture function
  • Loading branch information
FSichinger authored Oct 5, 2017
2 parents 4812630 + 5d72d6e commit 3acc5e9
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions GoPay.net-sdk/GoPay.net-sdk.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
<Compile Include="src\Model\Payment\BankAccount.cs" />
<Compile Include="src\Model\Payment\BasePayment.cs" />
<Compile Include="src\Model\Payment\Callback.cs" />
<Compile Include="src\Model\Payment\CapturePayment.cs" />
<Compile Include="src\Model\Payment\EnabledPaymentInstrument.cs" />
<Compile Include="src\Model\Payment\Group.cs" />
<Compile Include="src\Model\Payment\Image.cs" />
Expand Down
10 changes: 10 additions & 0 deletions GoPay.net-sdk/src/GPConnector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,16 @@ public async Task<PaymentResult> CapturePaymentAsync(long id)
return await Task.Factory.StartNew(() => Deserialize<PaymentResult>(response.Content));
}

/// <exception cref="GPClientException"></exception>
public PaymentResult CapturePayment(long id, CapturePayment capturePayment)
{
var restRequest = CreateRestRequest(@"/payments/payment/{id}/capture", "application/json");
restRequest.AddParameter("id", id, ParameterType.UrlSegment);
restRequest.AddJsonBody(capturePayment);
var response = Client.Execute(restRequest);
return ProcessResponse<PaymentResult>(response);
}

/// <exception cref="GPClientException"></exception>
public PaymentResult VoidAuthorization(long id)
{
Expand Down
21 changes: 21 additions & 0 deletions GoPay.net-sdk/src/Model/Payment/CapturePayment.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using GoPay.EETProp;

namespace GoPay.Model.Payments
{
public class CapturePayment
{

[JsonProperty("amount")]
public long Amount { get; set; }

[JsonProperty("items")]
public List<OrderItem> Items { get; set; }

[JsonProperty("eet")]
public EET Eet { get; set; }

}
}

0 comments on commit 3acc5e9

Please sign in to comment.